C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
cxsc::scimatrix Class Reference

A sparse complex interval matrix. More...

#include <scimatrix.hpp>

List of all members.

Public Member Functions

std::vector< int > & column_pointers ()
 Returns a reference to the vector containing the column pointers (the $ p $ array)
const std::vector< int > & column_pointers () const
 Returns a constant reference to the vector containing the column pointers (the $ p $ array)
real density () const
 Returns the density (the number of non-zeros divided by the number of elements) of the matrix.
void dropzeros ()
 Drops explicitly stored zeros from the data structure.
cintervalelement (int i, int j)
 Returns a reference to the element (i,j) of the matrix.
void full (cimatrix &A) const
 Creates a full matrix out of the sparse matrix and stores it in A. This should normally be done using the respective constructor of the dense matrix.
int get_nnz () const
 Returns the number of non-zero entries (including explicitly stored zeros).
scimatrixoperator&= (const imatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator&= (const cimatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator&= (const imatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator&= (const cimatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator&= (const simatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator&= (const scimatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
const cinterval operator() (int i, int j) const
 Returns a copy of the element in row i and column j.
scimatrix_slice operator() (const int, const int, const int, const int)
 Returns a slice of the matrix.
const scimatrix_slice operator() (const int, const int, const int, const int) const
 Returns a slice of the matrix.
scimatrix operator() (const intvector &pervec, const intvector &q)
 Performs a row and column permutation using two permutation vectors.
scimatrix operator() (const intvector &pervec)
 Performs a row permutation using a permutation vector.
scimatrix operator() (const intmatrix &P, const intmatrix &Q)
 Performs row and column permutations using the two permutation matrices P and Q. Faster than explicitly computing the product.
scimatrix operator() (const intmatrix &P)
 Performs a row permutation using the permutation matrix P. Faster than explicitly computing the product.
scimatrixoperator*= (const cmatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const rmatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const imatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const cimatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const rmatrix_slice &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const cmatrix_slice &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const imatrix_slice &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const cimatrix_slice &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const srmatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const scmatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const simatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const scimatrix &B)
 Multiply the sparse matrix by B and assign the result to it.
scimatrixoperator*= (const real &r)
 Multiply all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator*= (const complex &r)
 Multiply all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator*= (const interval &r)
 Multiply all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator*= (const cinterval &r)
 Multiply all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator+= (const rmatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const cmatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const imatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const cimatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const rmatrix_slice &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const cmatrix_slice &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const imatrix_slice &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const cimatrix_slice &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const srmatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const scmatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const simatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator+= (const scimatrix &B)
 Add B to the sparse matrix and assign the result to it.
scimatrixoperator-= (const rmatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const cmatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const imatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const cimatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const rmatrix_slice &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const cmatrix_slice &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const imatrix_slice &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const cimatrix_slice &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const srmatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const scmatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const simatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator-= (const scimatrix &B)
 Subtract B from the sparse matrix and assign the result to it.
scimatrixoperator/= (const real &r)
 Divide all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator/= (const complex &r)
 Divide all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator/= (const interval &r)
 Divide all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator/= (const cinterval &r)
 Divide all elements of the sparse matrix by r and assign the result to it.
scimatrixoperator= (const real &A)
 Assigns a real value to all elements of the matrix (resulting in a dense matrix!)
scimatrixoperator= (const interval &A)
 Assigns an interval value to all elements of the matrix (resulting in a dense matrix!)
scimatrixoperator= (const complex &A)
 Assigns a complex value to all elements of the matrix (resulting in a dense matrix!)
scimatrixoperator= (const cinterval &A)
 Assigns a complex interval value to all elements of the matrix (resulting in a dense matrix!)
scimatrixoperator= (const rmatrix &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const cmatrix &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const imatrix &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const cimatrix &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const rmatrix_slice &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const cmatrix_slice &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const imatrix_slice &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const cimatrix_slice &A)
 Assigns a dense matrix to the sparse matrix. Only the non zero entries of the dense matrix are used.
scimatrixoperator= (const srmatrix &A)
 Assign a sparse real to a sparse complex interval matrix.
scimatrixoperator= (const scmatrix &A)
 Assign a sparse complex to a sparse complex interval matrix.
scimatrixoperator= (const simatrix &A)
 Assign a sparse complex to a sparse interval matrix.
scimatrixoperator= (const srmatrix_slice &)
 Assign a sparse matrix slice to a sparse matrix.
scimatrixoperator= (const scmatrix_slice &)
 Assign a sparse matrix slice to a sparse matrix.
scimatrixoperator= (const simatrix_slice &)
 Assign a sparse matrix slice to a sparse matrix.
scimatrixoperator= (const scimatrix_slice &)
 Assign a sparse matrix slice to a sparse matrix.
scimatrix_subv operator[] (const cxscmatrix_column &)
 Returns a column of the matrix as a sparse subvector object.
scimatrix_subv operator[] (const int)
 Returns a row of the matrix as a sparse subvector object.
const scimatrix_subv operator[] (const cxscmatrix_column &) const
 Returns a column of the matrix as a sparse subvector object.
const scimatrix_subv operator[] (const int) const
 Returns a row of the matrix as a sparse subvector object.
scimatrixoperator|= (const rmatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const cmatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const imatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const cimatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const rmatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const cmatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const imatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const cimatrix_slice &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const srmatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const scmatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const simatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
scimatrixoperator|= (const scimatrix &B)
 Form the convex hull of a sparse matrix and B and assign the result to it.
std::vector< int > & row_indices ()
 Returns a reference to the vector containing the row indices (the $ ind $ array)
const std::vector< int > & row_indices () const
 Returns a constant reference to the vector containing the row indices (the $ ind $ array)
 scimatrix ()
 Standard constructor, creates an empty matrix of dimension 0x0.
 scimatrix (const int r, const int c)
 Creates an empty matrix with r rows and c columns, pre-reserving space for 2*(r+c) elements.
 scimatrix (const int r, const int c, const int e)
 Creates an empty matrix with r rows and c columns, pre-reserving space for e elements.
 scimatrix (const int m, const int n, const int nnz, const intvector &rows, const intvector &cols, const civector &values, const enum STORAGE_TYPE t=triplet)
 Creates a sparse matrix out of three vectors (arrays) forming a matrix stored in triplet, compressed row or compressed column storage.
 scimatrix (const int m, const int n, const int nnz, const int *rows, const int *cols, const cinterval *values, const enum STORAGE_TYPE t=triplet)
 Creates a sparse matrix out of three arrays forming a matrix stored in triplet, compressed row or compressed column storage.
 scimatrix (const srmatrix &A)
 Creates a sparse interval matrix out of a sparse real matrix A.
 scimatrix (const scmatrix &A)
 Creates a sparse interval matrix out of a sparse complex matrix A.
 scimatrix (const simatrix &A)
 Creates a sparse interval matrix out of a sparse interval matrix A.
 scimatrix (const rmatrix &A)
 Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitly.
 scimatrix (const cmatrix &A)
 Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitly.
 scimatrix (const imatrix &A)
 Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitly.
 scimatrix (const cimatrix &A)
 Creates a sparse matrix out of a dense matrix A. Only the non zero elements of A are stored explicitly.
 scimatrix (const int ms, const int ns, const cimatrix &A)
 Constructor for banded matrices.
 scimatrix (const srmatrix_slice &)
 Creates a sparse matrix out of a sparse matrix slice.
 scimatrix (const scmatrix_slice &)
 Creates a sparse matrix out of a sparse matrix slice.
 scimatrix (const simatrix_slice &)
 Creates a sparse matrix out of a sparse matrix slice.
 scimatrix (const scimatrix_slice &)
 Creates a sparse matrix out of a sparse matrix slice.
std::vector< cinterval > & values ()
 Returns a reference to the vector containing the stored values (the $ x $ array)
const std::vector< cinterval > & values () const
 Returns a constant reference to the vector containing the stored values (the $ x $ array)

Friends

simatrix abs (const scimatrix &)
 Returns the componentwise absolute value of the matrix A.
int ColLen (const scimatrix &)
 Returns the number of rows of the matrix.
srmatrix CompMat (const scimatrix &)
 Returns Ostroswkis comparison matrix for A.
scimatrix conj (const scimatrix &)
 Returns the conjugate complex of the matrix A.
scmatrix diam (const scimatrix &)
 Returns the componentwise diameter of the matrix A.
scimatrix Id (const scimatrix &)
 Return a sparse unity matrix of the same dimension as A.
simatrix Im (const scimatrix &)
 Returns the imaginary part of the matrix A.
scmatrix Inf (const scimatrix &)
 Returns the Infimum of the matrix A.
srmatrix InfIm (const scimatrix &)
 Returns the imaginary part of the infimum of the matrix A.
srmatrix InfRe (const scimatrix &)
 Returns the real part of the infimum of the matrix A.
int Lb (const scimatrix &, int)
 Returns the lower index bound for the rows or columns of A.
scmatrix mid (const scimatrix &)
 Returns the componentwise midpoint of the matrix A.
std::istream & operator>> (std::istream &, scimatrix_slice &)
 Standard input operator for sparse matrix slice.
std::istream & operator>> (std::istream &, scimatrix_subv &)
 Standard input operator for subvectors.
simatrix Re (const scimatrix &)
 Returns the real part of the matrix A.
int RowLen (const scimatrix &)
 Returns the number of columns of the matrix.
void SetLb (scimatrix &, const int, const int)
 Sets the lower index bound of the rows (i==ROW) or columns (i==COL) to j.
void SetUb (scimatrix &, const int, const int)
 Sets the upper index bound of the rows (i==ROW) or columns (i==COL) to j.
scmatrix Sup (const scimatrix &)
 Returns the Supremum of the matrix A.
srmatrix SupIm (const scimatrix &)
 Returns the imaginary part of the supremum of the matrix A.
srmatrix SupRe (const scimatrix &)
 Returns the real part of the supremum of the matrix A.
scimatrix transp (const scimatrix &)
 Returns the transpose of A.
int Ub (const scimatrix &, int)
 Returns the upper index bound for the rows or columns of A.

Detailed Description

A sparse complex interval matrix.

Sparse matrices in C-XSC are stored in the Compressed Column Storage (CCS) format. The non zero entries of the matrix are stored in three arrays (STL-vectors) $ p $, $ ind $, $ x $. The array $ ind $ stores the row indices of the non zero elements, the array $ x $ the respective values (the $ i $-th element of $ ind $ corresponds to the i-th element of $ x $, $ i=0,\ldots,nnz-1 $, where $ nnz $ is the number of non zeros. The entries are sorted by column. The array $ p $ of size $ n+1 $ stores the starting indices for the entries of each column of the matrix, so that the entries of the $ j $-th column of the matrix are stored in the elements with index $ p[j] $ through $ p[j+1]-1 $ of the arrays $ x $ and $ ind $. The elements of each column are stored as sorted by the row indices, explicitly stored zeros are allowed.

The internal data structure uses 0-based indexing throughout. However, in the interface to the user (using the respective operators) every matrix possesses a lower and an upper row index bound $ lb_1 $, $ ub_1 $ and a lower and an upper column index bound $ lb_2 $, $ ub_2 $ of type int. By default, these indexes are 1-based.

It is possible to directly access the internal data structure through the appropriate member function to allow for easier interfacing with other sparse matrix libraries and writing of more efficient sparse matrix algorithms. In this case, the user has to take care that the data structure remains consistent with the format described above. If the user just works with the operators and functions provided by C-XSC, everything will be handled automatically by the C-XSC library.

All matrix and vector operators which require dot product computations use higher precision dot products provided by the dotprecision classes. The precision to be used for these implicit dot products can be choosen by setting the global variable opdotprec accordingly. A value of 0 means maximum accuracy (the default, always used by all older C-XSC versions), a value of 1 means double accuracy, a value of 2 or higher means k-fold double accuracy. Lower accuracy leads to (significantly) faster computing times, but also to less exact results. For all dot products with an interval result, error bounds are computed to guarantee a correct enclosure. For all other dot products approximations without error bounds are computed.

See also:
cxsc::dotprecision

Definition at line 71 of file scimatrix.hpp.


Constructor & Destructor Documentation

cxsc::scimatrix::scimatrix ( const int  m,
const int  n,
const int  nnz,
const intvector rows,
const intvector cols,
const civector values,
const enum STORAGE_TYPE  t = triplet 
) [inline]

Creates a sparse matrix out of three vectors (arrays) forming a matrix stored in triplet, compressed row or compressed column storage.

Creates a sparse matrix of dimension $ m \times n $ with the values from the three arrays rows, cols and values. These are interpreted according to the storage type t. For triplet rows and cols contains the indices of all non zero values and the array values contains the actual values. For compressed_column, the arrays are interpreted according to the compressed column storage format, where cols contains the column pointers. For compressed_row the arrays are interpreted according to the compressed row storage format, which is equivalent to compressed column storage with the role of the rows and columns interchanged.

In each case the arrays need not be sorted by rows or columns and may contain explicit zero entries.

Definition at line 145 of file scimatrix.hpp.

cxsc::scimatrix::scimatrix ( const int  m,
const int  n,
const int  nnz,
const int *  rows,
const int *  cols,
const cinterval values,
const enum STORAGE_TYPE  t = triplet 
) [inline]

Creates a sparse matrix out of three arrays forming a matrix stored in triplet, compressed row or compressed column storage.

Creates a sparse matrix of dimension $ m \times n $ with the values from the three arrays rows, cols and values. These are interpreted according to the storage type t. For triplet rows and cols contains the indices of all non zero values and the array values contains the actual values. For compressed_column, the arrays are interpreted according to the compressed column storage format, where cols contains the column pointers. For compressed_row the arrays are interpreted according to the compressed row storage format, which is equivalent to compressed column storage with the role of the rows and columns interchanged.

In each case the arrays need not be sorted by rows or columns and may contain explicit zero entries.

Definition at line 256 of file scimatrix.hpp.

cxsc::scimatrix::scimatrix ( const int  ms,
const int  ns,
const cimatrix A 
) [inline]

Constructor for banded matrices.

Creates a sparse banded matrix of dimension $ ms \times ns $, whose bands are defined by the columns of the dense matrix A. The column inde range of A must be set appropriately: The columns of with negative indices are used for bands below the diagonal, the column with index 0 is used for the diagonal, and columns with positive index are use for bands above the diagonal.

Definition at line 476 of file scimatrix.hpp.


Member Function Documentation

void cxsc::scimatrix::dropzeros ( ) [inline]

Drops explicitly stored zeros from the data structure.

Dropping explicit zero entries can be essential when interfacing with other sparse matrix libraries. Some librares using the CCS storage format do not allow explicitly stored zeros.

Definition at line 537 of file scimatrix.hpp.

cinterval& cxsc::scimatrix::element ( int  i,
int  j 
) [inline]

Returns a reference to the element (i,j) of the matrix.

This function should only be used for write access. The indices i and j must be used according to the current index range of the matrix. A reference to the element (i,j) is returned. If the element is not stored explicitly, it is created as an explicit 0 entry. For read access to a single element, the ()-opeator should be used.

This function is faster than using the []-operator (for example A[i][j]), since it does not need to create a temporary subvector first.

Note that due to the underlying data structure the access to single elements of a sparse matrix is much more expensive than to the elements of a dense matrix.

Definition at line 703 of file scimatrix.hpp.

Referenced by cxsc::scimatrix_slice::element().

const cinterval cxsc::scimatrix::operator() ( int  i,
int  j 
) const [inline]

Returns a copy of the element in row i and column j.

This operator can be used for read access only. The indices i and j must be used according to the current index range of the matrix. A copy of the element (i,j) is returned, or 0 if this element is not explicitly stored. For write access to a single element, the []-opeator or the member function element should be used.

Note that due to the underlying data structure the access to single elements of a sparse matrix is much more expensive than to the elements of a dense matrix.

Definition at line 682 of file scimatrix.hpp.


Friends And Related Function Documentation

int Lb ( const scimatrix A,
int  i 
) [friend]

Returns the lower index bound for the rows or columns of A.

If i==ROW, the lower index bound for the rows is returned, if i==COL, the lower index bound for the columns is returned.

Definition at line 1335 of file scimatrix.hpp.

Referenced by operator()(), and scimatrix().

std::istream& operator>> ( std::istream &  is,
scimatrix_slice M 
) [friend]

Standard input operator for sparse matrix slice.

The input format is set by global flags, default is dense input. Use cout << SparseInOut; for sparse input or cout << MatrixMarketInOut; for input in matrix market format.

Definition at line 9614 of file scimatrix.hpp.

void SetLb ( scimatrix A,
const int  i,
const int  j 
) [friend]

Sets the lower index bound of the rows (i==ROW) or columns (i==COL) to j.

If i==ROW, the lower index bound for the rows of A ist set to j. if i==COL, the lower index bound of the columns is set to j. The upper index bound is automatically set according to the number of rows or columns of the matrix.

Definition at line 1306 of file scimatrix.hpp.

void SetUb ( scimatrix A,
const int  i,
const int  j 
) [friend]

Sets the upper index bound of the rows (i==ROW) or columns (i==COL) to j.

If i==ROW, the upper index bound for the rows of A ist set to j. if i==COL, the upper index bound of the columns is set to j. The lower index bound is automatically set according to the number of rows or columns of the matrix.

Definition at line 1321 of file scimatrix.hpp.

int Ub ( const scimatrix A,
int  i 
) [friend]

Returns the upper index bound for the rows or columns of A.

If i==COL, the upper index bound for the rows is returned, if i==COL, the upper index bound for the columns is returned.

Definition at line 1348 of file scimatrix.hpp.

Referenced by scimatrix().


The documentation for this class was generated from the following files: