33#ifndef __H__COMMON__MATH_TENSOR__
34#define __H__COMMON__MATH_TENSOR__
38#include "../../types.h"
52template <
size_t TRank,
size_t N,
typename T = number>
class MathTensor;
54template <
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);}
99template <
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;}
143template <
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] <<
"]";
158template <
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;}
198template <
size_t N,
typename T = number>
201template <
size_t N1,
size_t N2,
typename T = number>
204template <
size_t N1,
size_t N2,
size_t N3,
typename T = number>
207template <
size_t N1,
size_t N2,
size_t N3,
size_t N4,
typename T = number>
210template <
typename TEntry>
214 outStream << v[0] <<
"]";
218template <
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
void set(T val)
Definition math_tensor.h:131
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
MathTensor & operator=(T val)
sets all values of the tensor to a value
Definition math_tensor.h:130
size_t rank() const
Definition math_tensor.h:127
const value_type & operator[](size_t i) const
Definition math_tensor.h:134
void assign(const MathTensor< 1, N, T > &v)
Definition math_tensor.h:137
MathTensor(const bool init=true)
Definition math_tensor.h:116
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
MathTensor & operator=(const MathTensor &v)
Definition math_tensor.h:75
void set(T val)
Definition math_tensor.h:86
value_type m_data[N]
Definition math_tensor.h:95
MathTensor & operator=(T val)
sets all values of the tensor to a value
Definition math_tensor.h:85
MathTensor(const MathTensor &v)
Definition math_tensor.h:72
size_t rank() const
Definition math_tensor.h:82
MathTensor()
Definition math_tensor.h:71
size_t size_type
Definition math_tensor.h:62
const value_type & operator[](size_t i) const
Definition math_tensor.h:89
value_type & operator[](size_t i)
Definition math_tensor.h:88
static const size_t Dimension
Definition math_tensor.h:65
static const size_t Rank
Definition math_tensor.h:68
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(const MathTensorX &v)
Definition math_tensor.h:176
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
const value_type & operator[](size_t i) const
Definition math_tensor.h:189
static const size_t Dimension
Definition math_tensor.h:169
MathTensorX & operator=(const MathTensorX &v)
Definition math_tensor.h:179
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