#include <Array.h>

Public Member Functions | |
| Matrix () | |
| Matrix (const unsigned int n, const unsigned int m) | |
| Matrix (const T &a, const unsigned int n, const unsigned int m) | |
| Matrix (MType t, const T &a, const T &o, const unsigned int n, const unsigned int m) | |
| Matrix (MType t, const Vector< T > &v, const T &o, const unsigned int n, const unsigned int m) | |
| Matrix (const T *a, const unsigned int n, const unsigned int m) | |
| Matrix (const Matrix< T > &rhs) | |
| ~Matrix () | |
| T * | operator[] (const unsigned int &i) |
| const T * | operator[] (const unsigned int &i) const |
| void | resize (const unsigned int n, const unsigned int m) |
| void | resize (const T &a, const unsigned int n, const unsigned int m) |
| Vector< T > | extractRow (const unsigned int i) const |
| Vector< T > | extractColumn (const unsigned int j) const |
| Vector< T > | extractDiag () const |
| Matrix< T > | extractRows (const std::set< unsigned int > &indexes) const |
| Matrix< T > | extractColumns (const std::set< unsigned int > &indexes) const |
| Matrix< T > | extract (const std::set< unsigned int > &r_indexes, const std::set< unsigned int > &c_indexes) const |
| void | set (const T *a, unsigned int n, unsigned int m) |
| void | set (const std::set< unsigned int > &r_indexes, const std::set< unsigned int > &c_indexes, const Matrix< T > &m) |
| void | setRow (const unsigned int index, const Vector< T > &v) |
| void | setRow (const unsigned int index, const Matrix< T > &v) |
| void | setRows (const std::set< unsigned int > &indexes, const Matrix< T > &m) |
| void | setColumn (const unsigned int index, const Vector< T > &v) |
| void | setColumn (const unsigned int index, const Matrix< T > &v) |
| void | setColumns (const std::set< unsigned int > &indexes, const Matrix< T > &m) |
| unsigned int | nrows () const |
| unsigned int | ncols () const |
| Matrix< T > & | operator= (const Matrix< T > &rhs) |
| Matrix< T > & | operator= (const T &a) |
| Matrix< T > & | operator+= (const Matrix< T > &rhs) |
| Matrix< T > & | operator-= (const Matrix< T > &rhs) |
| Matrix< T > & | operator*= (const Matrix< T > &rhs) |
| Matrix< T > & | operator/= (const Matrix< T > &rhs) |
| Matrix< T > & | operator^= (const Matrix< T > &rhs) |
| Matrix< T > & | operator+= (const T &a) |
| Matrix< T > & | operator-= (const T &a) |
| Matrix< T > & | operator*= (const T &a) |
| Matrix< T > & | operator/= (const T &a) |
| Matrix< T > & | operator^= (const T &a) |
| operator Vector< T > () | |
Definition at line 857 of file Array.h.
| QuadProgPP::Matrix< T >::Matrix | ( | ) |
| QuadProgPP::Matrix< T >::Matrix | ( | const unsigned int | n, |
| const unsigned int | m | ||
| ) |
| QuadProgPP::Matrix< T >::Matrix | ( | const T & | a, |
| const unsigned int | n, | ||
| const unsigned int | m | ||
| ) |
| QuadProgPP::Matrix< T >::Matrix | ( | MType | t, |
| const T & | a, | ||
| const T & | o, | ||
| const unsigned int | n, | ||
| const unsigned int | m | ||
| ) |
Definition at line 960 of file Array.h.
References QuadProgPP::DIAG.
: v(new T*[n]) { unsigned int i, j; this->n = n; this->m = m; v[0] = new T[m * n]; for (i = 1; i < n; i++) v[i] = v[i - 1] + m; switch (t) { case DIAG: for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (i != j) v[i][j] = o; else v[i][j] = a; break; default: throw std::logic_error("Matrix type not supported"); } }
| QuadProgPP::Matrix< T >::Matrix | ( | MType | t, |
| const Vector< T > & | v, | ||
| const T & | o, | ||
| const unsigned int | n, | ||
| const unsigned int | m | ||
| ) |
Definition at line 984 of file Array.h.
References QuadProgPP::DIAG.
: v(new T*[n]) { unsigned int i, j; this->n = n; this->m = m; v[0] = new T[m * n]; for (i = 1; i < n; i++) v[i] = v[i - 1] + m; switch (t) { case DIAG: for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (i != j) v[i][j] = o; else v[i][j] = a[i]; break; default: throw std::logic_error("Matrix type not supported"); } }
| QuadProgPP::Matrix< T >::Matrix | ( | const T * | a, |
| const unsigned int | n, | ||
| const unsigned int | m | ||
| ) |
| QuadProgPP::Matrix< T >::Matrix | ( | const Matrix< T > & | rhs ) |
| QuadProgPP::Matrix< T >::~Matrix | ( | ) |
| Matrix< T > QuadProgPP::Matrix< T >::extract | ( | const std::set< unsigned int > & | r_indexes, |
| const std::set< unsigned int > & | c_indexes | ||
| ) | const [inline] |
Definition at line 1167 of file Array.h.
{
Matrix<T> tmp(r_indexes.size(), c_indexes.size());
unsigned int i = 0, j;
for (std::set<unsigned int>::const_iterator r_el = r_indexes.begin(); r_el != r_indexes.end(); r_el++)
{
if (*r_el >= n)
throw std::logic_error("Error extracting submatrix: the indexes are out of matrix bounds");
j = 0;
for (std::set<unsigned int>::const_iterator c_el = c_indexes.begin(); c_el != c_indexes.end(); c_el++)
{
if (*c_el >= m)
throw std::logic_error("Error extracting rows: the indexes are out of matrix bounds");
tmp[i][j] = v[*r_el][*c_el];
j++;
}
i++;
}
return tmp;
}
| Vector< T > QuadProgPP::Matrix< T >::extractColumn | ( | const unsigned int | j ) | const [inline] |
Definition at line 1099 of file Array.h.
Referenced by QuadProgPP::rank().
{
unsigned int i;
if (j >= m)
throw std::logic_error("Error in extractRow: trying to extract a row out of matrix bounds");
Vector<T> tmp(n);
for (i = 0; i < n; i++)
tmp[i] = v[i][j];
return tmp;
}
| Matrix< T > QuadProgPP::Matrix< T >::extractColumns | ( | const std::set< unsigned int > & | indexes ) | const [inline] |
Definition at line 1147 of file Array.h.
{
Matrix<T> tmp(n, indexes.size());
unsigned int i, j = 0;
for (std::set<unsigned int>::const_iterator el = indexes.begin(); el != indexes.end(); el++)
{
for (i = 0; i < n; i++)
{
if (*el >= m)
throw std::logic_error("Error extracting columns: the indexes are out of matrix bounds");
tmp[i][j] = v[i][*el];
}
j++;
}
return tmp;
}
| Vector< T > QuadProgPP::Matrix< T >::extractDiag | ( | ) | const [inline] |
Definition at line 1113 of file Array.h.
References QuadProgPP::min().
Referenced by QuadProgPP::lu_det().
{
unsigned int d = std::min(n, m), i;
Vector<T> tmp(d);
for (i = 0; i < d; i++)
tmp[i] = v[i][i];
return tmp;
}
| Vector< T > QuadProgPP::Matrix< T >::extractRow | ( | const unsigned int | i ) | const [inline] |
Definition at line 1089 of file Array.h.
Referenced by QuadProgPP::r_rank().
{
if (i >= n)
throw std::logic_error("Error in extractRow: trying to extract a row out of matrix bounds");
Vector<T> tmp(v[i], m);
return tmp;
}
| Matrix< T > QuadProgPP::Matrix< T >::extractRows | ( | const std::set< unsigned int > & | indexes ) | const [inline] |
Definition at line 1127 of file Array.h.
{
Matrix<T> tmp(indexes.size(), m);
unsigned int i = 0, j;
for (std::set<unsigned int>::const_iterator el = indexes.begin(); el != indexes.end(); el++)
{
for (j = 0; j < m; j++)
{
if (*el >= n)
throw std::logic_error("Error extracting rows: the indexes are out of matrix bounds");
tmp[i][j] = v[*el][j];
}
i++;
}
return tmp;
}
| unsigned int QuadProgPP::Matrix< T >::ncols | ( | ) | const [inline] |
Definition at line 894 of file Array.h.
Referenced by QuadProgPP::all_mean(), QuadProgPP::all_prod(), QuadProgPP::all_sum(), QuadProgPP::backward_elimination(), QuadProgPP::cholesky(), QuadProgPP::cholesky_solve(), QuadProgPP::dot_prod(), QuadProgPP::exp(), QuadProgPP::forward_elimination(), QuadProgPP::lu(), QuadProgPP::lu_det(), QuadProgPP::lu_inverse(), QuadProgPP::lu_solve(), QuadProgPP::max(), QuadProgPP::mean(), QuadProgPP::min(), QuadProgPP::operator!=(), QuadProgPP::operator*(), QuadProgPP::Matrix< T >::operator*=(), QuadProgPP::operator+(), QuadProgPP::Matrix< T >::operator+=(), QuadProgPP::operator-(), QuadProgPP::Matrix< T >::operator-=(), QuadProgPP::operator/(), QuadProgPP::Matrix< T >::operator/=(), QuadProgPP::operator==(), QuadProgPP::operator^(), QuadProgPP::Matrix< T >::operator^=(), QuadProgPP::pinv(), QuadProgPP::print_matrix(), QuadProgPP::prod(), QuadProgPP::r_max(), QuadProgPP::r_mean(), QuadProgPP::r_min(), QuadProgPP::r_prod(), QuadProgPP::r_rank(), QuadProgPP::r_sum(), QuadProgPP::r_var(), QuadProgPP::random(), QuadProgPP::rank(), QuadProgPP::Matrix< T >::set(), QuadProgPP::Matrix< T >::setColumn(), QuadProgPP::Matrix< T >::setColumns(), QuadProgPP::Matrix< T >::setRow(), QuadProgPP::Matrix< T >::setRows(), QuadProgPP::QuadProg::solve_quadprog(), QuadProgPP::sqrt(), QuadProgPP::sum(), QuadProgPP::svd(), QuadProgPP::t(), and QuadProgPP::var().
{ return m; } // number of columns
| unsigned int QuadProgPP::Matrix< T >::nrows | ( | ) | const [inline] |
Definition at line 893 of file Array.h.
Referenced by QuadProgPP::all_mean(), QuadProgPP::all_prod(), QuadProgPP::all_sum(), QuadProgPP::backward_elimination(), QuadProgPP::cholesky(), QuadProgPP::cholesky_decomposition(), QuadProgPP::cholesky_solve(), QuadProgPP::dot_prod(), QuadProgPP::exp(), QuadProgPP::forward_elimination(), QuadProgPP::lu(), QuadProgPP::lu_det(), QuadProgPP::lu_inverse(), QuadProgPP::lu_solve(), QuadProgPP::max(), QuadProgPP::mean(), QuadProgPP::min(), QuadProgPP::operator!=(), QuadProgPP::operator*(), QuadProgPP::Matrix< T >::operator*=(), QuadProgPP::operator+(), QuadProgPP::Matrix< T >::operator+=(), QuadProgPP::operator-(), QuadProgPP::Matrix< T >::operator-=(), QuadProgPP::operator/(), QuadProgPP::Matrix< T >::operator/=(), QuadProgPP::operator==(), QuadProgPP::operator^(), QuadProgPP::Matrix< T >::operator^=(), QuadProgPP::pinv(), QuadProgPP::print_matrix(), QuadProgPP::prod(), QuadProgPP::r_max(), QuadProgPP::r_mean(), QuadProgPP::r_min(), QuadProgPP::r_prod(), QuadProgPP::r_rank(), QuadProgPP::r_sum(), QuadProgPP::r_var(), QuadProgPP::random(), QuadProgPP::rank(), QuadProgPP::Matrix< T >::set(), QuadProgPP::Matrix< T >::setColumn(), QuadProgPP::Matrix< T >::setColumns(), QuadProgPP::Matrix< T >::setRow(), QuadProgPP::Matrix< T >::setRows(), QuadProgPP::QuadProg::solve_quadprog(), QuadProgPP::sqrt(), QuadProgPP::sum(), QuadProgPP::svd(), QuadProgPP::t(), and QuadProgPP::var().
{ return n; } // number of rows
| QuadProgPP::Matrix< T >::operator Vector< T > | ( | ) | [inline] |
Definition at line 1587 of file Array.h.
{
if (n > 1 && m > 1)
throw std::logic_error("Error matrix cast to vector: trying to cast a multi-dimensional matrix");
if (n == 1)
return extractRow(0);
else
return extractColumn(0);
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator*= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1474 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (m != rhs.ncols() || n != rhs.nrows())
throw std::logic_error("Operator*=: matrices have different sizes");
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] *= rhs[i][j];
return *this;
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator*= | ( | const T & | a ) | [inline] |
| Matrix< T > & QuadProgPP::Matrix< T >::operator+= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1354 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (m != rhs.ncols() || n != rhs.nrows())
throw std::logic_error("Operator+=: matrices have different sizes");
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] += rhs[i][j];
return *this;
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator+= | ( | const T & | a ) | [inline] |
| Matrix< T > & QuadProgPP::Matrix< T >::operator-= | ( | const T & | a ) | [inline] |
| Matrix< T > & QuadProgPP::Matrix< T >::operator-= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1417 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (m != rhs.ncols() || n != rhs.nrows())
throw std::logic_error("Operator-=: matrices have different sizes");
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] -= rhs[i][j];
return *this;
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator/= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1531 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (m != rhs.ncols() || n != rhs.nrows())
throw std::logic_error("Operator+=: matrices have different sizes");
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] /= rhs[i][j];
return *this;
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator/= | ( | const T & | a ) | [inline] |
| Matrix< T > & QuadProgPP::Matrix< T >::operator= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1031 of file Array.h.
: normal assignment via copying has been performed; // if matrix and rhs were different sizes, matrix // has been resized to match the size of rhs { unsigned int i, j; if (this != &rhs) { resize(rhs.n, rhs.m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) v[i][j] = rhs[i][j]; } return *this; }
| Matrix< T > & QuadProgPP::Matrix< T >::operator= | ( | const T & | a ) | [inline] |
| T* QuadProgPP::Matrix< T >::operator[] | ( | const unsigned int & | i ) | [inline] |
| const T* QuadProgPP::Matrix< T >::operator[] | ( | const unsigned int & | i ) | const [inline] |
| Matrix< T > & QuadProgPP::Matrix< T >::operator^= | ( | const T & | a ) | [inline] |
Definition at line 1577 of file Array.h.
References QuadProgPP::pow().
{
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] = pow(v[i][j], a);
return *this;
}
| Matrix< T > & QuadProgPP::Matrix< T >::operator^= | ( | const Matrix< T > & | rhs ) | [inline] |
Definition at line 1564 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), QuadProgPP::Matrix< T >::nrows(), and QuadProgPP::pow().
{
if (m != rhs.ncols() || n != rhs.nrows())
throw std::logic_error("Operator^=: matrices have different sizes");
for (unsigned int i = 0; i < n; i++)
for (unsigned int j = 0; j < m; j++)
v[i][j] = pow(v[i][j], rhs[i][j]);
return *this;
}
| void QuadProgPP::Matrix< T >::resize | ( | const T & | a, |
| const unsigned int | n, | ||
| const unsigned int | m | ||
| ) | [inline] |
| void QuadProgPP::Matrix< T >::resize | ( | const unsigned int | n, |
| const unsigned int | m | ||
| ) | [inline] |
Definition at line 1059 of file Array.h.
Referenced by QuadProgPP::operator>>(), and QuadProgPP::svd().
{
unsigned int i;
if (n == this->n && m == this->m)
return;
if (v != 0)
{
delete[] (v[0]);
delete[] (v);
}
this->n = n; this->m = m;
v = new T*[n];
v[0] = new T[m * n];
for (i = 1; i < n; i++)
v[i] = v[i - 1] + m;
}
| void QuadProgPP::Matrix< T >::set | ( | const T * | a, |
| unsigned int | n, | ||
| unsigned int | m | ||
| ) | [inline] |
| void QuadProgPP::Matrix< T >::set | ( | const std::set< unsigned int > & | r_indexes, |
| const std::set< unsigned int > & | c_indexes, | ||
| const Matrix< T > & | m | ||
| ) | [inline] |
Definition at line 1278 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
unsigned int i = 0, j;
if (c_indexes.size() != a.ncols() || r_indexes.size() != a.nrows())
throw std::logic_error("Error setting matrix elements: ranges are not compatible");
for (std::set<unsigned int>::const_iterator r_el = r_indexes.begin(); r_el != r_indexes.end(); r_el++)
{
if (*r_el >= n)
throw std::logic_error("Error in set: trying to set a row out of matrix bounds");
j = 0;
for (std::set<unsigned int>::const_iterator c_el = c_indexes.begin(); c_el != c_indexes.end(); c_el++)
{
if (*c_el >= m)
throw std::logic_error("Error in set: trying to set a column out of matrix bounds");
v[*r_el][*c_el] = a[i][j];
j++;
}
i++;
}
}
| void QuadProgPP::Matrix< T >::setColumn | ( | const unsigned int | index, |
| const Vector< T > & | v | ||
| ) | [inline] |
Definition at line 1234 of file Array.h.
References QuadProgPP::Vector< T >::size().
Referenced by QuadProgPP::rank().
{
if (j >= m)
throw std::logic_error("Error in setColumn: trying to set a column out of matrix bounds");
if (this->n != a.size())
throw std::logic_error("Error setting matrix column: ranges are not compatible");
for (unsigned int i = 0; i < nrows(); i++)
v[i][j] = a[i];
}
| void QuadProgPP::Matrix< T >::setColumn | ( | const unsigned int | index, |
| const Matrix< T > & | v | ||
| ) | [inline] |
Definition at line 1245 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (j >= m)
throw std::logic_error("Error in setColumn: trying to set a column out of matrix bounds");
if (this->n != a.nrows())
throw std::logic_error("Error setting matrix column: ranges are not compatible");
if (a.ncols() != 1)
throw std::logic_error("Error setting matrix column with a non-column matrix");
for (unsigned int i = 0; i < nrows(); i++)
v[i][j] = a[i][0];
}
| void QuadProgPP::Matrix< T >::setColumns | ( | const std::set< unsigned int > & | indexes, |
| const Matrix< T > & | m | ||
| ) | [inline] |
Definition at line 1259 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
unsigned int j = 0;
if (indexes.size() != a.ncols() || this->n != a.nrows())
throw std::logic_error("Error setting matrix columns: ranges are not compatible");
for (std::set<unsigned int>::const_iterator el = indexes.begin(); el != indexes.end(); el++)
{
for (unsigned int i = 0; i < nrows(); i++)
{
if (*el >= m)
throw std::logic_error("Error in setColumns: trying to set a column out of matrix bounds");
v[i][*el] = a[i][j];
}
j++;
}
}
| void QuadProgPP::Matrix< T >::setRow | ( | const unsigned int | index, |
| const Vector< T > & | v | ||
| ) | [inline] |
Definition at line 1191 of file Array.h.
References QuadProgPP::Vector< T >::size().
Referenced by QuadProgPP::r_rank().
{
if (i >= n)
throw std::logic_error("Error in setRow: trying to set a row out of matrix bounds");
if (this->m != a.size())
throw std::logic_error("Error setting matrix row: ranges are not compatible");
for (unsigned int j = 0; j < ncols(); j++)
v[i][j] = a[j];
}
| void QuadProgPP::Matrix< T >::setRow | ( | const unsigned int | index, |
| const Matrix< T > & | v | ||
| ) | [inline] |
Definition at line 1202 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
if (i >= n)
throw std::logic_error("Error in setRow: trying to set a row out of matrix bounds");
if (this->m != a.ncols())
throw std::logic_error("Error setting matrix column: ranges are not compatible");
if (a.nrows() != 1)
throw std::logic_error("Error setting matrix column with a non-row matrix");
for (unsigned int j = 0; j < ncols(); j++)
v[i][j] = a[0][j];
}
| void QuadProgPP::Matrix< T >::setRows | ( | const std::set< unsigned int > & | indexes, |
| const Matrix< T > & | m | ||
| ) | [inline] |
Definition at line 1215 of file Array.h.
References QuadProgPP::Matrix< T >::ncols(), and QuadProgPP::Matrix< T >::nrows().
{
unsigned int i = 0;
if (indexes.size() != m.nrows() || this->m != m.ncols())
throw std::logic_error("Error setting matrix rows: ranges are not compatible");
for (std::set<unsigned int>::const_iterator el = indexes.begin(); el != indexes.end(); el++)
{
for (unsigned int j = 0; j < ncols(); j++)
{
if (*el >= n)
throw std::logic_error("Error in setRows: trying to set a row out of matrix bounds");
v[*el][j] = m[i][j];
}
i++;
}
}
1.7.2