20
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
22
* @author: $LastChangedBy: dutka $
23
* @date: $LastChangedDate: 2007-05-02 14:59:25 +0200 (mer, 02 mai 2007) $
24
* Id: $Id: Tensor.hxx 424 2007-05-02 12:59:25Z dutka $
23
* @date: $LastChangedDate: 2008-10-31 11:52:04 +0100 (ven 31 oct 2008) $
24
* Id: $Id: Tensor.hxx 995 2008-10-31 10:52:04Z dutka $
26
26
#ifndef OPENTURNS_TENSOR_HXX
27
27
#define OPENTURNS_TENSOR_HXX
29
#include "TensorImplementation.hxx"
29
30
#include "TypedInterfaceObject.hxx"
30
#include "TensorImplementation.hxx"
33
33
namespace OpenTURNS
56
typedef Common::InvalidDimensionException InvalidDimensionException ;
57
typedef Common::InvalidArgumentException InvalidArgumentException ;
58
typedef Common::TypedInterfaceObject<TensorImplementation>::Implementation Implementation ;
58
typedef Common::InvalidDimensionException InvalidDimensionException;
59
typedef Common::InvalidArgumentException InvalidArgumentException;
60
typedef Common::TypedInterfaceObject<TensorImplementation>::Implementation Implementation;
60
62
/** Default constructor */
61
Tensor(const String & name = OT::DefaultName);
63
65
/** Constructor with size (rowDim, colDim, sheetDim) */
64
Tensor(UnsignedLong rowDim, UnsignedLong colDim, UnsignedLong sheetDim, const String & name = OT::DefaultName);
66
Tensor(const UnsignedLong rowDim,
67
const UnsignedLong colDim,
68
const UnsignedLong sheetDim);
66
70
/** Constructor from range of external collection */
67
71
template <class InputIterator>
68
Tensor(UnsignedLong rowDim, UnsignedLong colDim, UnsignedLong sheetDim,
69
InputIterator first, InputIterator last,
70
const String & name = OT::DefaultName);
72
Tensor(const UnsignedLong rowDim,
73
const UnsignedLong colDim,
74
const UnsignedLong sheetDim,
72
78
/** Constructor from external collection */
73
Tensor(UnsignedLong rowDim, UnsignedLong colDim, UnsignedLong sheetDim, const Collection<NumericalScalar> & elementsValues, const String & name = OT::DefaultName);
79
Tensor(const UnsignedLong rowDim,
80
const UnsignedLong colDim,
81
const UnsignedLong sheetDim,
82
const Collection<NumericalScalar> & elementsValues);
75
84
/** String converter */
76
85
virtual String str() const;
79
88
/** Operator () gives access to the elements of the tensor (to modify these elements) */
80
89
/** The element of the tensor is designated by its row number i, its column number j and its sheet number k */
81
NumericalScalar & operator () (UnsignedLong i, UnsignedLong j, UnsignedLong k) throw(InvalidDimensionException);
90
NumericalScalar & operator () (const UnsignedLong i,
92
const UnsignedLong k) throw(InvalidDimensionException);
83
94
/** Operator () gives access to the elements of the tensor (read only) */
84
95
/** The element of the tensor is designated by its row number i, its column number j and its sheet number k */
85
const NumericalScalar & operator () (UnsignedLong i, UnsignedLong j, UnsignedLong k) const throw(InvalidDimensionException);
96
const NumericalScalar & operator () (const UnsignedLong i,
98
const UnsignedLong k) const throw(InvalidDimensionException);
88
101
/** getSheet returns the sheet specified by its sheet number k */
89
Matrix getSheet(UnsignedLong k) const throw(InvalidDimensionException);
102
Matrix getSheet(const UnsignedLong k) const throw(InvalidDimensionException);
91
104
/** setSheet sets matrix m as the sheet specified by its sheet number k */
92
void setSheet(UnsignedLong k, Matrix & m) throw(InvalidDimensionException);
105
void setSheet(const UnsignedLong k,
106
const Matrix & m) throw(InvalidDimensionException);
94
108
/** Get the dimensions of the tensor */
95
109
/** Number of rows */
117
131
/** Constructor with size (rowDim, colDim, sheetDim) */
118
132
template <class InputIterator>
119
Tensor::Tensor(UnsignedLong rowDim, UnsignedLong colDim, UnsignedLong sheetDim,
120
InputIterator first, InputIterator last,
122
: Common::TypedInterfaceObject<TensorImplementation>(new TensorImplementation(rowDim,colDim,sheetDim,first,last,name))
133
Tensor::Tensor(const UnsignedLong rowDim,
134
const UnsignedLong colDim,
135
const UnsignedLong sheetDim,
138
: Common::TypedInterfaceObject<TensorImplementation>(new TensorImplementation(rowDim, colDim, sheetDim, first, last))