ivl 679
|
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>. 00002 A C++ template library extending syntax towards mathematical notation. 00003 00004 Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr> 00005 Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr> 00006 00007 ivl is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License 00009 version 3 as published by the Free Software Foundation. 00010 00011 Alternatively, you can redistribute it and/or modify it under the terms 00012 of the GNU General Public License version 2 as published by the Free 00013 Software Foundation. 00014 00015 ivl is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 and a copy of the GNU Lesser General Public License along 00022 with ivl. If not, see <http://www.gnu.org/licenses/>. */ 00023 00024 #ifndef IVL_ARRAY_FUNCTIONS_DETAILS_ASSIGN_OPERATORS_HPP 00025 #define IVL_ARRAY_FUNCTIONS_DETAILS_ASSIGN_OPERATORS_HPP 00026 00027 namespace ivl { 00028 /* 00029 template <class T, class S, class K, class J, class D, class P> 00030 typename array<T, S, K>::derived_type operator*=( 00031 array<T, S, K>& l, const array<J, D, P>& r) 00032 { 00033 loops::loop<loops::assign_times_class<T, J> >(l.derived(), r.derived()); 00034 return l.derived(); 00035 } 00036 00037 template <class T, class S, class K> 00038 typename array<T, S, K>::derived_type operator*=( 00039 array<T, S, K>& l, const T& r) 00040 { 00041 typename array_details::scalar_to_array<T, array<T, S, K> >:: 00042 type v(l.derived().size(), r); 00043 loops::loop<loops::assign_times_class<T, T> >(l.derived(), v); 00044 return l.derived(); 00045 } 00046 00047 #define HELPA(OP, CLAS) \ 00048 template <class T, class S, class K, class J, class D, class P> \ 00049 typename array<T, S, K>::derived_type OP( \ 00050 array<T, S, K>& l, const array<J, D, P>& r) \ 00051 { \ 00052 loops::loop<loops::CLAS<T, J> >(l.derived(), r.derived()); \ 00053 return l.derived(); \ 00054 }\ 00055 \ 00056 template <class T, class S, class K> \ 00057 typename array<T, S, K>::derived_type OP( \ 00058 array<T, S, K>& l, const T& r) \ 00059 { \ 00060 typename array_details::scalar_to_array<T, array<T, S, K> >:: \ 00061 type v(l.derived().size(), r); \ 00062 loops::loop<loops::CLAS<T, T> >(l.derived(), v); \ 00063 return l.derived(); \ 00064 } \ 00065 00066 //todo: some ops need to be defined for some special types 00067 //when operating with scalar, e.g. int for % 00068 //the plan is to define for a few types, e.g. float, double, 00069 //long long, int, and char and also T but automatically disable the 00070 //T specialization if T in the pre-defined types, so that 00071 //we avoid the already defined error. for now 00072 // we leave only the vs T element which is inadequate. 00073 00074 00075 HELPA(operator/=, assign_divide_class) 00076 //HELPA(operator+=, assign_plus_class) 00077 HELPA(operator-=, assign_minus_class) 00078 HELPA(operator%=, assign_mod_class) 00079 00080 HELPA(operator|=, assign_bitor_class) 00081 HELPA(operator&=, assign_bitand_class) 00082 HELPA(operator^=, assign_bitxor_class) 00083 00084 HELPA(operator>>=, assign_bitrshift_class) 00085 HELPA(operator<<=, assign_bitlshift_class) 00086 00087 00088 00089 00090 00091 00092 template <class T, class S, class K, class J, class D, class P> 00093 typename array<T, S, K>::derived_type operator+=( 00094 array<T, S, K>& l, const array<J, D, P>& r) 00095 { 00096 loops::loop<loops::assign_plus_class<T, J> >(l.derived(), r.derived()); 00097 return l.derived(); 00098 } 00099 00100 template <class T, class S, class K> 00101 typename array<T, S, K>::derived_type operator+=( 00102 array<T, S, K>& l, const T& r) 00103 { 00104 typename array_details::scalar_to_array<T, array<T, S, K> >:: 00105 type v(l.derived().size(), r); 00106 loops::loop<loops::assign_plus_class<T, T> >(l.derived(), v); 00107 return l.derived(); 00108 } 00109 00110 00111 00112 00113 */ 00114 00115 // need to make unary loops too. for -- ++. 00116 00117 00118 } /* namespace ivl */ 00119 00120 #endif // IVL_ARRAY_FUNCTIONS_DETAILS_ASSIGN_OPERATORS_HPP