1#ifndef chi_math_tensorNX_h
2#define chi_math_tensorNX_h
20 template<
int R,
int N,
class NumberFormat>
23 std::vector<VectorNX<N,NumberFormat>>
entries;
30 static_assert(std::is_floating_point<NumberFormat>::value,
31 "Only floating point number formats are supported for TensorRNX." );
33 const int num_rank1_entries = std::pow(N,R-1);
34 entries.resize(num_rank1_entries);
40 static_assert(std::is_floating_point<NumberFormat>::value,
41 "Only floating point number formats are supported for TensorRNX." );
43 const int num_rank1_entries = std::pow(N,R-1);
78 template<
int N,
class NumberFormat>
81 std::vector<VectorNX<N,NumberFormat>>
entries;
88 static_assert(std::is_floating_point<NumberFormat>::value,
89 "Only floating point number formats are supported for TensorRNX." );
91 const int num_rank1_entries = std::pow(N,2-1);
92 entries.resize(num_rank1_entries);
98 static_assert(std::is_floating_point<NumberFormat>::value,
99 "Only floating point number formats are supported for TensorRNX." );
101 const int num_rank1_entries = std::pow(N,2-1);
137 for (
int i=0; i<N; ++i)
139 const auto& this_row =
entries[i];
140 const auto& that_row = that.
entries[i];
141 for (
int j=0; j<N; ++j)
142 new_t(i)(j) = this_row[j] + that_row[j];
152 for (
int i=0; i<N; ++i)
154 const auto& that_row = that.
entries[i];
155 for (
int j=0; j<N; ++j)
156 this->entries[i](j) += that_row[j];
168 for (
int i=0; i<N; ++i)
170 const auto& this_row =
entries[i];
171 const auto& that_row = that.
entries[i];
172 for (
int j=0; j<N; ++j)
173 new_t(i)(j) = this_row[j] - that_row[j];
183 for (
int i=0; i<N; ++i)
185 const auto& that_row = that.
entries[i];
186 for (
int j=0; j<N; ++j)
187 this->entries[i](j) -= that_row[j];
199 for (
int i=0; i<N; ++i)
201 const auto& this_row =
entries[i];
202 for (
int j=0; j<N; ++j)
203 new_t(i)(j) = this_row[j]*value;
213 for (
int i=0; i<N; ++i)
214 for (
int j=0; j<N; ++j)
215 this->entries[i](j) *= value;
226 for (
int i=0; i<N; ++i)
228 const auto& this_row =
entries[i];
229 for (
int j=0; j<N; ++j)
230 new_t(i)(j) = this_row[j]/value;
240 for (
int i=0; i<N; ++i)
241 for (
int j=0; j<N; ++j)
242 this->entries[i](j) /= value;
253 for (
int i=0; i<N; ++i)
254 for (
int j=0; j<N; ++j)
256 const auto& this_row =
entries[j];
257 new_t(i)(j) = this_row[i];
269 for (
int i=0; i<N; ++i)
271 const auto& this_row =
entries[i];
272 new_vec(i) = this_row.
Dot(v);
283 for (
int i=0; i<N; ++i)
285 const auto& this_row =
entries[i];
286 new_vec(i) = this_row[i];
297 for (
int i=0; i<N; ++i)
299 const auto& this_row =
entries[i];
310 std::stringstream out;
312 for (
int i=0; i<N; ++i)
315 for (
int j=0; j<(N-1); ++j)
326 template<
int R,
int N>
335template<
int N,
class NumberFormat>
341 for (
int i=0; i<N;++i)
342 for (
int j=0; j<N; ++j)
343 new_tensor(i)(j) = that[i][j]*value;
chi_math::TensorRNX< 2, N, NumberFormat > operator*(const double value, const chi_math::TensorRNX< 2, N, NumberFormat > &that)
std::vector< VectorNX< N, NumberFormat > > entries
const unsigned int dimension
TensorRNX(const NumberFormat value)
VectorNX< N, NumberFormat > operator[](const int i)
TensorRNX & operator=(const TensorRNX &rhs)
VectorNX< N, NumberFormat > Dot(const TensorRNX< 2, N, NumberFormat > &that) const