/* * \file tnt_array3d_utils.h * \brief tnt_array3d_utils.h */ #ifndef IMPALGEBRA_TNT_ARRAY_3D_UTILS_H #define IMPALGEBRA_TNT_ARRAY_3D_UTILS_H #include #include #include IMPALGEBRA_BEGIN_INTERNAL_NAMESPACE namespace TNT { using namespace std; template std::ostream& operator<<(std::ostream &s, const Array3D &A) { int M=A.dim1(); int N=A.dim2(); int K=A.dim3(); s << M << " " << N << " " << K << "\n"; for (int i=0; i std::istream& operator>>(std::istream &s, Array3D &A) { int M, N, K; s >> M >> N >> K; Array3D B(M,N,K); for (int i=0; i> B[i][j][k]; A = B; return s; } template Array3D operator+(const Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() != m || B.dim2() != n || B.dim3() != p ) return Array3D(); else { Array3D C(m,n,p); for (int i=0; i Array3D operator-(const Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() != m || B.dim2() != n || B.dim3() != p ) return Array3D(); else { Array3D C(m,n,p); for (int i=0; i Array3D operator*(const Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() != m || B.dim2() != n || B.dim3() != p ) return Array3D(); else { Array3D C(m,n,p); for (int i=0; i Array3D operator/(const Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() != m || B.dim2() != n || B.dim3() != p ) return Array3D(); else { Array3D C(m,n,p); for (int i=0; i Array3D& operator+=(Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() == m && B.dim2() == n && B.dim3() == p ) { for (int i=0; i Array3D& operator-=(Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() == m && B.dim2() == n && B.dim3() == p ) { for (int i=0; i Array3D& operator*=(Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() == m && B.dim2() == n && B.dim3() == p ) { for (int i=0; i Array3D& operator/=(Array3D &A, const Array3D &B) { int m = A.dim1(); int n = A.dim2(); int p = A.dim3(); if (B.dim1() == m && B.dim2() == n && B.dim3() == p ) { for (int i=0; i