248 :
mstart(p.mstart + n.mstart * p.mstride),
250 mstride(p.mstride* n.mstride) {
258 Index const prev_fin = p.mstart + (p.mextent - 1) * p.mstride;
267 "Problem: mstride==",
392 for (
size_t i = 1; i <
N; i++) os <<
'x' << shape.data[i];
429 if (
mx != other.mx)
return true;
487 if (
mx != other.mx)
return true;
616 friend std::ostream& operator<<(std::ostream& os, const
ConstVectorView&
v);
679 using ConstVectorView::operator[];
694#define GETFUN(n) *(mdata + mrange.mstart + n * mrange.mstride)
830 msv.mdata += mstride;
836 if (msv.mdata + msv.mrange.mstart !=
837 other.msv.mdata + other.msv.mrange.mstart)
874 msv.mdata += mstride;
880 if (msv.mdata + msv.mrange.mstart !=
881 other.msv.mdata + other.msv.mrange.mstart)
916 Vector(std::initializer_list<Numeric> init);
954 Vector(
const std::vector<Numeric>&);
965 ARTS_ASSERT(r0.get_extent() >= 0,
"Must have size. Has: ", r0.get_extent());
1000 Vector& operator=(std::initializer_list<Numeric>
v);
1004 if (
const auto s = matpack::shape<Index, 1>(init); shape().data not_eq s) resize(s[0]);
1006 for (
Index i = 0; i < size(); i++)
1007 operator[](i) = init[i];
1037 void resize(
Index n);
1047 void transform_elementwise(F&& func) {
1048 std::transform(mdata, mdata + size(), mdata, func);
1078 [[nodiscard]]
Index selem() const noexcept {
return mrr.mstart + mcr.mstart; }
1079 [[nodiscard]]
Index nrows() const noexcept {
return mrr.mextent; }
1080 [[nodiscard]]
Index ncols() const noexcept {
return mcr.mextent; }
1081 [[nodiscard]]
Index drows() const noexcept {
return mrr.mstride; }
1082 [[nodiscard]]
Index dcols() const noexcept {
return mcr.mstride; }
1085 [[nodiscard]]
Index size() const noexcept {
return nrows() * ncols(); }
1086 [[nodiscard]]
bool empty() const noexcept {
return size() == 0; }
1105 return *(
mdata + mrr.mstart + r * mrr.mstride + mcr.mstart +
1154 friend std::ostream& operator<<(std::ostream& os, const
ConstMatrixView&
v);
1193 using ConstMatrixView::operator();
1201#define GETFUN(r, c) \
1202 *(mdata + mrr.mstart + r * mrr.mstride + mcr.mstart + c * mcr.mstride)
1314 ARTS_ASSERT(r0.get_extent() >= 0,
"Must have size. Has: ", r0.get_extent());
1315 ARTS_ASSERT(r1.get_extent() >= 0,
"Must have size. Has: ", r1.get_extent());
1326 if (
const auto s = matpack::shape<Index, 2>(init);
1327 shape().data not_eq s)
1330 auto [I, J] =
shape().data;
1331 for (
Index i = 0; i < I; i++)
1332 for (
Index j = 0; j < J; j++)
1333 operator()(i, j) = init(i, j);
1348 template <std::
size_t dim0>
1350 static_assert(dim0 < 2,
"Bad Dimension, Out-of-Bounds");
1352 Range r0(0, dim0 == 0 ? nrows() : ncols());
1356 "Can only reduce size on same size input. "
1357 "The sizes are (input v. output): ",
This file contains the definition of Array.
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
The row iterator class for sub matrices.
The ComplexMatrixView class.
The ComplexVectorView class.
The const row iterator class for sub matrices.
A constant view of a ComplexMatrix.
A constant view of a ComplexVector.
The constant iterator class for sub vectors.
bool operator!=(const ConstIterator1D &other) const ARTS_NOEXCEPT
Not equal operator, needed for algorithms like copy.
std::random_access_iterator_tag iterator_category
const Numeric * mx
Current position.
ConstIterator1D()=default
Default constructor.
const Numeric & reference
bool operator==(const ConstIterator1D &other) const ARTS_NOEXCEPT
ConstIterator1D & operator++() ARTS_NOEXCEPT
Prefix increment operator.
ConstIterator1D(const Numeric *x, Index stride) ARTS_NOEXCEPT
Explicit constructor.
const Numeric & operator*() const ARTS_NOEXCEPT
Dereferencing.
Index operator-(const ConstIterator1D &other) const ARTS_NOEXCEPT
friend void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
The const row iterator class for sub matrices.
const ConstVectorView & operator*() const ARTS_NOEXCEPT
Dereferencing.
ConstIterator2D(ConstVectorView x, Index stride) ARTS_NOEXCEPT
Explicit constructor.
ConstVectorView msv
Current position.
ConstIterator2D()=default
Default constructor.
const ConstVectorView * operator->() const ARTS_NOEXCEPT
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
bool operator!=(const ConstIterator2D &other) const ARTS_NOEXCEPT
Not equal operator, needed for algorithms like copy.
ConstIterator2D & operator++() ARTS_NOEXCEPT
Prefix increment operator.
Const version of Iterator3D.
Const version of Iterator4D.
Const version of Iterator5D.
Const version of Iterator6D.
Const version of Iterator7D.
A constant view of a Matrix.
Index drows() const noexcept
constexpr ConstMatrixView(ConstMatrixView &&)=default
ConstMatrixView & operator=(const ConstMatrixView &)=default
bool empty() const noexcept
Index dcols() const noexcept
ConstIterator2D begin() const ARTS_NOEXCEPT
Return const iterator to first row.
Index size() const noexcept
Index nrows() const noexcept
constexpr ConstMatrixView(const ConstMatrixView &)=default
ConstIterator2D end() const ARTS_NOEXCEPT
Return const iterator behind last row.
Index ncols() const noexcept
Numeric operator()(Index r, Index c) const ARTS_NOEXCEPT
Plain const index operator.
ConstMatrixView & operator=(ConstMatrixView &&)=default
ConstMatrixView()=default
Index selem() const noexcept
Numeric get(Index r, Index c) const ARTS_NOEXCEPT
Get element implementation without assertions.
A constant view of a Tensor3.
A constant view of a Tensor4.
A constant view of a Tensor5.
A constant view of a Tensor6.
A constant view of a Tensor7.
A constant view of a Vector.
Numeric get(Index n) const ARTS_NOEXCEPT
Get element implementation without assertions.
ConstIterator1D end() const ARTS_NOEXCEPT
Return const iterator behind last element.
ConstIterator1D begin() const ARTS_NOEXCEPT
Return const iterator to first element.
friend void lubacksub(VectorView, ConstMatrixView, ConstVectorView, const ArrayOfIndex &)
LU backsubstitution.
ConstVectorView()=default
Numeric * mdata
Pointer to the plain C array that holds the data.
Index delem() const noexcept
Steps in memory between elements.
friend int poly_root_solve(Matrix &roots, Vector &coeffs)
friend void mult_general(VectorView, const ConstMatrixView &, const ConstVectorView &) ARTS_NOEXCEPT
Matrix Vector multiplication.
Numeric sum() const ARTS_NOEXCEPT
The sum of all elements of a Vector.
Numeric operator[](Index n) const ARTS_NOEXCEPT
Plain const index operator.
constexpr ConstVectorView(ConstVectorView &&)=default
friend class ConstIterator2D
constexpr ConstVectorView(const ConstVectorView &)=default
friend void mult(VectorView, const ConstMatrixView &, const ConstVectorView &)
Matrix-Vector Multiplication.
static constexpr bool matpack_type
Index selem() const noexcept
Start element in memory.
Range mrange
The range of mdata that is actually used.
friend void transpose_mult(VectorView, const Sparse &, ConstVectorView)
Sparse matrix - Vector multiplication.
Numeric * get_c_array() const noexcept
Conversion to plain C-array, const-version.
Index nelem() const noexcept
Returns the number of elements.
friend class ConstMatrixView
friend void diagonalize(MatrixView, VectorView, VectorView, ConstMatrixView)
Matrix Diagonalization.
Index size() const noexcept
ConstVectorView & operator=(const ConstVectorView &)=default
ConstVectorView & operator=(ConstVectorView &&)=default
friend Numeric operator*(const ConstVectorView &a, const ConstVectorView &b) ARTS_NOEXCEPT
Scalar product.
bool empty() const noexcept
Returns true if variable size is zero.
The iterator class for sub vectors.
Iterator1D & operator++() ARTS_NOEXCEPT
Prefix increment operator.
bool operator==(const Iterator1D &other) const ARTS_NOEXCEPT
Index operator-(const Iterator1D &other) const ARTS_NOEXCEPT
Iterator1D()=default
Default constructor.
Numeric & operator*() const ARTS_NOEXCEPT
Dereferencing.
std::random_access_iterator_tag iterator_category
Numeric * mx
Current position.
friend void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
Copy data between begin and end to target.
bool operator!=(const Iterator1D &other) const ARTS_NOEXCEPT
Not equal operator, needed for algorithms like copy.
Iterator1D(Numeric *x, Index stride) ARTS_NOEXCEPT
Explicit constructor.
The row iterator class for sub matrices.
Iterator2D(const VectorView &x, Index stride) ARTS_NOEXCEPT
Explicit constructor.
VectorView & operator*() ARTS_NOEXCEPT
Dereferencing.
bool operator!=(const Iterator2D &other) const ARTS_NOEXCEPT
Not equal operator, needed for algorithms like copy.
Iterator2D()=default
Default constructor.
VectorView msv
Current position.
Iterator2D & operator++() ARTS_NOEXCEPT
Prefix increment operator.
VectorView * operator->() ARTS_NOEXCEPT
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Implementation of Tensors of Rank 3.
Implementation of Tensors of Rank 4.
Implementation of Tensors of Rank 5.
The outermost iterator class for rank 6 tensors.
Implementation of Tensors of Rank 7.
Numeric & operator()(Index r, Index c) ARTS_NOEXCEPT
Plain index operator.
Numeric & get(Index r, Index c) ARTS_NOEXCEPT
Get element implementation without assertions.
constexpr MatrixView(const MatrixView &)=default
Matrix(Matrix &&v) noexcept
Matrix & operator=(const matpack::matrix_like_not_matrix auto &init)
Set from a matrix type.
Numeric * get_raw_data() ARTS_NOEXCEPT
Matrix(const matpack::matrix_like_not_matrix auto &init)
Initialization from a vector type.
Matrix(Numeric *d, const Range &r0, const Range &r1) ARTS_NOEXCEPT
void transform_elementwise(F &&func)
constexpr void swap(Range &other) noexcept
constexpr Range(Index start, Joker, Index stride=1) ARTS_NOEXCEPT
Constructor with joker extent.
friend void mult_general(VectorView, const ConstMatrixView &, const ConstVectorView &) ARTS_NOEXCEPT
Matrix Vector multiplication.
constexpr Index operator()(const Index i) const ARTS_NOEXCEPT
friend constexpr void swap(Range &a, Range &b) noexcept
constexpr Range(const Range &p, const Range &n) ARTS_NOEXCEPT
Constructor of a new range relative to an old range.
constexpr Range(Index start, Index extent, Index stride=1) ARTS_NOEXCEPT
Explicit constructor.
Index mstart
The start index.
constexpr Index get_extent() const noexcept
Returns the extent of the range.
constexpr Range operator()(const Range r) const ARTS_NOEXCEPT
Range of range.
friend std::ostream & operator<<(std::ostream &os, const Range &r)
constexpr Index get_start() const noexcept
Returns the start index of the range.
Index mextent
The number of elements.
constexpr Range(Index max_size, const Range &r) ARTS_NOEXCEPT
Constructor which converts a range with joker to an explicit range.
constexpr Index get_stride() const noexcept
Returns the stride of the range.
constexpr Range(Joker, Index stride=1) noexcept
Constructor with just a joker.
Numeric & get(Index n) ARTS_NOEXCEPT
Get element implementation without assertions.
constexpr VectorView(const VectorView &)=default
VectorView & operator=(const ConstVectorView &v)
Assignment operator.
Numeric & operator[](Index n) ARTS_NOEXCEPT
Plain Index operator.
Iterator1D begin() ARTS_NOEXCEPT
Return iterator to first element.
Iterator1D end() ARTS_NOEXCEPT
Return iterator behind last element.
Vector(Numeric *d, const Range &r0) ARTS_NOEXCEPT
Vector(Vector &&v) noexcept
Vector & operator=(const matpack::vector_like_not_vector auto &init)
Set from a vector type.
Vector(const matpack::vector_like_not_vector auto &init)
Initialization from a vector type.
Binary output file stream class.
A concept precluding Arts matrix objects but allowing things similar to matrices.
A concept precluding Arts vector objects but allowing things similar to vectors.
#define ARTS_ASSERT(condition,...)
void ludcmp(Matrix &LU, ArrayOfIndex &indx, ConstMatrixView A)
LU decomposition.
void inv(MatrixView Ainv, ConstMatrixView A)
Matrix Inverse.
Numeric mean(const ConstVectorView &x) ARTS_NOEXCEPT
Mean function, vector version.
Numeric vector_angle(ConstVectorView a, ConstVectorView b)
Numeric nanmean(const ConstVectorView &x) ARTS_NOEXCEPT
Mean function, vector version ignoring nans and infs.
void proj(Vector &c, ConstVectorView a, ConstVectorView b) ARTS_NOEXCEPT
void transform(VectorView y, double(&my_func)(double), ConstVectorView x)
A generic transform function for vectors, which can be used to implement mathematical functions opera...
void cross3(VectorView c, const ConstVectorView &a, const ConstVectorView &b) ARTS_NOEXCEPT
cross3
void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
Numeric debug_matrixview_get_elem(MatrixView &mv, Index r, Index c)
Helper function to access matrix elements.
ConstMatrixView transpose(ConstMatrixView m) ARTS_NOEXCEPT
Const version of transpose.
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.
std::array< Index, N > data
friend std::ostream & operator<<(std::ostream &os, const Shape &shape)
bool operator<=>(const Shape &other) const =default