31 using std::runtime_error;
53 mstart(start), mextent(extent), mstride(stride)
116 assert( fin < max_size );
143 assert(
mstart<=prev_fin );
161 assert( p.
mstart <= fin );
162 assert( fin <= prev_fin );
182 return mrange.mextent;
217 (mrange.mextent)*mrange.mstride,
240 mrange(0,1), mdata(&const_cast<
Numeric&>(a))
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 861 assert( c < mcr.mextent );
876 assert( r < mrr.mextent );
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 )
1573 copy( dummy.begin(), dummy.end(),
begin() );
1633 for ( ; ai!=ae ; ++ai, ++bi )
1634 res += (*ai) * (*bi);
1671 *yelem = *melem * *xelem;
1678 *yelem += *melem * *xelem;
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;
2023 assert(mrange.mextent==v.
nelem());
2031 for ( ; i!=e ; ++i,++target )
friend class ConstVectorView
INDEX Index
The type to use for all integer numbers and indices.
friend void swap(Matrix &m1, Matrix &m2)
Swaps two objects.
const Numeric * mx
Current position.
void swap(Vector &v1, Vector &v2)
Swaps two objects.
Matrix & operator=(Matrix x)
Assignment operator from another matrix.
void cross3(VectorView c, const ConstVectorView &a, const ConstVectorView &b)
cross3
ConstIterator1D begin() const
Return const iterator to first element.
Index nelem() const
Number of elements.
friend void mult(VectorView, const ConstMatrixView &, const ConstVectorView &)
Matrix Vector multiplication.
Index mstart
The start index.
ConstIterator2D begin() const
Return const iterator to first row.
Numeric * mdata
Pointer to the plain C array that holds the data.
Matrix()
Default constructor.
MatrixView & operator*=(Numeric x)
Multiplication by scalar.
const Numeric * get_c_array() const
Conversion to plain C-array.
void copy(ConstIterator1D origin, const ConstIterator1D &end, Iterator1D target)
Copy data between begin and end to target.
Numeric operator()(Index r, Index c) const
Plain const index operator.
ConstIterator2D end() const
Return const iterator behind last row.
VectorView operator*=(Numeric x)
Multiplication by scalar.
Vector()
Default constructor.
friend class ConstIterator2D
ConstVectorView()
Default constructor.
ConstMatrixView()
Default constructor.
friend class ConstMatrixView
The row iterator class for sub matrices.
Numeric operator*(const ConstVectorView &a, const ConstVectorView &b)
Scalar product.
Numeric min(const ConstVectorView &x)
Min function, vector version.
ConstIterator1D begin() const
Return const iterator to first element.
ConstIterator1D end() const
Return const iterator behind last element.
VectorView operator+=(Numeric x)
Addition of scalar.
ConstIterator1D end() const
Return const iterator behind last element.
Index nelem() const
Returns the number of elements.
Numeric operator[](Index n) const
Plain const index operator.
ConstIterator2D begin() const
Return const iterator to first row.
Range(Index start, Index extent, Index stride=1)
VectorView operator-=(Numeric x)
Subtraction of scalar.
The const row iterator class for sub matrices.
Index ncols() const
Returns the number of columns.
VectorView()
Default constructor.
const Numeric * get_c_array() const
Conversion to plain C-array.
friend class ConstMatrixView
Range mrr
The row range of mdata that is actually used.
void proj(Vector &c, ConstVectorView a, ConstVectorView b)
Numeric max(const ConstVectorView &x)
Max function, vector version.
Vector & operator=(Vector v)
Assignment from another Vector.
Numeric sum() const
The sum of all elements of a Vector.
The declarations of all the exception classes.
Numeric operator[](Index n) const
Plain const index operator.
ConstIterator2D end() const
Return const iterator behind last row.
virtual ~Vector()
Destructor for Vector.
friend void swap(Vector &v1, Vector &v2)
Swaps two objects.
Numeric operator()(Index r, Index c) const
Plain const index operator.
std::ostream & operator<<(std::ostream &os, const ConstVectorView &v)
Output operator.
MatrixView()
Default constructor.
NUMERIC Numeric
The type to use for all floating point numbers.
Range mcr
The column range of mdata that is actually used.
Index mextent
The number of elements.
MatrixView & operator=(const ConstMatrixView &v)
Assignment operator.
void resize(Index n)
Assignment operator from VectorView.
MatrixView & operator-=(Numeric x)
Subtraction of scalar.
friend ConstMatrixView transpose(ConstMatrixView m)
Const version of transpose.
A constant view of a Vector.
Numeric vector_angle(ConstVectorView a, ConstVectorView b)
VectorView & operator=(const ConstVectorView &v)
Assignment operator.
Numeric mean(const ConstVectorView &x)
Mean function, vector version.
Numeric * mdata
Pointer to the plain C array that holds the data.
A constant view of a Matrix.
Numeric debug_matrixview_get_elem(MatrixView &mv, Index r, Index c)
Helper function to access matrix elements.
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...
MatrixView & operator/=(Numeric x)
Division by scalar.
Numeric * mx
Current position.
Range mrange
The range of mdata that is actually used.
The constant iterator class for sub vectors.
MatrixView & operator+=(Numeric x)
Addition of scalar.
The iterator class for sub vectors.
Index nrows() const
Returns the number of rows.
const Numeric RAD2DEG
Global constant, conversion from radians to degrees.
void resize(Index r, Index c)
Resize function.
VectorView operator/=(Numeric x)
Division by scalar.
virtual ~Matrix()
Destructor for Matrix.