csr(3)
NAME
csr - compressed sparse row matrix format
DESCRIPTION
- The class implements a matrix in compressed sparse row format.
A declaration whithout any parametrers correspond to a matrix with - null size:
csr<double> a;- Notes that the constructor can be invocated with an initializer:
csr<double> a = b;- Input and output, as usual
(see iorheo(3)):
cin >> a;
cout << a;- Default is the Harwell-Boeing format.
Various others formated options are available:
matlab and postscript plots. - Affectation from a scalar
a = 3.14;- The matrix/vector multiply:
a*x- and the transposed matrix/ vector multiply:
a.trans_mult(x);- The binary operators are:
a*b, a+b, a-b, lambda*a, a*lambda, a/lambda- The unary operators are sign inversion and transposition:
-a, trans(a);- The combination with a diagonal matrix
is not yet completely available.
The interface would be something like:
basic_diag<double> d;
a+d, d+a, a-d, d-a
a*d, d*a,
a/d // aij/djj
left_div(a,d) // aij/dii- When applied to the matrix directly:
this feature is not yet completely available.
The interface would be something like:
a += d; // a := a+d
a -= d; // a := a-d
a *= d; // a := a*d
a.left_mult(d); // a := d*a
a /= d; // aij := aij/djj
a.left_div(d); // aij := aij/dii- The combination with a constant-identity matrix:
this feature is not yet completely available.
The interface would be something like:
double k;
a + k*EYE, k*EYE + a, a - k*EYE, k*EYE - a,- a += e;
a -= e; - Get the lower triangular part:
csr<double> l = tril(a);- Conversely, triu get the upper triangular part.
- For optimizing the profile storage, I could be convenient to
use a renumbering algorithm
(see also ssk(3) and permutation(3)).
permutation p = gibbs(a);
csr<double> b = perm(a, p, q); // B := P*A*trans(Q)- Horizontal matrix concatenation: @tex $$ a = matrix{
- a_{11} & a_{12} } $$ @end tex
a = hcat(a11,a12);- Vertical matrix concatenation: @tex
$$ a=matrix{ - a_{11} a_{21} }
- $$ @end tex
a = vcat(a11,a21); - Explicit conversion from an associative asr e matrix writes:
a = csr<double>(e); - from a dense dns m matrix writes:
a = csr<double>(m);
NOTE
The csr class is currently under reconstruction for the distributed
memory support by using a MPI-based implementation.