N x N matrix.
More...
#include <JMatrixND.hh>
N x N matrix.
Definition at line 63 of file JMatrixND.hh.
JMATH::JMatrixND::JMatrixND |
( |
| ) |
|
|
inline |
JMATH::JMatrixND::JMatrixND |
( |
const size_t |
size | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 85 of file JMatrixND.hh.
void resize(const size_t size)
Resize matrix.
JMatrixND & reset()
Set matrix to the null matrix.
void JMATH::JMatrixND::resize |
( |
const size_t |
size | ) |
|
|
inline |
Resize matrix.
Note that this method resets the matrix.
- Parameters
-
Definition at line 98 of file JMatrixND.hh.
100 matrix_type::resize(size);
102 for (
row_type row = this->begin(); row != this->end(); ++row) {
106 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
matrix_type::iterator row_type
double JMATH::JMatrixND::at |
( |
size_t |
row, |
|
|
size_t |
col |
|
) |
| const |
|
inline |
Get matrix element.
- Parameters
-
row | row number |
col | column number |
- Returns
- matrix element at (row,col)
Definition at line 120 of file JMatrixND.hh.
122 return (*
this)[row][col];
double& JMATH::JMatrixND::at |
( |
size_t |
row, |
|
|
size_t |
col |
|
) |
| |
|
inline |
Get matrix element.
- Parameters
-
row | row number |
col | column number |
- Returns
- matrix element at (row,col)
Definition at line 133 of file JMatrixND.hh.
135 return (*
this)[row][col];
double JMATH::JMatrixND::operator() |
( |
size_t |
row, |
|
|
size_t |
col |
|
) |
| const |
|
inline |
Get matrix element.
- Parameters
-
row | row number |
col | column number |
- Returns
- matrix element at (row,col)
Definition at line 146 of file JMatrixND.hh.
double at(size_t row, size_t col) const
Get matrix element.
double& JMATH::JMatrixND::operator() |
( |
size_t |
row, |
|
|
size_t |
col |
|
) |
| |
|
inline |
Get matrix element.
- Parameters
-
row | row number |
col | column number |
- Returns
- matrix element at (row,col)
Definition at line 159 of file JMatrixND.hh.
double at(size_t row, size_t col) const
Get matrix element.
Set matrix to the null matrix.
- Returns
- this matrix
Definition at line 170 of file JMatrixND.hh.
172 for (
row_type row = this->begin(); row != this->end(); ++row) {
173 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
matrix_type::iterator row_type
Set to identity matrix.
- Returns
- this matrix
Definition at line 187 of file JMatrixND.hh.
189 for (
size_t i = 0; i != this->size(); ++i) {
193 for (
size_t j = 0; j != i; ++j) {
194 at(i,j) =
at(j,i) = 0.0;
double at(size_t row, size_t col) const
Get matrix element.
Transpose.
- Returns
- this matrix
Definition at line 207 of file JMatrixND.hh.
209 for (
size_t i = 0; i != this->size(); ++i) {
210 for (
size_t j = 0; j != i; ++j) {
211 std::swap(
at(i,j),
at(j,i));
double at(size_t row, size_t col) const
Get matrix element.
Negate matrix.
- Returns
- this matrix
Definition at line 224 of file JMatrixND.hh.
226 for (
row_type row = this->begin(); row != this->end(); ++row) {
227 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
matrix_type::iterator row_type
Matrix addition.
- Parameters
-
- Returns
- this matrix
Definition at line 242 of file JMatrixND.hh.
244 if (this->size() == A.size()) {
246 for (
size_t i = 0; i != this->size(); ++i) {
247 for (
size_t j = 0; j != this->size(); ++j) {
248 at(i,j) += A.
at(i,j);
253 THROW(JException,
"JMatrixND::add() inconsistent matrix dimensions " << this->size() <<
' ' << A.size());
double at(size_t row, size_t col) const
Get matrix element.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Matrix subtraction.
- Parameters
-
- Returns
- this matrix
Definition at line 266 of file JMatrixND.hh.
268 if (this->size() == A.size()) {
270 for (
size_t i = 0; i != this->size(); ++i) {
271 for (
size_t j = 0; j != this->size(); ++j) {
272 at(i,j) -= A.
at(i,j);
277 THROW(JException,
"JMatrixND::sub() inconsistent matrix dimensions " << this->size() <<
' ' << A.size());
double at(size_t row, size_t col) const
Get matrix element.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JMatrixND& JMATH::JMatrixND::mul |
( |
const double |
factor | ) |
|
|
inline |
Scale matrix.
- Parameters
-
- Returns
- this matrix
Definition at line 290 of file JMatrixND.hh.
292 for (
row_type row = this->begin(); row != this->end(); ++row) {
293 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
matrix_type::iterator row_type
JMatrixND& JMATH::JMatrixND::div |
( |
const double |
factor | ) |
|
|
inline |
Scale matrix.
- Parameters
-
- Returns
- this matrix
Definition at line 308 of file JMatrixND.hh.
310 for (
row_type row = this->begin(); row != this->end(); ++row) {
311 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
matrix_type::iterator row_type
Matrix multiplication.
- Parameters
-
- Returns
- this matrix
Definition at line 327 of file JMatrixND.hh.
330 if (A.size() == B.size()) {
334 for (
size_t i = 0; i != A.size(); ++i) {
335 for (
size_t j = 0; j != A.size(); ++j) {
339 for (
size_t k = 0; k != A.size(); ++k) {
340 this->
at(i,j) += A[i][k] * B[k][j];
347 THROW(JException,
"JMatrixND::mul() inconsistent matrix dimensions " << A.size() <<
' ' << B.size());
double at(size_t row, size_t col) const
Get matrix element.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void resize(const size_t size)
Resize matrix.
bool JMATH::JMatrixND::equals |
( |
const JMatrixND & |
A, |
|
|
const double |
eps = std::numeric_limits<double>::min() |
|
) |
| const |
|
inline |
Equality.
- Parameters
-
A | matrix |
eps | numerical precision |
- Returns
- true if matrices identical; else false
Definition at line 361 of file JMatrixND.hh.
364 if (this->size() == A.size()) {
366 for (
const_row_type row1 = this->begin(), row2 = A.begin(); row1 != this->end(); ++row1, ++row2) {
367 for (
const_col_type col1 = row1->begin(), col2 = row2->begin(); col1 != row1->end(); ++col1, ++col2) {
368 if (fabs(*col1 - *col2) > eps) {
377 THROW(JException,
"JMatrixND::equals() inconsistent matrix dimensions " << this->size() <<
' ' << A.size());
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
matrix_type::const_iterator const_row_type
std::vector< double >::const_iterator const_col_type
bool JMATH::JMatrixND::isIdentity |
( |
const double |
eps = std::numeric_limits<double>::min() | ) |
const |
|
inline |
Test identity.
- Parameters
-
- Returns
- true if identity matrix; else false
Definition at line 388 of file JMatrixND.hh.
390 for (
size_t i = 0; i != this->size(); ++i) {
392 if (fabs(1.0 -
at(i,i)) > eps) {
396 for (
size_t j = 0; j != i; ++j) {
397 if (fabs(
at(i,j)) > eps || fabs(
at(j,i)) > eps) {
double at(size_t row, size_t col) const
Get matrix element.
double JMATH::JMatrixND::getDeterminant |
( |
| ) |
const |
|
inline |
Get determinant of matrix.
- Returns
- determinant of matrix
Definition at line 412 of file JMatrixND.hh.
420 for (
size_t i = 0; i != A.size(); ++i) {
424 return det * A.getSign();
static data_type & getInstance()
Get unique instance of template class.
bool JMATH::JMatrixND::isPositiveDefinite |
( |
| ) |
const |
|
inline |
Test positive definiteness.
- Returns
- true if positive definite; else false
Definition at line 433 of file JMatrixND.hh.
439 for (
size_t i = 0; i != A.size(); ++i) {
440 if (A[i][i] <= 0.0) {
static data_type & getInstance()
Get unique instance of template class.
const bool JMATH::JMatrixND::isPositiveSemiDefinite |
( |
| ) |
const |
|
inline |
Test positive semi-definiteness.
- Returns
- true if positive semi-definite; else false
Definition at line 454 of file JMatrixND.hh.
460 for (
size_t i = 0; i != A.size(); ++i) {
static data_type & getInstance()
Get unique instance of template class.
Multiply with object.
- Parameters
-
- Returns
- result object
Definition at line 273 of file JMath.hh.
Auxiliary class for product evaluation of objects.
Read matrix from input.
- Parameters
-
- Returns
- reader
Definition at line 477 of file JMatrixND.hh.
485 for (
row_type row = matrix.begin(); row != matrix.end(); ++row) {
486 for (
col_type col = row->begin(); col != row->end(); ++col) {
std::vector< double >::iterator col_type
void resize(const size_t size)
Resize matrix.
matrix_type::iterator row_type
Write matrix to output.
- Parameters
-
- Returns
- writer
Definition at line 502 of file JMatrixND.hh.
504 int size = matrix.size();
508 for (
const_row_type row = matrix.begin(); row != matrix.end(); ++row) {
509 for (
const_col_type col = row->begin(); col != row->end(); ++col) {
matrix_type::const_iterator const_row_type
std::vector< double >::const_iterator const_col_type
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const JMatrixND & |
A |
|
) |
| |
|
friend |
Print ASCII formatted output.
- Parameters
-
- Returns
- output stream
Definition at line 525 of file JMatrixND.hh.
533 for (
const_col_type col = row->begin(); col != row->end(); ++col) {
534 out <<
FIXED(10,2) << *col <<
' ';
Auxiliary data structure for floating point format specification.
matrix_type::const_iterator const_row_type
std::vector< double >::const_iterator const_col_type
Auxiliary class to temporarily modify format specifications.
The documentation for this class was generated from the following file: