33 #ifndef __INCLUDE_MIST_OPERATOR_ARRAY3__
34 #define __INCLUDE_MIST_OPERATOR_ARRAY3__
47 template <
class T,
class Allocator >
48 inline const array3< T, Allocator >&
operator +=( array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
50 typedef typename array3< T, Allocator >::size_type size_type;
51 #if _CHECK_ARRAY3_OPERATION_ != 0
52 if( a1.size( ) != a2.size( ) )
55 ::std::cerr <<
"can't add array3s." << ::std::endl;
59 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] += static_cast< T >( a2[i] );
73 template <
class T,
class Allocator >
74 inline const array3< T, Allocator >&
operator -=( array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
76 typedef typename array3< T, Allocator >::size_type size_type;
77 #if _CHECK_ARRAY3_OPERATION_ != 0
78 if( a1.size( ) != a2.size( ) )
81 ::std::cerr <<
"can't subtract array3s." << ::std::endl;
85 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] -= static_cast< T >( a2[i] );
99 template <
class T,
class Allocator >
100 inline const array3< T, Allocator >&
operator *=( array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
102 typedef typename array3< T, Allocator >::size_type size_type;
103 #if _CHECK_ARRAY3_OPERATION_ != 0
104 if( a1.size( ) != a2.size( ) )
107 ::std::cerr <<
"can't multiply array3s." << ::std::endl;
111 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] *= static_cast< T >( a2[i] );
125 template <
class T,
class Allocator >
126 inline const array3< T, Allocator >&
operator /=( array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
128 typedef typename array3< T, Allocator >::size_type size_type;
129 #if _CHECK_ARRAY3_OPERATION_ != 0
130 if( a1.size( ) != a2.size( ) )
133 ::std::cerr <<
"can't divide array3s." << ::std::endl;
137 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] /= static_cast< T >( a2[i] );
151 template <
class T,
class Allocator >
152 inline const array3< T, Allocator >&
operator +=( array3< T, Allocator > &a1,
typename array3< T, Allocator >::value_type val )
154 typedef typename array3< T, Allocator >::size_type size_type;
155 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] += val;
169 template <
class T,
class Allocator >
170 inline const array3< T, Allocator >&
operator -=( array3< T, Allocator > &a1,
typename array3< T, Allocator >::value_type val )
172 typedef typename array3< T, Allocator >::size_type size_type;
173 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] -= val;
187 template <
class T,
class Allocator >
188 inline const array3< T, Allocator >&
operator *=( array3< T, Allocator > &a1,
typename array3< T, Allocator >::value_type val )
190 typedef typename array3< T, Allocator >::size_type size_type;
191 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] *= val;
205 template <
class T,
class Allocator >
206 inline const array3< T, Allocator >&
operator /=( array3< T, Allocator > &a1,
typename array3< T, Allocator >::value_type val )
208 typedef typename array3< T, Allocator >::size_type size_type;
209 #if _CHECK_ARRAY3_OPERATION_ != 0
213 ::std::cerr <<
"zero division occured." << ::std::endl;
217 for( size_type i = 0 ; i < a1.size( ) ; i++ ) a1[i] /= val;
231 template <
class T,
class Allocator >
232 inline array3< T, Allocator >
operator -(
const array3< T, Allocator > &a )
234 typedef typename array3< T, Allocator >::size_type size_type;
235 array3< T, Allocator > o( a.size1( ), a.size2( ), a.size3( ), a.reso1( ), a.reso2( ), a.reso3( ) );
236 for( size_type i = 0 ; i < o.size( ) ; i++ ) o[i] = -a[i];
251 template <
class T,
class Allocator >
252 inline array3< T, Allocator >
operator +(
const array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
254 array3< T, Allocator > tmp( a1 );
269 template <
class T,
class Allocator >
270 inline array3< T, Allocator >
operator -(
const array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
272 array3< T, Allocator > tmp( a1 );
287 template <
class T,
class Allocator >
288 inline array3< T, Allocator >
operator *(
const array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
290 array3< T, Allocator > tmp( a1 );
305 template <
class T,
class Allocator >
306 inline array3< T, Allocator >
operator /(
const array3< T, Allocator > &a1,
const array3< T, Allocator > &a2 )
308 array3< T, Allocator > tmp( a1 );
322 template <
class T,
class Allocator >
323 inline array3< T, Allocator >
operator +(
const array3< T, Allocator > &a,
typename array3< T, Allocator >::value_type val )
325 array3< T, Allocator > tmp( a );
326 return( tmp += val );
339 template <
class T,
class Allocator >
340 inline array3< T, Allocator >
operator +(
typename array3< T, Allocator >::value_type val,
const array3< T, Allocator > &a )
342 array3< T, Allocator > tmp( a );
343 return( tmp += val );
356 template <
class T,
class Allocator >
357 inline array3< T, Allocator >
operator -(
const array3< T, Allocator > &a,
typename array3< T, Allocator >::value_type val )
359 array3< T, Allocator > tmp( a );
360 return( tmp -= val );
373 template <
class T,
class Allocator >
374 inline array3< T, Allocator >
operator -(
typename array3< T, Allocator >::value_type val,
const array3< T, Allocator > &a )
376 array3< T, Allocator > tmp( a.size1( ), a.size2( ), a.size3( ), val );
391 template <
class T,
class Allocator >
392 inline array3< T, Allocator >
operator *(
const array3< T, Allocator > &a,
typename array3< T, Allocator >::value_type val )
394 array3< T, Allocator > tmp( a );
395 return( tmp *= val );
408 template <
class T,
class Allocator >
409 inline array3< T, Allocator >
operator *(
typename array3< T, Allocator >::value_type val,
const array3< T, Allocator > &a )
411 array3< T, Allocator > tmp( a );
412 return( tmp *= val );
426 template <
class T,
class Allocator >
427 inline array3< T, Allocator >
operator /(
const array3< T, Allocator > &a,
typename array3< T, Allocator >::value_type val )
429 array3< T, Allocator > tmp( a );
430 return( tmp /= val );
435 #endif // __INCLUDE_MIST_OPERATOR_ARRAY3__