27 #ifndef GMATRIXSPARSE_HPP
28 #define GMATRIXSPARSE_HPP
35 #define G_SPARSE_MATRIX_DEFAULT_MEM_BLOCK 512 // Default Memory block size
36 #define G_SPARSE_MATRIX_DEFAULT_STACK_ENTRIES 1000 // Max # of stack entries
37 #define G_SPARSE_MATRIX_DEFAULT_STACK_SIZE 512 // Max # of stack elements
199 friend double cs_cumsum(
int* p,
int* c,
int n);
205 const int& elements = 0);
238 virtual void clear(
void);
240 virtual std::string
classname(
void)
const;
241 virtual double&
at(
const int&
row,
const int&
column);
242 virtual const double&
at(
const int&
row,
const int&
column)
const;
249 virtual double fill(
void)
const;
250 virtual double min(
void)
const;
251 virtual double max(
void)
const;
252 virtual double sum(
void)
const;
271 const int&
number,
const int& col);
290 const int* src2_row,
int src2_num,
291 int* num_1,
int* num_2,
int* num_mix);
292 void mix_column(
const double* src1_data,
const int* src1_row,
int src1_num,
293 const double* src2_data,
const int* src2_row,
int src2_num,
294 double* dst_data,
int* dst_row,
int* dst_num);
329 return (
"GMatrixSparse");
virtual double & operator()(const int &row, const int &column)
Return reference to matrix element.
virtual GMatrixSparse & operator=(const GMatrixSparse &matrix)
Matrix assignment operator.
GArf operator/(const GArf &arf, const double &scale)
Auxiliary Response File vision operator friend.
void scale_elements(const double &scalar)
Scale all matrix elements with a scalar.
virtual double max(void) const
Return maximum matrix element.
Abstract matrix base class interface definition.
int get_index(const int &row, const int &column) const
Determines element index for (row,column)
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
int m_fill_col
Column into which element needs to be filled.
void stack_destroy(void)
Destroy matrix stack.
const int & size(void) const
Return number of matrix elements.
GMatrixSparse cholesky_invert(const bool &compress=true) const
Invert matrix using a Cholesky decomposition.
Sparse matrix class interface definition.
virtual double fill(void) const
Returns fill of matrix.
void remove_zero_row_col(void)
Remove rows and columns with zeros.
void insert_zero_row_col(const int &rows, const int &cols)
Insert zero rows and columns.
virtual GMatrixSparse * clone(void) const
Clone matrix.
virtual GMatrixSparse & operator*=(const GMatrixSparse &matrix)
Unary matrix multiplication operator.
Symmetric matrix class interface definition.
virtual ~GMatrixSparse(void)
Destructor.
GMatrixSparse invert(void) const
Return inverted matrix.
virtual double & at(const int &row, const int &column)
Return reference to matrix element.
GMatrixSparse(void)
Void matrix constructor.
virtual void clear(void)
Clear matrix.
int m_stack_max_entries
Maximum number of entries in the stack.
int * m_stack_work
Stack flush integer working array [m_cols].
GMatrixSparse transpose(void) const
Return transposed matrix.
virtual void add_to_column(const int &column, const GVector &vector)
Add vector column into matrix.
Sparse matrix symbolic analysis class.
void insert_row(const int &row, const GVector &vector, const bool &add)
Insert row in matrix.
GVector solve(const GVector &vector) const
Solves linear matrix equation.
int * m_stack_rowinx
Stack row indices [m_stack_size].
void stack_flush(void)
Flush matrix stack.
Abstract matrix base class definition.
const int & rows(void) const
Return number of matrix rows.
int * m_stack_colinx
Column index for each entry [m_stack_entries].
GMatrixSparse abs(void) const
Return absolute of matrix.
virtual GMatrixSparse & operator-=(const GMatrixSparse &matrix)
Unary matrix subtraction operator.
void free_elements(const int &start, const int &num)
Free memory for obsolete matrix elements.
virtual double sum(void) const
Sum matrix elements.
double * m_stack_data
Stack data [m_stack_size].
void set_mem_block(const int &block)
Set memory block size.
friend GMatrixSparse cs_symperm(const GMatrixSparse &matrix, const int *pinv)
cs_symperm
virtual std::string classname(void) const
Return class name.
void free_stack_members(void)
Delete fill-stack class members.
void init_stack_members(void)
Initialise fill stack.
int * m_rowinx
Row-indices of all elements.
virtual void add_to_row(const int &row, const GVector &vector)
Add row to matrix elements.
GArf operator*(const GArf &arf, const double &scale)
Auxiliary Response File scaling operator friend.
Sparse matrix numeric analysis class.
int m_stack_entries
Number of entries in the stack.
int * m_stack_start
Start in stack for each entry [m_stack_entries+1].
void copy_members(const GMatrixSparse &m)
Copy class members.
void fill_pending(void)
Fills pending matrix element.
virtual GMatrixSparse operator+(const GMatrixSparse &matrix) const
Binary matrix addition.
virtual GVector row(const int &row) const
Extract row as vector from matrix.
GSparseSymbolic * m_symbolic
Holds GSparseSymbolic object after decomposition.
double m_fill_val
Element to be filled.
virtual double min(void) const
Return minimum matrix element.
virtual GMatrixSparse operator-(void) const
Negate matrix elements.
void mix_column_prepare(const int *src1_row, int src1_num, const int *src2_row, int src2_num, int *num_1, int *num_2, int *num_mix)
Prepare mix of sparse columns.
virtual GVector column(const int &column) const
Extract column as vector from matrix.
virtual bool operator==(const GMatrixSparse &matrix) const
Equalty operator.
GVector cholesky_solver(const GVector &vector, const bool &compress=true) const
Cholesky solver.
friend GMatrixSparse cs_transpose(const GMatrixSparse &matrix, int values)
int * m_stack_rows
Stack push integer working array [m_cols].
int m_fill_row
Row into which element needs to be filled.
void stack_init(const int &size=0, const int &entries=0)
Initialises matrix filling stack.
void init_members(void)
Initialise class mambers.
friend double cs_cumsum(int *p, int *c, int n)
cs_cumsum
Generic matrix class definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print matrix.
virtual GVector operator*(const GVector &vector) const
Vector multiplication.
void alloc_members(const int &rows, const int &cols, const int &elements=0)
Allocate matrix.
GSparseNumeric * m_numeric
Holds GSparseNumeric object after decomposition.
virtual GMatrixSparse & operator+=(const GMatrixSparse &matrix)
Unary matrix addition operator.
int m_mem_block
Memory block to be allocated at once.
const int & columns(void) const
Return number of matrix columns.
GMatrixSparse cholesky_decompose(const bool &compress=true) const
Return Cholesky decomposition.
int m_stack_size
Maximum number of elements in the stack.
virtual GMatrixSparse & operator/=(const double &scalar)
Divide matrix elements.
virtual bool operator!=(const GMatrixSparse &matrix) const
Non-equality operator.
double m_zero
The zero element (needed for data access)
void alloc_elements(int start, const int &num)
Allocate memory for new matrix elements.
double * m_stack_values
Stack push double buffer [m_cols].
void mix_column(const double *src1_data, const int *src1_row, int src1_num, const double *src2_data, const int *src2_row, int src2_num, double *dst_data, int *dst_row, int *dst_num)
Mix of sparse columns.
void free_members(void)
Delete class members.
int stack_push_column(const GVector &vector, const int &col)
Push a vector column on the matrix stack.