33 #ifndef __H__COMMON__MATH_TENSOR__
34 #define __H__COMMON__MATH_TENSOR__
38 #include "../../types.h"
51 template <
size_t TRank,
size_t N,
typename T = number>
class MathTensor;
54 template <
size_t TRank,
size_t N,
typename T>
68 static const size_t Rank = TRank;
81 inline size_t size()
const {
return N;}
82 inline size_t rank()
const {
return TRank;}
86 inline void set(T val) {
for(
size_t i = 0; i < N; ++i)
m_data[i].
set(val);}
99 template <
size_t N,
typename T>
122 if(
this != &v){
assign(v);}
126 inline size_t size()
const {
return N;}
127 inline size_t rank()
const {
return 1;}
131 inline void set(T val) {
for(
size_t i = 0; i < N; ++i)
m_data[i] = val;}
143 template <
size_t TRank,
size_t N,
typename T>
147 for(
size_t i = 0; i < v.
size()-1; ++i)
148 outStream << v[i] <<
", ";
149 outStream << v[v.
size()-1] <<
"]";
158 template <
typename TEntry,
size_t N>
172 static const size_t Rank = TEntry::Rank+1;
181 if(
this != &v){
assign(v);}
185 inline size_t size()
const {
return N;}
198 template <
size_t N,
typename T = number>
201 template <
size_t N1,
size_t N2,
typename T = number>
204 template <
size_t N1,
size_t N2,
size_t N3,
typename T = number>
207 template <
size_t N1,
size_t N2,
size_t N3,
size_t N4,
typename T = number>
210 template <
typename TEntry>
214 outStream << v[0] <<
"]";
218 template <
typename TEntry,
size_t N>
222 for(
size_t i = 0; i < N-1; ++i)
223 outStream << v[i] <<
", ";
224 outStream << v[N-1] <<
"]";
Definition: math_tensor.h:199
Definition: math_tensor.h:202
Definition: math_tensor.h:205
Definition: math_tensor.h:208
Definition: math_tensor.h:101
void set(T val)
Definition: math_tensor.h:131
const value_type & operator[](size_t i) const
Definition: math_tensor.h:134
size_t size() const
Definition: math_tensor.h:126
MathTensor(const MathTensor &v)
Definition: math_tensor.h:117
size_t size_type
Definition: math_tensor.h:107
size_t rank() const
Definition: math_tensor.h:127
void assign(const MathTensor< 1, N, T > &v)
Definition: math_tensor.h:137
MathTensor(const bool init=true)
Definition: math_tensor.h:116
MathTensor & operator=(T val)
sets all values of the tensor to a value
Definition: math_tensor.h:130
T value_type
Definition: math_tensor.h:104
value_type & operator[](size_t i)
Definition: math_tensor.h:133
a mathematical Tensor of rank TRank and N entries.
Definition: math_tensor.h:56
void assign(const MathTensor< TRank, N, T > &v)
Definition: math_tensor.h:92
MathTensor< TRank-1, N, T > value_type
Definition: math_tensor.h:59
size_t size() const
Definition: math_tensor.h:81
void set(T val)
Definition: math_tensor.h:86
value_type m_data[N]
Definition: math_tensor.h:95
MathTensor(const MathTensor &v)
Definition: math_tensor.h:72
size_t rank() const
Definition: math_tensor.h:82
MathTensor()
Definition: math_tensor.h:71
value_type & operator[](size_t i)
Definition: math_tensor.h:88
MathTensor & operator=(T val)
sets all values of the tensor to a value
Definition: math_tensor.h:85
size_t size_type
Definition: math_tensor.h:62
static const size_t Dimension
Definition: math_tensor.h:65
const value_type & operator[](size_t i) const
Definition: math_tensor.h:89
static const size_t Rank
Definition: math_tensor.h:68
MathTensor & operator=(const MathTensor &v)
Definition: math_tensor.h:75
Definition: math_tensor.h:160
size_t rank() const
Definition: math_tensor.h:186
TEntry value_type
Definition: math_tensor.h:163
MathTensorX()
Definition: math_tensor.h:175
MathTensorX & operator=(const MathTensorX &v)
Definition: math_tensor.h:179
MathTensorX(const MathTensorX &v)
Definition: math_tensor.h:176
const value_type & operator[](size_t i) const
Definition: math_tensor.h:189
void assign(const MathTensorX< TEntry, N > &v)
Definition: math_tensor.h:192
static const size_t Rank
Definition: math_tensor.h:172
value_type & operator[](size_t i)
Definition: math_tensor.h:188
TEntry m_data[N]
Definition: math_tensor.h:195
size_t size_type
Definition: math_tensor.h:166
static const size_t Dimension
Definition: math_tensor.h:169
size_t size() const
Definition: math_tensor.h:185
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
#define UG_ASSERT(expr, msg)
Definition: assert.h:70