Go to the documentation of this file.
31 using std::runtime_error;
53 mstart(start), mextent(extent), mstride(stride)
69 mstart(start), mextent(-1), mstride(stride)
79 mstart(0), mextent(-1), mstride(stride)
116 assert( fin < max_size );
127 mstart(p.mstart + n.mstart*p.mstride),
129 mstride(p.mstride*n.mstride)
143 assert(
mstart<=prev_fin );
161 assert( p.
mstart <= fin );
162 assert( fin <= prev_fin );
240 mrange(0,1), mdata(&const_cast<
Numeric&>(a))
248 mrange(0,0), mdata(NULL)
256 const Range& range) :
295 for ( ; i!=end ; ++i )
297 os <<
" " << setw(3) << *i;
311 throw runtime_error(
"Creating a VectorView from a const Vector is not allowed.");
475 for ( ; i!=e ; ++i,++s )
490 for ( ; i!=e ; ++i,++s )
505 for ( ; i!=e ; ++i,++s )
520 for ( ; i!=e ; ++i,++s )
545 throw std::runtime_error(
"A VectorView can only be converted to a plain C-array if it's pointing to a continuous block of data");
559 throw std::runtime_error(
"A VectorView can only be converted to a plain C-array if it's pointing to a continuous block of data");
584 const Range& range) :
617 memcpy((
void *)target.
mx,
621 for ( ; origin!=end ; ++origin,++target )
630 for ( ; target!=end ; ++target )
713 std::vector<Numeric>::const_iterator vec_it_end = v.
end();
715 for (std::vector<Numeric>::const_iterator vec_it = v.begin();
716 vec_it != vec_it_end;
847 const Range& c)
const
901 mrr(0,0,1), mcr(0,0,1), mdata(NULL)
963 os << setw(3) << *ic;
966 for ( ; ic!=end_col ; ++ic )
968 os <<
" " << setw(3) << *ic;
972 for ( ; ir!=end_row ; ++ir )
980 os << setw(3) << *ic;
983 for ( ; ic!=end_col ; ++ic )
985 os <<
" " << setw(3) << *ic;
1163 for (
Iterator1D c = r->begin(); c!=ec ; ++c )
1176 for (
Iterator1D c = r->begin(); c!=ec ; ++c )
1189 for (
Iterator1D c = r->begin(); c!=ec ; ++c )
1202 for (
Iterator1D c = r->begin(); c!=ec ; ++c )
1218 throw std::runtime_error(
"A MatrixView can only be converted to a plain C-array if it's pointing to a continuous block of data");
1233 throw std::runtime_error(
"A MatrixView can only be converted to a plain C-array if it's pointing to a continuous block of data");
1246 for ( ; r!=er ; ++r,++sr )
1251 for ( ; c!=ec ; ++c,++sc )
1265 for ( ; r!=er ; ++r,++sr )
1270 for ( ; c!=ec ; ++c,++sc )
1284 for ( ; r!=er ; ++r,++sr )
1289 for ( ; c!=ec ; ++c,++sc )
1303 for ( ; r!=er ; ++r,++sr )
1308 for ( ; c!=ec ; ++c,++sc )
1322 for ( ; r!=er ; ++r,++sc )
1338 for ( ; r!=er ; ++r,++sc )
1354 for ( ; r!=er ; ++r,++sc )
1370 for ( ; r!=er ; ++r,++sc )
1432 for ( ; origin!=end ; ++origin,++target )
1437 for ( ; o!=e ; ++o,++t )
1447 for ( ; target!=end ; ++target )
1451 for ( ; t!=e ; ++t )
1497 Range( 0, m.nrows(), m.ncols() ),
1498 Range( 0, m.ncols() ) )
1507 Range( 0, m.nrows(), m.ncols() ),
1508 Range( 0, m.ncols() ) )
1633 for ( ; ai!=ae ; ++ai, ++bi )
1634 res += (*ai) * (*bi);
1655 assert(
M.mcr.mextent != 0 &&
M.mrr.mextent != 0);
1658 Numeric *mdata =
M.mdata +
M.mcr.mstart +
M.mrr.mstart;
1671 *yelem = *melem * *xelem;
1676 melem +=
M.mcr.mstride;
1678 *yelem += *melem * *xelem;
1681 mdata +=
M.mrr.mstride;
1699 assert( A.
ncols() ==
C.ncols() );
1700 assert( B.
ncols() ==
C.nrows() );
1711 for ( ; ai!=ae ; ++ai, ++bi )
1720 for ( ; aci!=ace ; ++aci, ++cti )
1724 *aci = (*bi) * (*cti);
1745 assert( a.
nelem() == 3 );
1746 assert( b.
nelem() == 3 );
1747 assert( c.
nelem() == 3 );
1749 c[0] = a[1]*b[2] - a[2]*b[1];
1750 c[1] = a[2]*b[0] - a[0]*b[2];
1751 c[2] = a[0]*b[1] - a[1]*b[0];
1766 Numeric arg = (a*b) / sqrt(a*a) / sqrt(b*b);
1770 return fabs(arg) > 1. ? 0. : acos(arg) *
RAD2DEG;
1839 double (&my_func)(
double),
1848 for ( ; xi!=xe; ++xi, ++yi )
1871 double (&my_func)(
double),
1881 for ( ; rx!=rxe; ++rx, ++ry )
1886 for ( ; cx!=cxe; ++cx, ++cy )
1900 for ( ; xi!=xe ; ++xi )
1918 for ( ; rx!=rxe ; ++rx )
1923 for ( ; cx!=cxe ; ++cx )
1940 for ( ; xi!=xe ; ++xi )
1958 for ( ; rx!=rxe ; ++rx )
1963 for ( ; cx!=cxe ; ++cx )
1980 for ( ; xi!=xe ; ++xi )
mean += *xi;
1996 for ( ; rx!=rxe ; ++rx )
2001 for ( ; cx!=cxe ; ++cx )
mean += *cx;
2031 for ( ; i!=e ; ++i,++target )
Numeric operator()(Index r, Index c) const
Plain const index operator.
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.
Matrix & operator=(Matrix x)
Assignment operator from another matrix.
VectorView()
Default constructor.
The declarations of all the exception classes.
MatrixView & operator=(const ConstMatrixView &v)
Assignment operator.
Vector()
Default constructor.
The constant iterator class for sub vectors.
MatrixView()
Default constructor.
const Numeric RAD2DEG
Global constant, conversion from radians to degrees.
void proj(Vector &c, ConstVectorView a, ConstVectorView b)
Vector & operator=(Vector v)
Assignment from another Vector.
Numeric * mdata
Pointer to the plain C array that holds the data.
void resize(Index n)
Resize function.
Numeric max(const ConstVectorView &x)
Max function, vector version.
ConstVectorView()
Default constructor.
MatrixView & operator+=(Numeric x)
Addition of scalar.
Index nrows() const
Returns the number of rows.
friend void swap(Matrix &m1, Matrix &m2)
Swaps two objects.
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.
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.
Range mrr
The row range of mdata that is actually used.
void cross3(VectorView c, const ConstVectorView &a, const ConstVectorView &b)
cross3
ConstIterator1D end() const
Return const iterator behind last element.
ConstIterator2D begin() const
Return const iterator to first row.
ConstIterator2D end() const
Return const iterator behind last row.
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication.
virtual ~Matrix()
Destructor for Matrix.
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.
Range(Index start, Index extent, Index stride=1)
Numeric sum() const
The sum of all elements of a Vector.
NUMERIC Numeric
The type to use for all floating point numbers.
std::ostream & operator<<(std::ostream &os, const ConstVectorView &v)
Output operator.
friend void swap(Vector &v1, Vector &v2)
Swaps two objects.
ConstMatrixView transpose(ConstMatrixView m)
Const version of transpose.
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.
ConstIterator1D begin() const
Return const iterator to first element.
The const row iterator class for sub matrices.
A constant view of a Matrix.
Numeric min(const ConstVectorView &x)
Min function, vector version.
Index mextent
The number of elements.
ConstIterator2D end() const
Return const iterator behind last row.
Matrix()
Default constructor.
VectorView operator*=(Numeric x)
Multiplication by scalar.
VectorView operator-=(Numeric x)
Subtraction of scalar.
void swap(Vector &v1, Vector &v2)
Swaps two objects.
ConstMatrixView()
Default constructor.
Numeric vector_angle(ConstVectorView a, ConstVectorView b)
ConstIterator2D begin() const
Return const iterator to first row.
ConstIterator1D end() const
Return const iterator behind last element.
The row iterator class for sub matrices.
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.
MatrixView & operator*=(Numeric x)
Multiplication by scalar.
const Numeric * get_c_array() const
Conversion to plain C-array.
friend class ConstVectorView
void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
Copy data between begin and end to 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.
const Numeric * get_c_array() const
Conversion to plain C-array.
Numeric operator[](Index n) const
Plain const index operator.