31 multi1d(T *f,
int ns1) {F=f; n1=ns1;copymem=
true;}
50 for(
int i=0; i < n1; ++i)
60 int size()
const {
return n1;}
70 for(
int i=0; i < n1; ++i)
81 std::cerr <<
"multi1d: left hand side not initialized in =" << std::endl;
85 for(
int i=0; i < n1; ++i)
95 std::cerr <<
"multi1d: left hand side not initialized in =" << std::endl;
99 for(
int i=0; i < n1; ++i)
110 std::cerr <<
"multi1d: Sizes incompatible in +=" << std::endl;
114 for(
int i=0; i < n1; ++i)
125 std::cerr <<
"multi1d: left hand side not initialized in +=" << std::endl;
129 for(
int i=0; i < n1; ++i)
140 std::cerr <<
"multi1d: Sizes incompatible in -=" << std::endl;
144 for(
int i=0; i < n1; ++i)
155 std::cerr <<
"multi1d: left hand side not initialized in -=" << std::endl;
159 for(
int i=0; i < n1; ++i)
170 std::cerr <<
"multi1d: Sizes incompatible in *=" << std::endl;
174 for(
int i=0; i < n1; ++i)
185 std::cerr <<
"multi1d: left hand side not initialized in *=" << std::endl;
189 for(
int i=0; i < n1; ++i)
200 std::cerr <<
"multi1d: Sizes incompatible in /=" << std::endl;
204 for(
int i=0; i < n1; ++i)
215 std::cerr <<
"multi1d: left hand side not initialized in /=" << std::endl;
219 for(
int i=0; i < n1; ++i)
259 std::cerr <<
"multi1d: invalid resize of a copy of memory" << std::endl;
264 F =
new(std::nothrow) T[n1];
266 QDP_error_exit(
"Unable to allocate memory in multi1d::resize(%d)\n",ns1);
296 for(
int i=0; i < l.
size(); ++i)
299 for(
int i=0; i < r.
size(); ++i)
312 for(
int i=0; i < n1.
size(); ++i)
333 for(
int i=0; i < len; ++i)
336 return (a[i] < b[i]) ? true :
false;
339 return (a.
size() == b.
size()) ? false : (a.
size() < b.
size()) ? true :
false;
349 for(
int i=0; i < len; ++i)
352 return (a[i] > b[i]) ? true :
false;
355 return (a.
size() == b.
size()) ? false : (a.
size() > b.
size()) ? true :
false;
363 return (a < b) || (a == b);
371 return (a > b) || (a == b);
504 for(
int i(0);i<a.
size();i++)
519 for(
int i(0);i<a.
size();i++)
534 for(
int i(0);i<a.
size();i++)
550 for(
int i(0);i<a.
size();i++)
565 for(
int i(0);i<a.
size();i++)
580 for(
int i(0);i<a.
size();i++)
596 for(
int i(0);i<a.
size();i++)
611 for(
int i(0);i<a.
size();i++)
628 for(
int i=1; i < a.
size(); ++i)
643 multi2d(T *f,
int ns2,
int ns1) {F=f; n1=ns1; n2=ns2; sz=n1*n2; copymem=
true;}
652 for(
int i=0; i < sz; ++i)
659 std::cerr <<
"multi2d: invalid resize of a copy of memory" << std::endl;
666 F =
new(std::nothrow) T[sz];
668 QDP_error_exit(
"Unable to new memory in multi2d::resize(%d,%d)\n",ns2,ns1);
685 for(
int i=0; i < sz; ++i)
696 std::cerr <<
"multi2d: left hand side not initialized in =" << std::endl;
700 for(
int i=0; i < sz; ++i)
706 const T*
slice(
int j)
const {
return F+n1*j;}
736 multi3d(T *f,
int ns3,
int ns2,
int ns1) {F=f; n1=ns1; n2=ns2; n3=ns3; sz=n1*n2*n3; copymem=
true;}
737 explicit multi3d(
int ns3,
int ns2,
int ns1) {copymem=
false;F=0;
resize(ns3,ns2,ns1);}
741 multi3d(
const multi3d& s): copymem(false), n1(s.n1), n2(s.n2), n3(s.n3), sz(s.sz), F(0)
745 for(
int i=0; i < sz; ++i)
753 std::cerr <<
"multi3d: invalid resize of a copy of memory" << std::endl;
763 n1=ns1; n2=ns2; n3=ns3; sz=n1*n2*n3; F =
new(std::nothrow) T[sz];
765 QDP_error_exit(
"Unable to new memory in multi3d::resize(%d,%d,%d)\n",ns3,ns2,ns1);
784 for(
int i=0; i < sz; ++i)
795 std::cerr <<
"multi3d: left hand side not initialized in =" << std::endl;
799 for(
int i=0; i < sz; ++i)
805 const T*
slice(
int k,
int j)
const {
return F+n1*(j+n2*(k));}
808 T&
operator()(
int k,
int j,
int i) {
return F[i+n1*(j+n2*(k))];}
811 const T&
operator()(
int k,
int j,
int i)
const {
return F[i+n1*(j+n2*(k))];}
834 multi4d() {F=0;n1=n2=n3=n4=sz=0;copymem=
false;}
835 multi4d(T *f,
int ns4,
int ns3,
int ns2,
int ns1) {F=f; n1=ns1; n2=ns2; n3=ns3; n4=ns4; sz=n1*n2*n3*n4; copymem=
true;}
836 explicit multi4d(
int ns4,
int ns3,
int ns2,
int ns1) {copymem=
false;F=0;
resize(ns4,ns3,ns2,ns1);}
840 multi4d(
const multi4d& s): copymem(false), n1(s.n1), n2(s.n2), n3(s.n3), n4(s.n4), sz(s.sz), F(0)
844 for(
int i=0; i < sz; ++i)
849 void resize(
int ns4,
int ns3,
int ns2,
int ns1)
852 std::cerr <<
"multi4d: invalid resize of a copy of memory" << std::endl;
862 n1=ns1; n2=ns2; n3=ns3; n4=ns4; sz=n1*n2*n3*n4; F =
new(std::nothrow) T[sz];
864 QDP_error_exit(
"Unable to new memory in multi4d::resize(%d,%d,%d,%d)\n",ns4,ns3,ns2,ns1);
879 for(
int i=0; i < sz; ++i)
890 std::cerr <<
"multi4d: left hand side not initialized in =" << std::endl;
894 for(
int i=0; i < sz; ++i)
900 const T*
slice(
int l,
int k,
int j)
const {
return F+n1*(j+n2*(k+n3*(l)));}
903 T&
operator()(
int l,
int k,
int j,
int i) {
return F[i+n1*(j+n2*(k+n3*(l)))];}
906 const T&
operator()(
int l,
int k,
int j,
int i)
const {
return F[i+n1*(j+n2*(k+n3*(l)))];}
930 multi5d() {F=0;n1=n2=n3=n4=n5=sz=0;copymem=
false;}
931 multi5d(T *f,
int ns5,
int ns4,
int ns3,
int ns2,
int ns1) {F=f; n1=ns1; n2=ns2; n3=ns3; n4=ns4; n5=ns5; sz=n1*n2*n3*n4*n5; copymem=
true;}
932 explicit multi5d(
int ns4,
int ns3,
int ns2,
int ns1) {copymem=
false;F=0;
resize(ns4,ns3,ns2,ns1);}
936 multi5d(
const multi5d& s): copymem(false), n1(s.n1), n2(s.n2), n3(s.n3), n4(s.n4), n5(s.n5), sz(s.sz), F(0)
940 for(
int i=0; i < sz; ++i)
945 void resize(
int ns5,
int ns4,
int ns3,
int ns2,
int ns1)
948 std::cerr <<
"multi5d: invalid resize of a copy of memory" << std::endl;
958 n1=ns1; n2=ns2; n3=ns3; n4=ns4; n5=ns5; sz=n1*n2*n3*n4*n5; F =
new(std::nothrow) T[sz];
960 QDP_error_exit(
"Unable to new memory in multi5d::resize(%d,%d,%d,%d,%d)\n",ns5,ns4,ns3,ns2,ns1);
976 for(
int i=0; i < sz; ++i)
987 std::cerr <<
"multi5d: left hand side not initialized in =" << std::endl;
991 for(
int i=0; i < sz; ++i)
997 const T*
slice(
int m,
int l,
int k,
int j)
const{
return F+n1*(j+n2*(k+n3*(l+n4*(m))));}
1000 T&
operator()(
int m,
int l,
int k,
int j,
int i) {
return F[i+n1*(j+n2*(k+n3*(l+n4*(m))))];}
1003 const T&
operator()(
int m,
int l,
int k,
int j,
int i)
const {
return F[i+n1*(j+n2*(k+n3*(l+n4*(m))))];}
1037 for(
int i=0; i < sz; ++i)
1047 for(
int i=1; i < nz.size(); ++i)
1049 F =
new(std::nothrow) T[sz];
1051 std::cerr <<
"Unable to new memory in multiNd::resize(): sz= " << sz <<
" size= ";
1052 for(
int i=0; i < _nz.
size(); ++i) {
1053 std::cerr <<
" " << _nz[i];
1055 std::cerr << std::endl;
1062 int size(
int i)
const {
return nz[i];}
1077 for(
int i=0; i < sz; ++i)
1088 std::cerr <<
"multiNd: left hand side not initialized in =" << std::endl;
1092 for(
int i=0; i < sz; ++i)
1102 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1114 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1126 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1130 return F[i+nz[0]*j];
1138 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1142 return F[i+nz[0]*j];
1150 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1154 return F[i+nz[0]*(j+nz[1]*(k))];
1162 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1166 return F[i+nz[0]*(j+nz[1]*(k))];
1174 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1178 return F[i+nz[0]*(j+nz[1]*(k+nz[2]*l))];
1186 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1190 return F[i+nz[0]*(j+nz[1]*(k+nz[2]*l))];
1196 if (ind.
size() != nz.size())
1198 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1203 for(
int i=1; i < nz.size(); ++i)
1204 off = off*nz[i] + ind[i];
1212 if (ind.
size() != nz.size())
1214 std::cerr <<
"multiNd: improper rank of array indices" << std::endl;
1219 for(
int i=1; i < nz.size(); ++i)
1220 off = off*nz[i] + ind[i];
1229 if (off < 0 || off >= sz)
1231 std::cerr <<
"multiNd: index out of bounds" << std::endl;
1242 if (off < 0 || off >= sz)
1244 std::cerr <<
"multiNd: index out of bounds" << std::endl;
Container for a multi-dimensional 1D array.
const T & operator[](int i) const
Return const ref to an element.
void revertFromFastMemoryHint(bool copy=false)
multi1d< T > & operator=(const T *s1)
Set equal to a old-style C 1-D array.
multi1d< T > & operator-=(const T &s1)
Subtract-replace on each element.
multi1d< T > & operator+=(const T &s1)
Add-replace on each element.
const T & operator()(int i) const
Return const ref to an element.
multi1d< T > & operator/=(const multi1d< T > &s1)
Divide-replace on each element.
multi1d< T > & operator-=(const multi1d< T > &s1)
Subtract-replace on each element.
void moveToFastMemoryHint(bool copy=false)
multi1d & operator=(const multi1d &s1)
Equal operator uses underlying = of T.
T & operator[](int i)
Return ref to an element.
multi1d< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
multi1d< T > & operator+=(const multi1d< T > &s1)
Add-replace on each element.
multi1d(const multi1d &s)
Copy constructor.
int size() const
Size of array.
T & operator()(int i)
Return ref to an element.
void resize(int ns1)
Resize routine, call a templated resize, using *this to disambiguate.
const T * slice() const
Return ref to a column slice.
multi1d< T > & operator*=(const multi1d< T > &s1)
Mult-replace on each element.
multi1d< T > & operator/=(const T &s1)
Divide-replace on each element.
multi1d< T > & operator*=(const T &s1)
Mult-replace on each element.
Container for a multi-dimensional 2D array.
void resize(int ns2, int ns1)
Allocate mem for the array.
multi2d< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
const T * slice(int j) const
Return ref to a row slice.
multi2d(const multi2d &s)
Copy constructor.
T & operator()(int j, int i)
Return ref to an element.
int size1() const
Size of array.
multi1d< T > operator[](int j)
Return ref to an element.
multi2d(int ns2, int ns1)
const T & operator()(int j, int i) const
Return const ref to an element.
int nrows() const
Another variant on the size of the 2d array.
multi2d< T > & operator=(const multi2d< T > &s1)
Equal operator uses underlying = of T.
const multi1d< T > operator[](int j) const
Return const ref to an element.
multi2d(T *f, int ns2, int ns1)
Container for a multi-dimensional 3D array.
multi2d< T > operator[](int k)
Return ref to an element.
const T * slice(int k, int j) const
Return ref to a column slice.
T & operator()(int k, int j, int i)
Return ref to an element.
multi3d< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
multi3d(const multi3d &s)
Copy constructor.
int leftSize() const
Another variant on the size of the 3d array.
int size1() const
Size of array.
multi3d(T *f, int ns3, int ns2, int ns1)
const multi2d< T > operator[](int k) const
Return const ref to an element.
multi3d(int ns3, int ns2, int ns1)
const T & operator()(int k, int j, int i) const
Return const ref to an element.
void resize(int ns3, int ns2, int ns1)
Allocate mem for the array.
multi3d< T > & operator=(const multi3d< T > &s1)
Equal operator uses underlying = of T.
Container for a multi-dimensional 4D array.
int size1() const
Size of array.
const T * slice(int l, int k, int j) const
Return ref to a column slice.
T & operator()(int l, int k, int j, int i)
Return ref to an element.
multi4d< T > & operator=(const multi4d< T > &s1)
Equal operator uses underlying = of T.
multi4d(int ns4, int ns3, int ns2, int ns1)
const T & operator()(int l, int k, int j, int i) const
Return const ref to an element.
multi4d< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
const multi3d< T > operator[](int l) const
Return const ref to an element.
multi4d(T *f, int ns4, int ns3, int ns2, int ns1)
multi4d(const multi4d &s)
Copy constructor.
multi3d< T > operator[](int l)
Return ref to an element.
void resize(int ns4, int ns3, int ns2, int ns1)
Allocate mem for the array.
multi5d< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
int size1() const
Size of array.
const multi4d< T > operator[](int m) const
Return const ref to an element.
multi5d< T > & operator=(const multi5d< T > &s1)
Equal operator uses underlying = of T.
multi5d(const multi5d &s)
Copy constructor.
void resize(int ns5, int ns4, int ns3, int ns2, int ns1)
Allocate mem for the array.
const T & operator()(int m, int l, int k, int j, int i) const
Return const ref to an element.
multi4d< T > operator[](int m)
Return ref to an element.
multi5d(int ns4, int ns3, int ns2, int ns1)
T & operator()(int m, int l, int k, int j, int i)
Return ref to an element.
multi5d(T *f, int ns5, int ns4, int ns3, int ns2, int ns1)
const T * slice(int m, int l, int k, int j) const
Return ref to a column slice.
const T & operator[](const multi1d< int > &ind) const
Return ref to an element via indices packed in a multi1d array.
T & operator()(int k, int j, int i)
Return ref to an element.
T & operator[](const multi1d< int > &ind)
Return ref to an element via indices packed in a multi1d array.
void resize(const multi1d< int > &_nz)
Allocate mem for the array.
T & operator()(int l, int k, int j, int i)
Return ref to an element.
T & getElem(int off)
Return ref to an element with index flattened over indices.
multiNd< T > & operator=(const T1 &s1)
Equal operator uses underlying = of T.
T & operator()(int i)
Return ref to an element.
multiNd(const multi1d< int > &_nz)
const T & operator()(int l, int k, int j, int i) const
Return const ref to an element.
const multi1d< int > & size() const
Size of an array containing sizes of each index.
int size(int i) const
Size of i-th array index. Indices run from left to right in operator().
const T & operator()(int k, int j, int i) const
Return const ref to an element.
int numElem() const
Number of elements in the array.
const T & getElem(int off) const
Return const-ref to an element with index flattened over indices.
const T & operator()(int j, int i) const
Return const ref to an element.
multiNd< T > & operator=(const multiNd< T > &s1)
Equal operator uses underlying = of T.
const T & operator()(int i) const
Return const ref to an element.
T & operator()(int j, int i)
Return ref to an element.
multiNd(const multiNd &s)
Copy constructor.
UnaryReturn< C, FnNorm2 >::Type_t norm2(const QDPType< T, C > &s1)
OScalar = norm2(trace(adj(source)*source)).
multi1d< T > concat(const multi1d< T > &l, const multi1d< T > &r)
Concatenate two Array's.
Yet another random number generator.
MakeReturn< BinaryNode< OpEQ, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpEQ >::Type_t >::Expression_t operator==(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< BinaryNode< OpGT, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpGT >::Type_t >::Expression_t operator>(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
void QDP_error_exit(const char *format,...)
Simple error display and abort routine.
MakeReturn< BinaryNode< OpMultiply, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpMultiply >::Type_t >::Expression_t operator*(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< BinaryNode< OpAdd, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpAdd >::Type_t >::Expression_t operator+(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< UnaryNode< FnCos, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnCos >::Type_t >::Expression_t cos(const QDPExpr< T1, C1 > &l)
MakeReturn< BinaryNode< OpSubtract, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpSubtract >::Type_t >::Expression_t operator-(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< UnaryNode< FnArcTan, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnArcTan >::Type_t >::Expression_t atan(const QDPExpr< T1, C1 > &l)
MakeReturn< UnaryNode< FnArcSin, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnArcSin >::Type_t >::Expression_t asin(const QDPExpr< T1, C1 > &l)
MakeReturn< BinaryNode< OpGE, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpGE >::Type_t >::Expression_t operator>=(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
void QDP_abort(int status)
Panic button.
MakeReturn< BinaryNode< OpDivide, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpDivide >::Type_t >::Expression_t operator/(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< UnaryNode< FnSin, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSin >::Type_t >::Expression_t sin(const QDPExpr< T1, C1 > &l)
MakeReturn< UnaryNode< FnArcCos, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnArcCos >::Type_t >::Expression_t acos(const QDPExpr< T1, C1 > &l)
MakeReturn< BinaryNode< OpLT, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpLT >::Type_t >::Expression_t operator<(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< BinaryNode< OpNE, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpNE >::Type_t >::Expression_t operator!=(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< UnaryNode< FnSqrt, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSqrt >::Type_t >::Expression_t sqrt(const QDPExpr< T1, C1 > &l)
MakeReturn< UnaryNode< FnTan, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnTan >::Type_t >::Expression_t tan(const QDPExpr< T1, C1 > &l)
MakeReturn< BinaryNode< OpLE, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, OpLE >::Type_t >::Expression_t operator<=(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
MakeReturn< UnaryNode< FnLog, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnLog >::Type_t >::Expression_t log(const QDPExpr< T1, C1 > &l)