Go to the documentation of this file.
32 using std::runtime_error;
58 for (; i != e; ++i) s += *i;
90 : mrange(0, 1), mdata(&const_cast<
Numeric&>(a)) {
95 : mrange(range), mdata(
data) {
100 : mrange(p, n), mdata(
data) {
115 for (; i !=
end; ++i) {
116 os <<
" " << setw(3) << *i;
127 "Creating a VectorView from a const Vector is not allowed.");
216 assert(
nelem() ==
x.nelem());
223 for (; i != e; ++i, ++s) *i *= *s;
228 assert(
nelem() ==
x.nelem());
235 for (; i != e; ++i, ++s) *i /= *s;
240 assert(
nelem() ==
x.nelem());
247 for (; i != e; ++i, ++s) *i += *s;
252 assert(
nelem() ==
x.nelem());
259 for (; i != e; ++i, ++s) *i -= *s;
274 throw std::runtime_error(
275 "A VectorView can only be converted to a plain C-array if it's pointing to a continuous block of data");
282 throw std::runtime_error(
283 "A VectorView can only be converted to a plain C-array if it's pointing to a continuous block of data");
306 memcpy((
void*)target.
mx,
310 for (; origin !=
end; ++origin, ++target) *target = *origin;
314 for (; target !=
end; ++target) *target =
x;
333 std::fill_n(
mdata, n, fill);
342 for (; i != e; ++i) {
360 std::vector<Numeric>::const_iterator vec_it_end = v.
end();
362 for (std::vector<Numeric>::const_iterator vec_it = v.begin();
363 vec_it != vec_it_end;
387 v.mrange =
Range(0, 0);
438 const Range& c)
const {
501 : mrr(rr), mcr(cr), mdata(
data) {
524 : mrr(pr, nr), mcr(pc, nc), mdata(
data) {
545 os << setw(3) << *ic;
548 for (; ic != end_col; ++ic) {
549 os <<
" " << setw(3) << *ic;
553 for (; ir != end_row; ++ir) {
559 os << setw(3) << *ic;
562 for (; ic != end_col; ++ic) {
563 os <<
" " << setw(3) << *ic;
694 for (
Iterator1D c = r->begin(); c != ec; ++c) *c *=
x;
704 for (
Iterator1D c = r->begin(); c != ec; ++c) *c /=
x;
714 for (
Iterator1D c = r->begin(); c != ec; ++c) *c +=
x;
724 for (
Iterator1D c = r->begin(); c != ec; ++c) *c -=
x;
738 throw std::runtime_error(
739 "A MatrixView can only be converted to a plain C-array if it's pointing to a continuous block of data");
753 throw std::runtime_error(
754 "A MatrixView can only be converted to a plain C-array if it's pointing to a continuous block of data");
761 assert(
nrows() ==
x.nrows());
762 assert(
ncols() ==
x.ncols());
766 for (; r != er; ++r, ++sr) {
770 for (; c != ec; ++c, ++sc) *c *= *sc;
777 assert(
nrows() ==
x.nrows());
778 assert(
ncols() ==
x.ncols());
782 for (; r != er; ++r, ++sr) {
786 for (; c != ec; ++c, ++sc) *c /= *sc;
793 assert(
nrows() ==
x.nrows());
794 assert(
ncols() ==
x.ncols());
798 for (; r != er; ++r, ++sr) {
802 for (; c != ec; ++c, ++sc) *c += *sc;
809 assert(
nrows() ==
x.nrows());
810 assert(
ncols() ==
x.ncols());
814 for (; r != er; ++r, ++sr) {
818 for (; c != ec; ++c, ++sc) *c -= *sc;
825 assert(
nrows() ==
x.nelem());
826 assert(
ncols() == 1);
830 for (; r != er; ++r, ++sc) {
839 assert(
nrows() ==
x.nelem());
840 assert(
ncols() == 1);
844 for (; r != er; ++r, ++sc) {
853 assert(
nrows() ==
x.nelem());
854 assert(
ncols() == 1);
858 for (; r != er; ++r, ++sc) {
867 assert(
nrows() ==
x.nelem());
868 assert(
ncols() == 1);
872 for (; r != er; ++r, ++sc) {
922 for (; origin !=
end; ++origin, ++target) {
926 for (; o != e; ++o, ++t) *t = *o;
932 for (; target !=
end; ++target) {
935 for (; t != e; ++t) *t =
x;
954 std::fill_n(
mdata, r * c, fill);
1049 copy(dummy.begin(), dummy.end(),
begin());
1101 for (; ai != ae; ++ai, ++bi) res += (*ai) * (*bi);
1124 assert(
y.mrange.get_extent() ==
M.mrr.get_extent());
1125 assert(
M.mcr.get_extent() ==
x.mrange.get_extent());
1126 assert((
M.mcr.get_extent() != 0) && (
M.mrr.get_extent() != 0));
1128 if ((
M.mcr.get_stride() == 1) || (
M.mrr.get_stride() == 1)) {
1133 int LDA, incx, incy;
1135 if (
M.mcr.get_stride() != 1) {
1137 m = (int)
M.mrr.get_extent();
1138 n = (int)
M.mcr.get_extent();
1139 LDA = (int)
M.mcr.get_stride();
1142 m = (int)
M.mcr.get_extent();
1143 n = (int)
M.mrr.get_extent();
1144 LDA = (int)
M.mrr.get_stride();
1145 if (
M.mrr.get_stride() == 1) LDA = m;
1148 incx = (int)
x.mrange.get_stride();
1149 incy = (int)
y.mrange.get_stride();
1151 double* mstart =
M.mdata +
M.mcr.get_start() +
M.mrr.get_start();
1152 double* ystart =
y.mdata +
y.mrange.get_start();
1153 double* xstart =
x.mdata +
x.mrange.get_start();
1185 assert(
y.mrange.mextent ==
M.mrr.mextent);
1186 assert(
M.mcr.mextent ==
x.mrange.mextent);
1187 assert(
M.mcr.mextent != 0 &&
M.mrr.mextent != 0);
1190 Numeric* mdata =
M.mdata +
M.mcr.mstart +
M.mrr.mstart;
1191 Numeric* xdata =
x.mdata +
x.mrange.mstart;
1192 Numeric* yelem =
y.mdata +
y.mrange.mstart;
1202 *yelem = *melem * *xelem;
1207 melem +=
M.mcr.mstride;
1208 xelem +=
x.mrange.mstride;
1209 *yelem += *melem * *xelem;
1212 mdata +=
M.mrr.mstride;
1213 yelem +=
y.mrange.mstride;
1274 char transa, transb;
1316 double alpha = 1.0,
beta = 0.0;
1363 for (; ai != ae; ++ai, ++bi) {
1371 for (; aci != ace; ++aci, ++cti) {
1374 *aci = (*bi) * (*cti);
1394 assert(a.
nelem() == 3);
1395 assert(b.
nelem() == 3);
1396 assert(c.
nelem() == 3);
1398 c[0] = a[1] * b[2] - a[2] * b[1];
1399 c[1] = a[2] * b[0] - a[0] * b[2];
1400 c[2] = a[0] * b[1] - a[1] * b[0];
1418 return fabs(arg) > 1. ? 0. : acos(arg) *
RAD2DEG;
1438 const Numeric C = (a * b) / (a * a);
1478 assert(
y.nelem() ==
x.nelem());
1483 for (; xi != xe; ++xi, ++yi) *yi = my_func(*xi);
1506 assert(
y.nrows() ==
x.nrows());
1507 assert(
y.ncols() ==
x.ncols());
1512 for (; rx != rxe; ++rx, ++ry) {
1516 for (; cx != cxe; ++cx, ++cy) *cy = my_func(*cx);
1528 for (; xi != xe; ++xi) {
1529 if (*xi >
max)
max = *xi;
1543 for (; rx != rxe; ++rx) {
1547 for (; cx != cxe; ++cx)
1548 if (*cx >
max)
max = *cx;
1562 for (; xi != xe; ++xi) {
1563 if (*xi <
min)
min = *xi;
1577 for (; rx != rxe; ++rx) {
1581 for (; cx != cxe; ++cx)
1582 if (*cx <
min)
min = *cx;
1596 for (; xi != xe; ++xi)
mean += *xi;
1611 for (; rx != rxe; ++rx) {
1615 for (; cx != cxe; ++cx)
mean += *cx;
1644 for (; i != e; ++i, ++target) *target = *i;
ConstMatrixView()=default
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...
Numeric * mx
Current position.
The declarations of all the exception classes.
Eigen::Map< const MatrixType, 0, StrideType > ConstMatrixViewMap
Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > StrideType
MatrixView & operator=(const ConstMatrixView &v)
Assignment operator.
The constant iterator class for sub vectors.
const Numeric RAD2DEG
Global constant, conversion from radians to degrees.
Eigen::Map< Matrix4x4Type, 0, StrideType > Matrix4x4ViewMap
void proj(Vector &c, ConstVectorView a, ConstVectorView b)
Numeric * mdata
Pointer to the plain C array that holds the data.
Vector y(Workspace &ws) noexcept
void resize(Index n)
Resize function.
Numeric max(const ConstVectorView &x)
Max function, vector version.
MatrixView & operator+=(Numeric x)
Addition of scalar.
ConstMatrixViewMap MapToEigen(const ConstMatrixView &A)
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Index nrows() const
Returns the number of rows.
Range mrange
The range of mdata that is actually used.
Index mstart
The start index.
MatrixView & operator-=(Numeric x)
Subtraction of scalar.
MatrixView & operator/=(Numeric x)
Division by scalar.
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.
Range mcr
The column range of mdata that is actually used.
VectorView & operator=(const ConstVectorView &v)
Assignment operator.
VectorView operator/=(Numeric x)
Division by scalar.
Numeric sqrt(const Rational r)
Square root.
Range mrr
The row range of mdata that is actually used.
constexpr Index get_start() const
Returns the start index of the range.
void cross3(VectorView c, const ConstVectorView &a, const ConstVectorView &b)
cross3
Implementation of Matrix, Vector, and such stuff.
Workspace & init(Workspace &ws)
This can be used to make arrays out of anything.
std::ostream & operator<<(std::ostream &os, const Range &r)
Index nelem(const Lines &l)
Number of lines.
ConstIterator1D end() const
Return const iterator behind last element.
ConstIterator2D end() const
Return const iterator behind last row.
Matrix4x4ViewMap MapToEigen4x4(MatrixView &A)
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix-Vector Multiplication.
virtual ~Matrix()
Destructor for Matrix.
Vector & operator=(const Vector &v)
Assignment from another Vector.
Index ncols() const
Returns the number of columns.
The iterator class for sub vectors.
Index nelem() const
Returns the number of elements.
virtual ~Vector()
Destructor for Vector.
Numeric mean(const ConstVectorView &x)
Mean function, vector version.
ConstIterator1D begin() const
Return const iterator to first element.
Numeric sum() const
The sum of all elements of a Vector.
Iterator2D begin()
** Return const iterator to first row. Has to be redefined here, since it is
NUMERIC Numeric
The type to use for all floating point numbers.
ConstVectorView()=default
ConstMatrixView transpose(ConstMatrixView m)
Const version of transpose.
Numeric & operator()(Index r, Index c)
Plain index operator.
Numeric * mdata
Pointer to the plain C array that holds the data.
Numeric operator[](Index n) const
Plain const index operator.
Numeric operator()(Index r, Index c) const
Plain const index operator.
void resize(Index r, Index c)
Resize function.
ConstVectorView diagonal() const
Matrix diagonal as vector.
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
The const row iterator class for sub matrices.
bool empty() const
Returns true if variable size is zero.
A constant view of a Matrix.
constexpr Index get_extent() const
Returns the extent of the range.
void mult_general(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication.
Interface for BLAS library.
Index nrows(Workspace &ws) noexcept
Eigen::Map< const Matrix4x4Type, 0, StrideType > ConstMatrix4x4ViewMap
constexpr Index get_stride() const
Returns the stride of the range.
Numeric min(const ConstVectorView &x)
Min function, vector version.
Index mextent
The number of elements.
Eigen::Map< MatrixType, 0, StrideType > MatrixViewMap
VectorView operator*=(Numeric x)
Multiplication by scalar.
Numeric & operator[](Index n)
Plain Index operator.
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
VectorView operator-=(Numeric x)
Subtraction of scalar.
void swap(Vector &v1, Vector &v2)
Iterator1D end()
Return iterator behind last element.
bool empty() const
Returns true if variable size is zero.
Numeric vector_angle(ConstVectorView a, ConstVectorView b)
ConstIterator2D begin() const
Return const iterator to first row.
Iterator1D begin()
Return iterator to first element.
Matrix & operator=(const Matrix &x)
Assignment operator from another matrix.
Iterator2D end()
Return iterator behind last row.
The row iterator class for sub matrices.
Vector x(Workspace &ws) noexcept
Numeric operator*(const ConstVectorView &a, const ConstVectorView &b)
Scalar product.
INDEX Index
The type to use for all integer numbers and indices.
Numeric debug_matrixview_get_elem(MatrixView &mv, Index r, Index c)
Helper function to access matrix elements.
ConstMatrixViewMap MapToEigenCol(const ConstVectorView &A)
MatrixView & operator*=(Numeric x)
Multiplication by scalar.
const Numeric * get_c_array() const
Conversion to plain C-array.
Index ncols(Workspace &ws) noexcept
friend class ConstVectorView
void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
A constant view of a Vector.
VectorView operator+=(Numeric x)
Addition of scalar.
Index nelem() const
Number of elements.
const Numeric * mx
Current position.
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.
const Numeric * get_c_array() const
Conversion to plain C-array, const-version.
ConstMatrixViewMap MapToEigenRow(const ConstVectorView &A)