21 #ifndef TNT_ARRAY2D_UTILS_H
22 #define TNT_ARRAY2D_UTILS_H
37 s << M <<
" " << N <<
"\n";
39 for (
int i=0; i<M; i++)
41 for (
int j=0; j<N; j++)
62 for (
int i=0; i<M; i++)
63 for (
int j=0; j<N; j++)
86 for (
int i=0; i<m; i++)
88 for (
int j=0; j<n; j++)
89 C[i][j] = A[i][j] + B[i][j];
101 if (B.
dim1() != m || B.
dim2() != n )
108 for (
int i=0; i<m; i++)
110 for (
int j=0; j<n; j++)
111 C[i][j] = A[i][j] - B[i][j];
124 if (B.
dim1() != m || B.
dim2() != n )
131 for (
int i=0; i<m; i++)
133 for (
int j=0; j<n; j++)
134 C[i][j] = A[i][j] * B[i][j];
149 if (B.
dim1() != m || B.
dim2() != n )
156 for (
int i=0; i<m; i++)
158 for (
int j=0; j<n; j++)
159 C[i][j] = A[i][j] / B[i][j];
175 if (B.
dim1() == m || B.
dim2() == n )
177 for (
int i=0; i<m; i++)
179 for (
int j=0; j<n; j++)
194 if (B.
dim1() == m || B.
dim2() == n )
196 for (
int i=0; i<m; i++)
198 for (
int j=0; j<n; j++)
213 if (B.
dim1() == m || B.
dim2() == n )
215 for (
int i=0; i<m; i++)
217 for (
int j=0; j<n; j++)
234 if (B.
dim1() == m || B.
dim2() == n )
236 for (
int i=0; i<m; i++)
238 for (
int j=0; j<n; j++)
270 for (
int i=0; i<M; i++)
271 for (
int j=0; j<K; j++)
275 for (
int k=0; k<N; k++)
276 sum += A[i][k] * B [k][j];
Definition: tnt_array2d.h:38
int dim1() const
Definition: tnt_array2d.h:231
int dim2() const
Definition: tnt_array2d.h:234
Definition: tnt_array1d.h:36
Array1D< T > operator+(const Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:64
Array1D< T > & operator-=(Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:174
Array1D< T > & operator/=(Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:209
Array2D< T > matmult(const Array2D< T > &A, const Array2D< T > &B)
Definition: tnt_array2d_utils.h:259
Array1D< T > operator*(const Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:107
Array1D< T > operator-(const Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:86
Array1D< T > & operator+=(Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:156
Array1D< T > & operator*=(Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:191
Array1D< T > operator/(const Array1D< T > &A, const Array1D< T > &B)
Definition: tnt_array1d_utils.h:128
std::ostream & operator<<(std::ostream &s, const Array1D< T > &A)
Definition: tnt_array1d_utils.h:31
std::istream & operator>>(std::istream &s, Array1D< T > &A)
Definition: tnt_array1d_utils.h:49
T sum(const std::vector< T > &array, int start, int end)
Definition: essentiamath.h:117