28 using std::runtime_error;
108 assert( c < mcr.mextent );
111 mcr.mstart + c * mcr.mstride,
121 const Range& c)
const 125 assert( r < mrr.mextent );
128 mrr.mstart + r * mrr.mstride,
138 const Range& c)
const 142 assert( p < mpr.mextent );
145 mpr.mstart + p * mpr.mstride,
155 const Range& c)
const 159 assert( b < mbr.mextent );
162 mbr.mstart + b * mbr.mstride,
177 assert( r < mrr.mextent );
178 assert( c < mcr.mextent );
181 mrr.mstart + r * mrr.mstride +
182 mcr.mstart + c * mcr.mstride,
197 assert( p < mpr.mextent );
198 assert( c < mcr.mextent );
201 mpr.mstart + p * mpr.mstride +
202 mcr.mstart + c * mcr.mstride,
212 const Range& c)
const 217 assert( p < mpr.mextent );
218 assert( r < mrr.mextent );
221 mpr.mstart + p * mpr.mstride +
222 mrr.mstart + r * mrr.mstride,
232 const Range& c)
const 237 assert( b < mbr.mextent );
238 assert( r < mrr.mextent );
241 mbr.mstart + b * mbr.mstride +
242 mrr.mstart + r * mrr.mstride,
257 assert( b < mbr.mextent );
258 assert( c < mcr.mextent );
261 mbr.mstart + b * mbr.mstride +
262 mcr.mstart + c * mcr.mstride,
272 const Range& c)
const 277 assert( b < mbr.mextent );
278 assert( p < mpr.mextent );
281 mbr.mstart + b * mbr.mstride +
282 mpr.mstart + p * mpr.mstride,
298 assert( p < mpr.mextent );
299 assert( r < mrr.mextent );
300 assert( c < mcr.mextent );
303 mpr.mstart + p * mpr.mstride +
304 mrr.mstart + r * mrr.mstride +
305 mcr.mstart + c * mcr.mstride,
321 assert( b < mbr.mextent );
322 assert( r < mrr.mextent );
323 assert( c < mcr.mextent );
326 mbr.mstart + b * mbr.mstride +
327 mrr.mstart + r * mrr.mstride +
328 mcr.mstart + c * mcr.mstride,
344 assert( b < mbr.mextent );
345 assert( p < mpr.mextent );
346 assert( c < mcr.mextent );
349 mbr.mstart + b * mbr.mstride +
350 mpr.mstart + p * mpr.mstride +
351 mcr.mstart + c * mcr.mstride,
361 const Range& c)
const 367 assert( b < mbr.mextent );
368 assert( p < mpr.mextent );
369 assert( r < mrr.mextent );
372 mbr.mstart + b * mbr.mstride +
373 mpr.mstart + p * mpr.mstride +
374 mrr.mstart + r * mrr.mstride,
387 if (mbr.mstart != 0 || mbr.mstride != mpr.mextent * mrr.mextent * mcr.mextent
388 || mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent
389 || mrr.mstart != 0 || mrr.mstride != mcr.mextent
390 || mcr.mstart != 0 || mcr.mstride != 1)
391 throw std::runtime_error(
"A Tensor4View can only be converted to a plain C-array if it's pointing to a continuous block of data");
404 if (mbr.mstart != 0 || mbr.mstride != mpr.mextent * mrr.mextent * mcr.mextent
405 || mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent
406 || mrr.mstart != 0 || mrr.mstride != mcr.mextent
407 || mcr.mstart != 0 || mcr.mstride != 1)
408 throw std::runtime_error(
"A Tensor4View can only be converted to a plain C-array if it's pointing to a continuous block of data");
425 (mbr.mextent) * mbr.mstride,
432 mbr(0,1,a.mpr.mextent*a.mrr.mextent*a.mcr.mextent),
505 if ( ib != end_book ) {
510 for ( ; ib != end_book; ++ib ) {
529 const Range& c)
const 553 const Range& c)
const 565 const Range& c)
const 577 const Range& c)
const 613 const Range& c)
const 625 const Range& c)
const 649 const Range& c)
const 697 const Range& c)
const 1138 for ( ; b !=
eb ; ++b, ++xb )
1155 for ( ; b !=
eb ; ++b, ++xb )
1172 for ( ; b !=
eb ; ++b, ++xb )
1189 for ( ; b !=
eb ; ++b, ++xb )
1271 for ( ; origin !=
end ; ++origin, ++target )
1284 for ( ; target !=
end ; ++target )
1310 Range( 0, b, p*r*c ),
1321 Range( 0, b, p*r*c ),
1474 double (&my_func)(
double),
1486 for ( ; xi != xe; ++xi, ++yi )
1504 for ( ; xi != xe ; ++xi )
1509 if ( maxi > themax )
1526 for ( ; xi != xe ; ++xi )
1531 if ( mini < themin )
1561 return tv(b, p, r, c);
INDEX Index
The type to use for all integer numbers and indices.
Numeric debug_tensor4view_get_elem(Tensor4View &tv, Index b, Index p, Index r, Index c)
Helper function to access tensor elements.
Numeric min(const ConstTensor4View &x)
Min function, tensor version.
void copy(ConstIterator4D origin, const ConstIterator4D &end, Iterator4D target)
Copy data between begin and end to target.
Const version of Iterator4D.
Index mstart
The start index.
Tensor4View()
Default constructor.
Range mrr
The row range of mdata that is actually used.
Implementation of Tensors of Rank 4.
ConstIterator4D begin() const
Return const iterator to first book.
virtual ~Tensor4()
Destructor for Tensor4.
Tensor4View & operator+=(Numeric x)
Addition of scalar.
Index npages() const
Returns the number of pages.
Tensor4View & operator*=(Numeric x)
Multiplication by scalar.
void swap(Tensor4 &t1, Tensor4 &t2)
Swaps two objects.
Index nrows() const
Returns the number of rows.
A constant view of a Tensor4.
Tensor3View & operator*()
Dereferencing.
const ConstTensor3View & operator*() const
Dereferencing.
Range mpr
The page range of mdata that is actually used.
Tensor4 & operator=(Tensor4 x)
Assignment operator from another tensor.
Tensor4()
Default constructor.
std::ostream & operator<<(std::ostream &os, const ConstTensor4View &v)
Output operator.
ConstIterator3D end() const
Return const iterator behind last page.
Tensor4View & operator=(const ConstTensor4View &v)
Assignment operator.
The declarations of all the exception classes.
Range mbr
The book range of mdata that is actually used.
Numeric max(const ConstTensor4View &x)
Max function, tensor version.
NUMERIC Numeric
The type to use for all floating point numbers.
ConstTensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c) const
Const index operator for subrange.
Range mcr
The column range of mdata that is actually used.
Index mextent
The number of elements.
Tensor4View & operator/=(Numeric x)
Division by scalar.
Numeric * mdata
Pointer to the plain C array that holds the data.
ConstTensor4View()
Default constructor.
ConstIterator4D begin() const
Return const iterator to first book.
ConstIterator4D end() const
Return const iterator behind last book.
void transform(Tensor4View y, double(&my_func)(double), ConstTensor4View x)
A generic transform function for tensors, which can be used to implement mathematical functions opera...
ConstIterator4D end() const
Return const iterator behind last book.
friend void swap(Tensor4 &t1, Tensor4 &t2)
Swaps two objects.
ConstIterator3D begin() const
Return const iterator to first page.
A constant view of a Tensor3.
A constant view of a Vector.
Tensor4View & operator-=(Numeric x)
Subtraction of scalar.
A constant view of a Matrix.
ConstIterator3D begin() const
Return const iterator to first row.
Tensor3View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
Index nbooks() const
Returns the number of books.
ConstTensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c) const
Const index operator for subrange.
const ConstTensor3View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
Index ncols() const
Returns the number of columns.
void resize(Index b, Index p, Index r, Index c)
Resize function.
Tensor3View msv
Current position.
ConstIterator3D end() const
Return const iterator behind last row.
const Numeric * get_c_array() const
Conversion to plain C-array.