TF++, Miscellaneous classes and modules in C++:
blitzutil.h
Go to the documentation of this file.
1 
35 // include guard
36 #ifndef TF_BLITZUTIL_H_VERSION
37 
38 #define TF_BLITZUTIL_H_VERSION \
39  "TF_BLITZUTIL_H V1.0 "
40 
41 #include<blitz/array.h>
42 #include<tfxx/error.h>
43 
44 namespace tfxx {
45 
53 namespace blitzutil {
54 
62  template<class T1, class T2, int N1, int N2>
63  bool sameShape(const blitz::Array<T1,N1>& a1,
64  const blitz::Array<T2,N2>& a2)
65  { return(blitz::areShapesConformable(a1.shape(),a2.shape())); }
66 
74  template<class T1, class T2, int N1, int N2>
75  bool sameDomain(const blitz::Array<T1,N1>& a1,
76  const blitz::Array<T2,N2>& a2)
77  { return(blitz::areShapesConformable(a1.lbound(),a2.lbound())&&
78  blitz::areShapesConformable(a1.ubound(),a2.ubound())); }
79 
89  template<class T, int N>
90  void setToSameDomain(blitz::Array<T,N>& array,
91  const blitz::RectDomain<N>& domain,
92  const blitz::GeneralArrayStorage<N>&
93  storage=blitz::fortranArray)
94  {
95  blitz::TinyVector<int, N> extent;
96  for (int i=0; i<N; i++)
97  { extent[i]=domain.ubound()[i]-domain.lbound()[i]+1; }
98  blitz::Array<T, N> result(domain.lbound(),extent,storage);
99  array.reference(result);
100  }
101 
102 } // namespace blitzutil
103 
104 } // namespace tfxx
105 
106 #endif // TF_BLITZUTIL_H_VERSION (includeguard)
107 
108 /* ----- END OF blitzutil.h ----- */
bool sameDomain(const blitz::Array< T1, N1 > &a1, const blitz::Array< T2, N2 > &a2)
test for conforming domains
Definition: blitzutil.h:75
void setToSameDomain(blitz::Array< T, N > &array, const blitz::RectDomain< N > &domain, const blitz::GeneralArrayStorage< N > &storage=blitz::fortranArray)
create a second array spanning the same domain
Definition: blitzutil.h:90
bool sameShape(const blitz::Array< T1, N1 > &a1, const blitz::Array< T2, N2 > &a2)
test for conforming shapes
Definition: blitzutil.h:63
Namespace containing all code of library libtfxx.