ARTS  2.2.66
matpackII.cc File Reference

Implementation of sparse matrices. More...

#include <algorithm>
#include <set>
#include <iostream>
#include <cmath>
#include <iterator>
#include "matpackII.h"
Include dependency graph for matpackII.cc:

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const Sparse &v)
 Output operator for Sparse. More...
 
void abs (Sparse &A, const Sparse &B)
 Absolute value of sparse matrix elements. More...
 
void mult (VectorView y, const Sparse &M, ConstVectorView x)
 Sparse matrix - Vector multiplication. More...
 
void mult (MatrixView A, const Sparse &B, ConstMatrixView C)
 SparseMatrix - Matrix multiplication. More...
 
void transpose (Sparse &A, const Sparse &B)
 Transpose of sparse matrix. More...
 
void mult (Sparse &A, const Sparse &B, const Sparse &C)
 Sparse - Sparse multiplication. More...
 
void add (Sparse &A, const Sparse &B, const Sparse &C)
 Sparse - Sparse addition. More...
 
void sub (Sparse &A, const Sparse &B, const Sparse &C)
 Sparse - Sparse subtraction. More...
 

Detailed Description

Implementation of sparse matrices.

Author
Stefan Buehler sbueh.nosp@m.ler@.nosp@m.ltu.s.nosp@m.e
Date
Tue Jul 15 15:05:40 2003

Notes:

There are two different ways to index: S.rw(3,4) = 1; // Read and write cout << S.ro(3,4); // Read only

This distinction is necessary, because rw() creates elements if they don't already exist.

The normal index operator "()" correspondes to ro, so "S(3,4)" is the same as S.ro(3,4).

Definition in file matpackII.cc.

Function Documentation

◆ abs()

void abs ( Sparse A,
const Sparse B 
)

Absolute value of sparse matrix elements.

Computes the absolute values of the elements in sparse matrix B.

The output matrix A must have been initialized with the correct size.

Parameters
AOutput: Absolute value matrix.
BOriginal matrix.
Author
Mattias Ekstrom
Date
2005-03-21

Definition at line 537 of file matpackII.cc.

References copy(), Sparse::mcolptr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), and Sparse::nrows().

◆ add()

void add ( Sparse A,
const Sparse B,
const Sparse C 
)

Sparse - Sparse addition.

Calculates A = B+C, where result A is sparse, and B and C are also sparse.

Output comes first!

Dimensions of B, and C must match. A will be resized.

Parameters
AOutput: Result matrix.
BFirst summand matrix.
CSecond summand matrix.
Author
Oliver Lemke
Date
2009-09-03

Definition at line 871 of file matpackII.cc.

References C, Sparse::data(), Sparse::mcolptr, Sparse::ncols(), Sparse::nrows(), and Sparse::rw().

Referenced by test49().

◆ mult() [1/3]

void mult ( VectorView  y,
const Sparse M,
ConstVectorView  x 
)

Sparse matrix - Vector multiplication.

This calculates the product

y = M*x, where M is sparse.

Output comes first!

Dimensions of y, M, and x must match. No memory reallocation takes place, only the data is copied.

Parameters
yOutput: The multiplication result.
MMatrix for multiplication (sparse).
xVector for multiplication.
Author
Stefan Buehler sbueh.nosp@m.ler@.nosp@m.ltu.s.nosp@m.e
Date
Tue Jul 15 15:05:40 2003

Definition at line 579 of file matpackII.cc.

References Sparse::mcolptr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), ConstVectorView::nelem(), and Sparse::nrows().

◆ mult() [2/3]

void mult ( MatrixView  A,
const Sparse B,
ConstMatrixView  C 
)

SparseMatrix - Matrix multiplication.

Calculates the matrix product:

A = B*C, where B is sparse.

Output comes first!

Dimensions of A, B, and C must match. No memory reallocation takes place, only the data is copied.

Parameters
AOutput: Result matrix (full).
BFirst matrix to multiply (sparse).
CSecond matrix to multiply (full).
Author
Stefan Buehler sbueh.nosp@m.ler@.nosp@m.ltu.s.nosp@m.e
Date
Tue Jul 15 15:05:40 2003

Definition at line 633 of file matpackII.cc.

References C, Sparse::mcolptr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), ConstMatrixView::ncols(), Sparse::nrows(), and ConstMatrixView::nrows().

◆ mult() [3/3]

void mult ( Sparse A,
const Sparse B,
const Sparse C 
)

Sparse - Sparse multiplication.

Calculates A = B*C, where result A is sparse, and B and C are also sparse.

Output comes first!

Dimensions of A, B, and C must match. No memory reallocation takes place, only the data is copied.

Parameters
AOutput: Result matrix.
BFirst product matrix.
CSecond product matrix.
Author
Mattias Ekstroem
Date
2003-08-06

Definition at line 780 of file matpackII.cc.

References Sparse::mcolptr, Sparse::mcr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), Sparse::nrows(), Sparse::rw(), and Sparse::transpose.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const Sparse v 
)

Output operator for Sparse.

Parameters
osOutput stream.
vSparse matrix to print.
Returns
Output stream.
Author
Stefan Buehler sbueh.nosp@m.ler@.nosp@m.ltu.s.nosp@m.e
Date
Tue Jul 15 15:05:40 2003

Definition at line 495 of file matpackII.cc.

References Sparse::mcolptr, Sparse::mdata, and Sparse::mrowind.

◆ sub()

void sub ( Sparse A,
const Sparse B,
const Sparse C 
)

Sparse - Sparse subtraction.

Calculates A = B-C, where result A is sparse, and B and C are also sparse.

Output comes first!

Dimensions of B, and C must match. A will be resized.

Parameters
AOutput: Result matrix.
BFirst subtrahend matrix.
CSecond subtrahend matrix.
Author
Oliver Lemke
Date
2009-09-03

Definition at line 920 of file matpackII.cc.

References Sparse::mcolptr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), Sparse::nrows(), and Sparse::rw().

Referenced by sensor_responseBackendFrequencySwitching(), and test49().

◆ transpose()

void transpose ( Sparse A,
const Sparse B 
)

Transpose of sparse matrix.

Computes the transpose of the sparse matrix B.

The output matrix A must have been initialized with the correct size.

Parameters
AOutput: Transposed matrix.
BOriginal matrix.
Author
Mattias Ekstroem
Date
2003-08-05

Definition at line 689 of file matpackII.cc.

References Sparse::mcolptr, Sparse::mcr, Sparse::mdata, Sparse::mrowind, Sparse::ncols(), and Sparse::nrows().