53 for (; i != e; ++i) s += *i;
116 for (; i != end; ++i) {
117 os <<
" " << setw(3) << *i;
128 "Creating a VectorView from a const Vector is not allowed.\n"
129 "This is not really a runtime error, but I don't want to start\n"
130 "producing direct output from inside matpack. And just exiting is\n"
132 "If you see this error, there is a bug in the code, not in the\n"
193 for (
Iterator1D i = begin(); i != e; ++i) *i *= x;
199 for (
Iterator1D i = begin(); i != e; ++i) *i /= x;
205 for (
Iterator1D i = begin(); i != e; ++i) *i += x;
211 for (
Iterator1D i = begin(); i != e; ++i) *i -= x;
223 for (; i != e; ++i, ++s) *i *= *s;
235 for (; i != e; ++i, ++s) *i /= *s;
247 for (; i != e; ++i, ++s) *i += *s;
259 for (; i != e; ++i, ++s) *i -= *s;
292 memcpy((
void*)target.
mx,
296 for (; origin != end; ++origin, ++target) *target = *origin;
300 for (; target != end; ++target) *target = x;
308 std::copy(init.begin(), init.end(),
begin());
319 std::fill_n(
mdata, n, fill);
328 for (; i != e; ++i) {
346 auto vec_it_end =
v.end();
348 for (
auto vec_it =
v.begin();
349 vec_it != vec_it_end;
356 std::copy(
v.begin(),
v.end(),
begin());
403 swap(v1.mrange, v2.mrange);
404 swap(v1.mdata, v2.mdata);
527 os << setw(3) << *ic;
530 for (; ic != end_col; ++ic) {
531 os <<
" " << setw(3) << *ic;
535 for (; ir != end_row; ++ir) {
541 os << setw(3) << *ic;
544 for (; ic != end_col; ++ic) {
545 os <<
" " << setw(3) << *ic;
572 return VectorView(mdata + mcr.mstart +
c * mcr.mstride, mrr, r);
584 return VectorView(mdata + mrr.mstart + r * mrr.mstride, mcr,
c);
719 for (; r != er; ++r, ++sr) {
723 for (;
c != ec; ++
c, ++sc) *
c *= *sc;
735 for (; r != er; ++r, ++sr) {
739 for (;
c != ec; ++
c, ++sc) *
c /= *sc;
751 for (; r != er; ++r, ++sr) {
755 for (;
c != ec; ++
c, ++sc) *
c += *sc;
767 for (; r != er; ++r, ++sr) {
771 for (;
c != ec; ++
c, ++sc) *
c -= *sc;
783 for (; r != er; ++r, ++sc) {
797 for (; r != er; ++r, ++sc) {
811 for (; r != er; ++r, ++sc) {
825 for (; r != er; ++r, ++sc) {
877 for (; origin != end; ++origin, ++target) {
881 for (; o != e; ++o, ++t) *t = *o;
887 for (; target != end; ++target) {
890 for (; t != e; ++t) *t = x;
909 std::fill_n(
mdata, r *
c, fill);
916 Range(0, m.nrows(), m.ncols()),
917 Range(0, m.ncols())) {
925 Range(0, m.nrows(), m.ncols()),
926 Range(0, m.ncols())) {
1032 swap(m1.mrr, m2.mrr);
1033 swap(m1.mcr, m2.mcr);
1034 swap(m1.mdata, m2.mdata);
1058 for (; ai != ae; ++ai, ++bi) res += (*ai) * (*bi);
1083 ARTS_ASSERT((
M.mcr.get_extent() != 0) && (
M.mrr.get_extent() != 0));
1085 if ((
M.mcr.get_stride() == 1) || (
M.mrr.get_stride() == 1)) {
1090 int LDA, incx, incy;
1092 if (
M.mcr.get_stride() != 1) {
1094 m = (int)
M.mrr.get_extent();
1095 n = (int)
M.mcr.get_extent();
1096 LDA = (int)
M.mcr.get_stride();
1099 m = (int)
M.mcr.get_extent();
1100 n = (int)
M.mrr.get_extent();
1101 LDA = (int)
M.mrr.get_stride();
1102 if (
M.mrr.get_stride() == 1) LDA = m;
1108 double* mstart =
M.mdata +
M.mcr.get_start() +
M.mrr.get_start();
1147 Numeric* mdata =
M.mdata +
M.mcr.mstart +
M.mrr.mstart;
1148 Numeric* xdata = x.mdata + x.mrange.mstart;
1149 Numeric* yelem = y.mdata + y.mrange.mstart;
1159 *yelem = *melem * *xelem;
1164 melem +=
M.mcr.mstride;
1165 xelem += x.mrange.mstride;
1166 *yelem += *melem * *xelem;
1169 mdata +=
M.mrr.mstride;
1170 yelem += y.mrange.mstride;
1231 char transa, transb;
1273 double alpha = 1.0, beta = 0.0;
1320 for (; ai != ae; ++ai, ++bi) {
1328 for (; aci != ace; ++aci, ++cti) {
1331 *aci = (*bi) * (*cti);
1357 c[0] =
a[1] *
b[2] -
a[2] *
b[1];
1358 c[1] =
a[2] *
b[0] -
a[0] *
b[2];
1359 c[2] =
a[0] *
b[1] -
a[1] *
b[0];
1377 return fabs(arg) > 1. ? 0. : acos(arg) *
RAD2DEG;
1440 for (; xi != xe; ++xi, ++yi) *yi = my_func(*xi);
1469 for (; rx != rxe; ++rx, ++ry) {
1473 for (; cx != cxe; ++cx, ++cy) *cy = my_func(*cx);
1485 for (; xi != xe; ++xi) {
1486 if (*xi >
max)
max = *xi;
1500 for (; rx != rxe; ++rx) {
1504 for (; cx != cxe; ++cx)
1505 if (*cx >
max)
max = *cx;
1519 for (; xi != xe; ++xi) {
1520 if (*xi <
min)
min = *xi;
1534 for (; rx != rxe; ++rx) {
1538 for (; cx != cxe; ++cx)
1539 if (*cx <
min)
min = *cx;
1553 for (; xi != xe; ++xi)
mean += *xi;
1566 Index numnormal = 0;
1571 for (; xi != xe; ++xi)
1572 if (std::isnormal(*xi) or (*xi == 0)) {
1580 nanmean = std::numeric_limits<Numeric>::quiet_NaN();
1593 for (; rx != rxe; ++rx) {
1597 for (; cx != cxe; ++cx)
mean += *cx;
1622 const auto e =
v.end();
1626 for (; i != e; ++i, ++target) *target = *i;
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
Interface for BLAS library.
void dgemv_(char *trans, int *m, int *n, double *alpha, double *A, int *LDA, double *x, int *incx, double *beta, double *y, int *incy)
Matrix-Vector Multiplication.
void dgemm_(char *transa, char *transb, int *m, int *n, int *k, double *alpha, double *A, int *lda, double *B, int *ldb, double *beta, double *C, int *ldc)
BLAS matrix multiplication.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
The constant iterator class for sub vectors.
const Numeric * mx
Current position.
The const row iterator class for sub matrices.
A constant view of a Matrix.
Range mrr
The row range of mdata that is actually used.
friend class ConstVectorView
ConstIterator2D begin() const ARTS_NOEXCEPT
Return const iterator to first row.
Index nrows() const noexcept
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.
Numeric * mdata
Pointer to the plain C array that holds the data.
Range mcr
The column range of mdata that is actually used.
ConstVectorView diagonal() const ARTS_NOEXCEPT
Matrix diagonal as vector.
ConstMatrixView()=default
A constant view of a Vector.
ConstIterator1D end() const ARTS_NOEXCEPT
Return const iterator behind last element.
ConstIterator1D begin() const ARTS_NOEXCEPT
Return const iterator to first element.
ConstVectorView()=default
Numeric * mdata
Pointer to the plain C array that holds the data.
Numeric sum() const ARTS_NOEXCEPT
The sum of all elements of a Vector.
Numeric operator[](Index n) const ARTS_NOEXCEPT
Plain const index operator.
Range mrange
The range of mdata that is actually used.
Index nelem() const noexcept
Returns the number of elements.
The iterator class for sub vectors.
Numeric * mx
Current position.
The row iterator class for sub matrices.
MatrixView & operator=(const ConstMatrixView &m)
Assignment operator.
MatrixView & operator/=(Numeric x) ARTS_NOEXCEPT
Division by scalar.
Numeric & operator()(Index r, Index c) ARTS_NOEXCEPT
Plain index operator.
Iterator2D end() ARTS_NOEXCEPT
Return iterator behind last row.
MatrixView & operator+=(Numeric x) ARTS_NOEXCEPT
Addition of scalar.
Iterator2D begin() ARTS_NOEXCEPT
** Return const iterator to first row. Has to be redefined here, since it is
MatrixView & operator*=(Numeric x) ARTS_NOEXCEPT
Multiplication by scalar.
MatrixView & operator-=(Numeric x) ARTS_NOEXCEPT
Subtraction of scalar.
void resize(Index r, Index c)
Resize function.
~Matrix() noexcept override
Destructor for Matrix.
Matrix & operator=(const Matrix &m)
Assignment operator from another matrix.
Index mstart
The start index.
constexpr Index get_extent() const noexcept
Returns the extent of the range.
constexpr Index get_start() const noexcept
Returns the start index of the range.
Index mextent
The number of elements.
constexpr Index get_stride() const noexcept
Returns the stride of the range.
VectorView operator+=(Numeric x) ARTS_NOEXCEPT
Addition of scalar.
VectorView operator-=(Numeric x) ARTS_NOEXCEPT
Subtraction of scalar.
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.
VectorView operator*=(Numeric x) ARTS_NOEXCEPT
Multiplication by scalar.
Iterator1D end() ARTS_NOEXCEPT
Return iterator behind last element.
VectorView operator/=(Numeric x) ARTS_NOEXCEPT
Division by scalar.
void resize(Index n)
Resize function.
~Vector() noexcept override
Destructor for Vector.
Vector & operator=(const Vector &v)
Assignment from another Vector.
#define ARTS_ASSERT(condition,...)
constexpr Numeric RAD2DEG
The declarations of all the exception classes.
Numeric mean(const ConstVectorView &x) ARTS_NOEXCEPT
Mean function, vector version.
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix-Vector Multiplication.
void swap(Vector &v1, Vector &v2) noexcept
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 mult_general(VectorView y, const ConstMatrixView &M, const ConstVectorView &x) ARTS_NOEXCEPT
Matrix Vector multiplication.
std::ostream & operator<<(std::ostream &os, const Range &r)
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.
Numeric operator*(const ConstVectorView &a, const ConstVectorView &b) ARTS_NOEXCEPT
Scalar product.
ConstMatrixView transpose(ConstMatrixView m) ARTS_NOEXCEPT
Const version of transpose.
Implementation of Matrix, Vector, and such stuff.
void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
constexpr Numeric alpha
Fine structure constant convenience name [-].
Numeric sqrt(const Rational r)
Square root.