41#define G_CONSTRUCTOR "GMatrix::GMatrix(int&, int&)"
42#define G_OP_MUL_VEC "GMatrix::operator*(GVector&)"
43#define G_OP_ADD "GMatrix::operator+=(GMatrix&)"
44#define G_OP_SUB "GMatrix::operator-=(GMatrix&)"
45#define G_OP_MAT_MUL "GMatrix::operator*=(GMatrix&)"
46#define G_AT "GMatrix::at(int&, int&)"
47#define G_EXTRACT_ROW "GMatrix::row(int&)"
48#define G_SET_ROW "GMatrix::row(int&, GVector&)"
49#define G_EXTRACT_COLUMN "GMatrix::column(int&)"
50#define G_SET_COLUMN "GMatrix::column(int&, GVector&)"
51#define G_ADD_TO_ROW "GMatrix::add_to_row(int&, GVector&)"
52#define G_ADD_TO_COLUMN "GMatrix::add_to_column(int&, GVector&)"
53#define G_INVERT "GMatrix::invert()"
54#define G_SOLVE "GMatrix::solve(GVector&)"
55#define G_EXTRACT_LOWER "GMatrix::extract_lower_triangle()"
56#define G_EXTRACT_UPPER "GMatrix::extract_upper_triangle()"
96 #if defined(G_RANGE_CHECK)
99 "Please specify a non-negative number of rows.";
104 "negative. Please specify a non-negative number of "
159 for (
int col = 0; col <
m_cols; ++col) {
161 double value = matrix(
row, col);
162 (*this)(
row, col) = value;
163 (*this)(col,
row) = value;
190 for (
int col = 0; col <
m_cols; ++col) {
192 (*this)(
row, col) = matrix(
row, col);
231 if (
this != &matrix) {
295 "Please specify a vector of size "+
306 sum += *src * vector[col];
330 double* ptr = matrix.
m_data;
331 for (
int i = 0; i < matrix.
m_elements; ++i, ++ptr) {
356 " differs from the expected number of "+
363 " differs from the expected number of "+
370 const double* src = matrix.
m_data;
417 " differs from the expected number of "+
424 " differs from the expected number of "+
431 const double* src = matrix.
m_data;
484 "the first matrix differs from number of "+
486 "matrix. Please specify a second matrix with "+
495 for (
int col = 0; col <
m_cols; ++col) {
497 for (
int i = 0; i <
m_cols; ++i) {
498 sum += v_row[i] * matrix(i,col);
513 for (
int col = 0; col < matrix.
m_cols; ++col) {
515 for (
int i = 0; i <
m_cols; ++i) {
516 sum += (*this)(
row,i) * matrix(i,col);
640 #if defined(G_RANGE_CHECK)
679 #if defined(G_RANGE_CHECK)
690 "columns. Please specify a vector of size "+
721 #if defined(G_RANGE_CHECK)
766 #if defined(G_RANGE_CHECK)
778 "rows. Please specify a vector of size "+
815 #if defined(G_RANGE_CHECK)
827 "columns. Please specify a vector of size "+
860 #if defined(G_RANGE_CHECK)
873 "rows. Please specify a vector of size "+
910 for (
int col = 0; col <
m_cols; ++col) {
911 matrix(col,
row) = (*this)(
row, col);
990 double* dst = matrix.
m_data;
992 *dst++ = std::abs(*src++);
1014 double result = 0.0;
1028 result = 1.0-double(zero)/double(
m_elements);
1054 " differs from number of matrix columns "+
1056 "on square matrices.";
1064 for (
int col = 0; col <
m_cols; ++col) {
1093 " differs from number of matrix columns "+
1095 "on square matrices.";
1103 for (
int col = 0; col <
m_cols; ++col) {
1105 for (
int row = 0;
row <= col; ++
row, ++i) {
1133 double cosangle = std::cos(arg);
1134 double sinangle = std::sin(arg);
1141 (*this)(1,1) = cosangle;
1142 (*this)(1,2) = -sinangle;
1144 (*this)(2,1) = sinangle;
1145 (*this)(2,2) = cosangle;
1170 double cosangle = std::cos(arg);
1171 double sinangle = std::sin(arg);
1174 (*this)(0,0) = cosangle;
1176 (*this)(0,2) = sinangle;
1180 (*this)(2,0) = -sinangle;
1182 (*this)(2,2) = cosangle;
1207 double cosangle = std::cos(arg);
1208 double sinangle = std::sin(arg);
1211 (*this)(0,0) = cosangle;
1212 (*this)(0,1) = -sinangle;
1214 (*this)(1,0) = sinangle;
1215 (*this)(1,1) = cosangle;
1241 result.append(
"=== GMatrix ===");
1337 m_data =
new double[elements];
1348 for (
int col = 1; col <=
m_cols; ++col) {
Exception handler interface definition.
Mathematical function definitions.
Sparse matrix class definition.
Symmetric matrix class definition.
Generic matrix class definition.
double angle(const GVector &a, const GVector &b)
Computes angle between vectors.
Vector class interface definition.
Abstract matrix base class interface definition.
const int & rows(void) const
Return number of matrix rows.
int m_num_rowsel
Number of selected rows (for compressed decomposition)
void init_members(void)
Initialise class members.
std::string print_col_compression(const GChatter &chatter=NORMAL) const
Print column compression scheme if it exists.
int m_cols
Number of columns.
int m_rows
Number of rows.
const int & columns(void) const
Return number of matrix columns.
virtual GMatrixBase & operator=(const GMatrixBase &matrix)
Assignment operator.
int * m_colsel
Column selection (for compressed decomposition)
double * m_data
Matrix data.
int m_num_colsel
Number of selected columns (for compressed decomposition)
void free_members(void)
Delete class members.
std::string print_row_compression(const GChatter &chatter=NORMAL) const
Print row compression scheme if it exists.
std::string print_elements(const GChatter &chatter=NORMAL, const int &num=15) const
Print all matrix elements.
int m_alloc
Size of allocated matrix memory.
int * m_colstart
Column start indices (m_cols+1)
int * m_rowsel
Row selection (for compressed decomposition)
int m_elements
Number of elements stored in matrix.
Sparse matrix class interface definition.
Symmetric matrix class interface definition.
Generic matrix class definition.
void init_members(void)
Initialise class members.
void copy_members(const GMatrix &matrix)
Copy class members.
virtual double sum(void) const
Return matrix element sum.
virtual ~GMatrix(void)
Destructor.
GMatrix(void)
Void matrix constructor.
virtual double & at(const int &row, const int &column)
Return reference to matrix element.
GMatrix extract_lower_triangle(void) const
Extract lower triangle of matrix.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print matrix.
virtual GMatrix & operator*=(const GMatrix &matrix)
Unary matrix multiplication operator.
virtual double fill(void) const
Return fill of matrix.
GVector solve(const GVector &vector) const
Solves linear matrix equation.
void eulerx(const double &angle)
Set Euler rotation matrix around x axis.
virtual GVector row(const int &row) const
Extract row as vector from matrix.
GMatrix transpose(void) const
Return transposed matrix.
GMatrix invert(void) const
Return inverted matrix.
virtual void add_to_row(const int &row, const GVector &vector)
Add row to matrix elements.
virtual GMatrix operator-(void) const
Negate matrix elements.
virtual void add_to_column(const int &column, const GVector &vector)
Add vector column into matrix.
virtual GMatrix * clone(void) const
Clone matrix.
virtual GMatrix & operator=(const GMatrix &matrix)
Matrix assignment operator.
virtual GMatrix & operator+=(const GMatrix &matrix)
Unary matrix addition operator.
virtual GMatrix & operator-=(const GMatrix &matrix)
Unary matrix subtraction operator.
GMatrix abs(void) const
Return absolute of matrix.
GMatrix extract_upper_triangle(void) const
Extract upper triangle of matrix.
void eulerz(const double &angle)
Set Euler rotation matrix around z axis.
void eulery(const double &angle)
Set Euler rotation matrix around y axis.
virtual GVector column(const int &column) const
Extract column as vector from matrix.
void alloc_members(const int &rows, const int &columns)
Allocate matrix memory.
void free_members(void)
Delete class members.
virtual GVector operator*(const GVector &vector) const
Vector multiplication.
virtual void clear(void)
Clear matrix.
const int & size(void) const
Return size of vector.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.