H2Lib  3.0
sparsematrix.h
Go to the documentation of this file.
1 
2 /* ------------------------------------------------------------
3  * This is the file "sparsematrix.h" of the H2Lib package.
4  * All rights reserved, Steffen Boerm 2012
5  * ------------------------------------------------------------ */
6 
11 #ifndef SPARSEMATRIX_H
12 #define SPARSEMATRIX_H
13 
28 typedef struct _sparsematrix sparsematrix;
29 
32 
35 
36 #include "basic.h"
37 #include "avector.h"
38 #include "sparsepattern.h"
39 #include "krylov.h"
40 
42 struct _sparsematrix {
49 
57 };
58 
59 /* ------------------------------------------------------------ *
60  * Constructors and destructors *
61  * ------------------------------------------------------------ */
62 
74 
85 
95 
101 HEADER_PREFIX void
103 
104 /* ------------------------------------------------------------ *
105  * Access methods
106  * ------------------------------------------------------------ */
107 
120 
130 HEADER_PREFIX void
132 
133 /* ------------------------------------------------------------
134  * Statistics
135  * ------------------------------------------------------------ */
136 
144 HEADER_PREFIX size_t
146 
147 /* ------------------------------------------------------------
148  * Simple utility functions
149  * ------------------------------------------------------------ */
150 
161 HEADER_PREFIX void
163 
167 HEADER_PREFIX void
169 
173 HEADER_PREFIX void
175 
182 HEADER_PREFIX void
183 print_eps_sparsematrix(pcsparsematrix a, const char *filename, uint offset);
184 
185 /* ------------------------------------------------------------
186  * Basic linear algebra
187  * ------------------------------------------------------------ */
188 
200 HEADER_PREFIX void
202  pavector y);
203 
215 HEADER_PREFIX void
217  pavector y);
218 
231 HEADER_PREFIX void
233  pavector y);
234 
245 
258 
266 HEADER_PREFIX void
267 add_sparsematrix_amatrix(field alpha, bool atrans, pcsparsematrix a, pamatrix b);
268 
271 #endif
void addeval_sparsematrix_avector(field alpha, pcsparsematrix a, pcavector x, pavector y)
Multiply a matrix by a vector , .
void mvm_sparsematrix_avector(field alpha, bool trans, pcsparsematrix a, pcavector x, pavector y)
Multiply a matrix or its adjoint by a vector, or .
size_t getsize_sparsematrix(pcsparsematrix a)
Get size of a given sparsematrix object.
real norm2_sparsematrix(pcsparsematrix S)
Approximate the spectral norm of a matrix .
void clear_sparsematrix(psparsematrix a)
Set a matrix to zero.
Definition: avector.h:39
void add_sparsematrix_amatrix(field alpha, bool atrans, pcsparsematrix a, pamatrix b)
Add a sparsematrix to an amatrix, or .
uint nz
Number of non-zero entries.
Definition: sparsematrix.h:48
void del_sparsematrix(psparsematrix a)
Delete a sparsematrix object.
unsigned uint
Unsigned integer type.
Definition: settings.h:70
pfield coeff
Coefficients of non-zero entries.
Definition: sparsematrix.h:56
double _Complex field
Field type.
Definition: settings.h:171
void sort_sparsematrix(psparsematrix a)
Sort non-zero entries to ensure that diagonal entries come first.
const sparsematrix * pcsparsematrix
Pointer to constant sparsematrix object.
Definition: sparsematrix.h:34
sparsematrix * psparsematrix
Pointer to sparsematrix object.
Definition: sparsematrix.h:31
real norm2diff_sparsematrix(pcsparsematrix a, pcsparsematrix b)
Approximate the spectral norm of the difference of two matrices and .
void print_eps_sparsematrix(pcsparsematrix a, const char *filename, uint offset)
Print matrix to a Postscript file.
field addentry_sparsematrix(psparsematrix a, uint row, uint col, field x)
Add to a matrix entry, .
Representation of the sparsity pattern of a matrix.
Definition: sparsepattern.h:43
void print_sparsematrix(pcsparsematrix a)
Print a sparse matrix.
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
double real
real floating point type.
Definition: settings.h:97
psparsematrix new_raw_sparsematrix(uint rows, uint cols, uint nz)
Create a sparsematrix object without initializing its arrays.
void setentry_sparsematrix(psparsematrix a, uint row, uint col, field x)
Set a matrix entry, .
uint cols
Number of columns.
Definition: sparsematrix.h:46
uint * row
Starting indices for row representations in col and coeff.
Definition: sparsematrix.h:52
uint * col
Column indices of non-zero entries.
Definition: sparsematrix.h:54
field * pfield
Pointer to field array.
Definition: settings.h:185
Representation of a sparse matrix in compressed row format.
Definition: sparsematrix.h:42
Representation of a matrix as an array in column-major order.
Definition: amatrix.h:43
psparsematrix new_identity_sparsematrix(uint rows, uint cols)
Creates a new sparsematrix object and initializes it to the idenity matrix .
void addevaltrans_sparsematrix_avector(field alpha, pcsparsematrix a, pcavector x, pavector y)
Multiply the adjoint of a matrix by a vector , .
uint rows
Number of rows.
Definition: sparsematrix.h:44
psparsematrix new_zero_sparsematrix(psparsepattern sp)
Create a sparsematrix based on a sparsepattern.