MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::tensor Namespace Reference

Namespace that contains all classes, functions and constants needed for Tensor. More...

Namespaces

namespace  detail_
 

Classes

class  Tensor
 Provides a lightweight and fast class for accessing 1D arrays as multi-dimensional tensors (up to 4D). More...
 

Functions

template<class TT >
std::ostream & operator<< (std::ostream &os, const Tensor< TT > &t)
 Prints the values of the Tensor object together with the respective index. More...
 
template<class TT >
void swap (Tensor< TT > &a, Tensor< TT > &b)
 Non-member swap exchanges the contents of two Tensors. More...
 

Detailed Description

Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2012-11-13

Function Documentation

◆ operator<<()

template<class TT >
std::ostream & maia::tensor::operator<< ( std::ostream &  os,
const Tensor< TT > &  t 
)
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2012-11-09
Template Parameters
TTScalar data type of the tensor elements.
Parameters
[in]osOutput stream that should be written to.
[in]indexerThe indexer object.
Returns
The output stream for further concatenation.

Definition at line 722 of file tensor.h.

722 {
723 for(MInt i = 0; i < t.dim0(); i++) {
724 for(MInt j = 0; j < t.dim1(); j++) {
725 for(MInt k = 0; k < t.dim2(); k++) {
726 for(MInt l = 0; l < t.dim3(); l++) {
727 os << "(" << i << "," << j << "," << k << "," << l << ") = ";
728 os << t(i, j, k, l) << std::endl;
729 }
730 }
731 }
732 }
733
734 os << "Dimensions (i,j,k,l) = (" << t.dim0() << "," << t.dim1() << "," << t.dim2() << "," << t.dim3() << ")"
735 << std::endl;
736
737 return os;
738}
size_type dim0() const
Return the size of dimension 0.
Definition: tensor.h:366
size_type dim1() const
Return the size of dimension 1.
Definition: tensor.h:380
size_type dim2() const
Return the size of dimension 2.
Definition: tensor.h:394
size_type dim3() const
Return the size of dimension 3.
Definition: tensor.h:408
int32_t MInt
Definition: maiatypes.h:62

◆ swap()

template<class TT >
void maia::tensor::swap ( Tensor< TT > &  a,
Tensor< TT > &  b 
)
inline
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2012-11-13
Template Parameters
TTScalar data type of the tensor elements.
Parameters
[in]aThe first tensor to be swapped.
[in]bThe second tensor to be swapped.

Definition at line 752 of file tensor.h.

752 {
753 a.swap(b);
754}
Definition: contexttypes.h:19