152 [[nodiscard]]
bool empty() const noexcept {
return size() == 0; }
226 return get(
b, p, r,
c);
301 using ConstTensor4View::operator();
342#define GETFUN(b, p, r, c) \
343 *(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart + p * mpr.mstride + \
344 mrr.mstart + r * mrr.mstride + mcr.mstart + c * mcr.mstride)
456 if (
const auto s = matpack::shape<Index, 4>(init);
shape().data not_eq s)
457 resize(s[0], s[1], s[2], s[3]);
459 auto [I, J, K, L] =
shape().data;
460 for (
Index i = 0; i < I; i++)
461 for (
Index j = 0; j < J; j++)
462 for (
Index k = 0; k < K; k++)
463 for (
Index x = 0; x < L; x++)
464 operator()(i, j, k, x) = init(i, j, k, x);
485 ARTS_ASSERT(not(r0.get_extent() < 0),
"Must have size");
486 ARTS_ASSERT(not(r1.get_extent() < 0),
"Must have size");
487 ARTS_ASSERT(not(r2.get_extent() < 0),
"Must have size");
488 ARTS_ASSERT(not(r3.get_extent() < 0),
"Must have size");
509 template <std::
size_t dim0>
511 static_assert(dim0 < 4,
"Bad Dimension, Out-of-Bounds");
516 : dim0 == 2 ?
nrows()
521 "Can only reduce size on same size input");
527 template <std::
size_t dim0, std::
size_t dim1>
529 static_assert(dim1 < 4,
"Bad Dimension, Out-of-Bounds");
530 static_assert(dim0 < dim1,
"Bad Dimensions, dim1 must be larger than dim0");
541 "Can only reduce size on same size input");
547 template <std::
size_t dim0, std::
size_t dim1, std::
size_t dim2>
549 static_assert(dim2 < 4,
"Bad Dimension, Out-of-Bounds");
550 static_assert(dim0 < dim1,
"Bad Dimensions, dim1 must be larger than dim0");
551 static_assert(dim1 < dim2,
"Bad Dimensions, dim2 must be larger than dim1");
560 "Can only reduce size on same size input");
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
This can be used to make arrays out of anything.
Const version of Iterator4D.
ConstIterator4D & operator++()
Prefix increment operator.
const ConstTensor3View & operator*() const
Dereferencing.
const ConstTensor3View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
ConstTensor3View msv
Current position.
ConstIterator4D()=default
Default constructor.
bool operator!=(const ConstIterator4D &other) const
Not equal operator, needed for algorithms like copy.
ConstIterator4D(ConstTensor3View x, Index stride)
Explicit constructor.
Const version of Iterator5D.
A constant view of a Matrix.
Index size() const noexcept
A constant view of a Tensor3.
Numeric * mdata
Pointer to the plain C array that holds the data.
Range mrr
The row range of mdata that is actually used.
Range mcr
The column range of mdata that is actually used.
Index size() const noexcept
Range mpr
The page range of mdata that is actually used.
A constant view of a Tensor4.
static constexpr bool matpack_type
Index ncols() const noexcept
Range mrr
The row range of mdata that is actually used.
ConstTensor4View()=default
ConstTensor4View & operator=(const ConstTensor4View &)=default
Range mbr
The book range of mdata that is actually used.
ConstTensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c) const
Const index operator for subrange.
virtual ~ConstTensor4View()=default
Destructor.
Index size() const noexcept
bool empty() const noexcept
constexpr ConstTensor4View(const ConstTensor4View &)=default
Range mcr
The column range of mdata that is actually used.
Numeric * mdata
Pointer to the plain C array that holds the data.
constexpr ConstTensor4View(ConstTensor4View &&)=default
Range mpr
The page range of mdata that is actually used.
friend std::ostream & operator<<(std::ostream &os, const ConstTensor4View &v)
Output operator.
ConstTensor4View & operator=(ConstTensor4View &&)=default
Numeric get(Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
ConstIterator4D end() const
Return const iterator behind last book.
ConstIterator4D begin() const
Return const iterator to first book.
Index nrows() const noexcept
Index nbooks() const noexcept
Numeric operator()(Index b, Index p, Index r, Index c) const
Plain const index operator.
Index npages() const noexcept
A constant view of a Tensor5.
A constant view of a Tensor6.
A constant view of a Tensor7.
A constant view of a Vector.
Index size() const noexcept
Implementation of Tensors of Rank 4.
Iterator4D & operator++()
Prefix increment operator.
Tensor3View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
Iterator4D()=default
Default constructor.
bool operator!=(const Iterator4D &other) const
Not equal operator, needed for algorithms like copy.
Tensor3View & operator*()
Dereferencing.
Tensor3View msv
Current position.
Iterator4D(const Tensor3View &x, Index stride)
Explicit constructor.
Implementation of Tensors of Rank 5.
Index mstart
The start index.
constexpr Index get_extent() const noexcept
Returns the extent of the range.
Index mextent
The number of elements.
constexpr Tensor4View(const Tensor4View &)=default
Iterator4D begin()
Return iterator to first book.
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Numeric & get(Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Tensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c)
Index operator for subrange.
Tensor4View & operator=(const ConstTensor4View &v)
Assignment operator.
Iterator4D end()
Return iterator behind last book.
Numeric & operator()(Index b, Index p, Index r, Index c)
Plain non-const index operator.
Tensor4 & operator=(const matpack::tensor4_like_not_tensor4 auto &init)
Set from a tensor type.
Matrix reduce_rank() &&ARTS_NOEXCEPT
Tensor4(Tensor4 &&v) noexcept
Tensor4(Numeric *d, const Range &r0, const Range &r1, const Range &r2, const Range &r3) ARTS_NOEXCEPT
Tensor3 reduce_rank() &&ARTS_NOEXCEPT
Tensor4(const matpack::tensor4_like_not_tensor4 auto &init)
Initialization from a tensor type.
void transform_elementwise(F &&func)
A concept precluding Arts types but allowing the tensor-like object.
#define ARTS_ASSERT(condition,...)
void copy(ConstIterator4D origin, const ConstIterator4D &end, Iterator4D target)
Copy data between begin and end to target.
Numeric debug_tensor4view_get_elem(Tensor4View &tv, Index b, Index p, Index r, Index c)
Helper function to access tensor elements.
#define GETFUN(b, p, r, c)
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...
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
void swap(ComplexVector &v1, ComplexVector &v2) noexcept
Swaps two objects.