Loading...
Searching...
No Matches
dolfin::Matrix Class Reference

`#include <Matrix.h>`

Inheritance diagram for dolfin::Matrix:
[legend]
Collaboration diagram for dolfin::Matrix:
[legend]

## Public Member Functions

| Matrix ()
| Create empty matrix.
| Matrix (MPI_Comm comm)
| Create empty matrix.
| Matrix (const Matrix &A)
| Copy constructor.
| Matrix (const GenericMatrix &A)
| Create a Vector from a GenericVector.
virtual | ~Matrix ()
| Destructor.
virtual void | init (const TensorLayout &tensor_layout)
| Initialize zero tensor using tensor layout.
virtual bool | empty () const
| Return true if matrix is empty.
virtual std::size_t | size (std::size_t dim) const
| Return size of given dimension.
virtual std::pair< std::int64_t, std::int64_t > | local_range (std::size_t dim) const
| Return local ownership range.
virtual std::size_t | nnz () const
| Return number of non-zero entries in matrix (collective).
virtual void | zero ()
| Set all entries to zero and keep any sparse structure.
virtual void | apply (std::string mode)
| Finalize assembly of tensor.
MPI_Comm | mpi_comm () const
| Return MPI communicator.
virtual std::string | str (bool verbose) const
| Return informal string representation (pretty-print).
virtual std::shared_ptr< GenericMatrix > | copy () const
| Return copy of matrix.
virtual void | init_vector (GenericVector &y, std::size_t dim) const
virtual void | get (double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const
| Get block of values.
virtual void | set (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Set block of values using global indices.
virtual void | set_local (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Set block of values using local indices.
virtual void | add (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Add block of values using global indices.
virtual void | add_local (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Add block of values using local indices.
virtual void | axpy (double a, const GenericMatrix &A, bool same_nonzero_pattern)
| Add multiple of given matrix (AXPY operation).
virtual double | norm (std::string norm_type) const
| Return norm of matrix.
virtual void | getrow (std::size_t row, std::vector< std::size_t > &columns, std::vector< double > &values) const
| Get non-zero values of given row.
virtual void | setrow (std::size_t row, const std::vector< std::size_t > &columns, const std::vector< double > &values)
| Set values for given row.
virtual void | zero (std::size_t m, const dolfin::la_index *rows)
| Set given rows to zero.
virtual void | zero_local (std::size_t m, const dolfin::la_index *rows)
| Set given rows (local row indices) to zero.
virtual void | ident (std::size_t m, const dolfin::la_index *rows)
| Set given rows (global row indices) to identity matrix.
virtual void | ident_local (std::size_t m, const dolfin::la_index *rows)
| Set given rows (local row indices) to identity matrix.
virtual void | mult (const GenericVector &x, GenericVector &y) const
| Compute matrix-vector product y = Ax.
virtual void | transpmult (const GenericVector &x, GenericVector &y) const
virtual void | get_diagonal (GenericVector &x) const
| Get diagonal of a matrix.
virtual void | set_diagonal (const GenericVector &x)
| Set diagonal of a matrix.
virtual const Matrix & | operator*= (double a)
| Multiply matrix by given number.
virtual const Matrix & | operator/= (double a)
| Divide matrix by given number.
virtual const GenericMatrix & | operator= (const GenericMatrix &A)
| Assignment operator.
virtual bool | is_symmetric (double tol) const
| Test if matrix is symmetric.
virtual GenericLinearAlgebraFactory & | factory () const
| Return linear algebra backend factory.
virtual const GenericMatrix * | instance () const
| Return concrete instance / unwrap (const version).
virtual GenericMatrix * | instance ()
| Return concrete instance / unwrap (non-const version).
virtual std::shared_ptr< const LinearAlgebraObject > | shared_instance () const
| Return concrete shared ptr instance / unwrap (const version).
virtual std::shared_ptr< LinearAlgebraObject > | shared_instance ()
| Return concrete shared ptr instance / unwrap (non-const version).
const Matrix & | operator= (const Matrix &A)
| Assignment operator.
Public Member Functions inherited from dolfin::GenericMatrix
virtual | ~GenericMatrix ()
| Destructor.
virtual std::size_t | rank () const
| Return tensor rank (number of dimensions).
virtual void | get (double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const
| Get block of values.
virtual void | set (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using global indices.
virtual void | set_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using local indices.
virtual void | add (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using local indices.
virtual void | add (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using local indices.
const GenericMatrix & | operator+= (const GenericMatrix &A)
| Add given matrix.
const GenericMatrix & | operator-= (const GenericMatrix &A)
| Subtract given matrix.
virtual double | operator() (dolfin::la_index i, dolfin::la_index j) const
| Get value of given entry.
virtual double | getitem (std::pair< dolfin::la_index, dolfin::la_index > ij) const
| Get value of given entry.
virtual void | setitem (std::pair< dolfin::la_index, dolfin::la_index > ij, double value)
virtual void | ident_zeros (double tol=DOLFIN_EPS)
| Insert one on the diagonal for all zero rows.
Public Member Functions inherited from dolfin::GenericTensor
virtual | ~GenericTensor ()
| Destructor.
Public Member Functions inherited from dolfin::Variable
| Variable ()
| Create unnamed variable.
| Variable (const std::string name, const std::string label)
| Create variable with given name and label.
| Variable (const Variable &variable)
| Copy constructor.
virtual | ~Variable ()
| Destructor.
const Variable & | operator= (const Variable &variable)
| Assignment operator.
void | rename (const std::string name, const std::string label)
| Rename variable.
std::string | name () const
| Return name.
std::string | label () const
| Return label (description).
std::size_t | id () const

## Additional Inherited Members

Public Attributes inherited from dolfin::Variable
Parameters | parameters
| Parameters.
Protected Member Functions inherited from dolfin::GenericLinearOperator
virtual void | init_layout (const GenericVector &x, const GenericVector &y, GenericLinearOperator *wrapper)

## Detailed Description

This class provides the default DOLFIN matrix class, based on the default DOLFIN linear algebra backend.

## Member Function Documentation

## add()

virtual void dolfin::Matrix::add | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

inline virtual

Add block of values using global indices.

Implements dolfin::GenericMatrix.

## add_local()

virtual void dolfin::Matrix::add_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

inline virtual

Add block of values using local indices.

Implements dolfin::GenericMatrix.

## apply()

virtual void dolfin::Matrix::apply | ( | std::string | mode | ) |

inline virtual

Finalize assembly of tensor.

Implements dolfin::GenericMatrix.

## axpy()

virtual void dolfin::Matrix::axpy | ( | double | a,
|  | const GenericMatrix & | A,
|  | bool | same_nonzero_pattern )

inline virtual

Add multiple of given matrix (AXPY operation).

Implements dolfin::GenericMatrix.

## copy()

virtual std::shared_ptr< GenericMatrix > dolfin::Matrix::copy | ( |  | ) | const

inline virtual

Return copy of matrix.

Implements dolfin::GenericMatrix.

## empty()

virtual bool dolfin::Matrix::empty | ( |  | ) | const

inline virtual

Return true if matrix is empty.

Implements dolfin::GenericTensor.

## factory()

virtual GenericLinearAlgebraFactory & dolfin::Matrix::factory | ( |  | ) | const

inline virtual

Return linear algebra backend factory.

Implements dolfin::GenericTensor.

## get()

virtual void dolfin::Matrix::get | ( | double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols ) const

inline virtual

Get block of values.

Implements dolfin::GenericMatrix.

## get_diagonal()

virtual void dolfin::Matrix::get_diagonal | ( | GenericVector & | x | ) | const

inline virtual

Get diagonal of a matrix.

Implements dolfin::GenericMatrix.

## getrow()

virtual void dolfin::Matrix::getrow | ( | std::size_t | row,
|  | std::vector< std::size_t > & | columns,
|  | std::vector< double > & | values ) const

inline virtual

Get non-zero values of given row.

Implements dolfin::GenericMatrix.

## ident()

virtual void dolfin::Matrix::ident | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

inline virtual

Set given rows (global row indices) to identity matrix.

Implements dolfin::GenericMatrix.

## ident_local()

virtual void dolfin::Matrix::ident_local | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

inline virtual

Set given rows (local row indices) to identity matrix.

Implements dolfin::GenericMatrix.

## init()

virtual void dolfin::Matrix::init | ( | const TensorLayout & | tensor_layout | ) |

inline virtual

Initialize zero tensor using tensor layout.

Implements dolfin::GenericTensor.

## init_vector()

virtual void dolfin::Matrix::init_vector | ( | GenericVector & | y,
|  | std::size_t | dim ) const

inline virtual

Resize vector y such that is it compatible with matrix for multiplication Ax = b (dim = 0 -> b, dim = 1 -> x) In parallel case, size and layout are important.

Implements dolfin::GenericMatrix.

## instance() [1/2]

virtual GenericMatrix * dolfin::Matrix::instance | ( |  | ) |

inline virtual

Return concrete instance / unwrap (non-const version).

Reimplemented from dolfin::LinearAlgebraObject.

## instance() [2/2]

virtual const GenericMatrix * dolfin::Matrix::instance | ( |  | ) | const

inline virtual

Return concrete instance / unwrap (const version).

Reimplemented from dolfin::LinearAlgebraObject.

## is_symmetric()

virtual bool dolfin::Matrix::is_symmetric | ( | double | tol | ) | const

inline virtual

Test if matrix is symmetric.

Reimplemented from dolfin::GenericMatrix.

## local_range()

virtual std::pair< std::int64_t, std::int64_t > dolfin::Matrix::local_range | ( | std::size_t | dim | ) | const

inline virtual

Return local ownership range.

Implements dolfin::GenericMatrix.

## mpi_comm()

MPI_Comm dolfin::Matrix::mpi_comm | ( |  | ) | const

inline virtual

Return MPI communicator.

Implements dolfin::LinearAlgebraObject.

## mult()

virtual void dolfin::Matrix::mult | ( | const GenericVector & | x,
|  | GenericVector & | y ) const

inline virtual

Compute matrix-vector product y = Ax.

Implements dolfin::GenericLinearOperator.

## nnz()

virtual std::size_t dolfin::Matrix::nnz | ( |  | ) | const

inline virtual

Return number of non-zero entries in matrix (collective).

Implements dolfin::GenericMatrix.

## norm()

virtual double dolfin::Matrix::norm | ( | std::string | norm_type | ) | const

inline virtual

Return norm of matrix.

Implements dolfin::GenericMatrix.

## operator*=()

virtual const Matrix & dolfin::Matrix::operator*= | ( | double | a | ) |

inline virtual

Multiply matrix by given number.

Implements dolfin::GenericMatrix.

## operator/=()

virtual const Matrix & dolfin::Matrix::operator/= | ( | double | a | ) |

inline virtual

Divide matrix by given number.

Implements dolfin::GenericMatrix.

## operator=()

virtual const GenericMatrix & dolfin::Matrix::operator= | ( | const GenericMatrix & | A | ) |

inline virtual

Assignment operator.

Implements dolfin::GenericMatrix.

## set()

virtual void dolfin::Matrix::set | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

inline virtual

Set block of values using global indices.

Implements dolfin::GenericMatrix.

## set_diagonal()

virtual void dolfin::Matrix::set_diagonal | ( | const GenericVector & | x | ) |

inline virtual

Set diagonal of a matrix.

Implements dolfin::GenericMatrix.

## set_local()

virtual void dolfin::Matrix::set_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

inline virtual

Set block of values using local indices.

Implements dolfin::GenericMatrix.

## setrow()

virtual void dolfin::Matrix::setrow | ( | std::size_t | row,
|  | const std::vector< std::size_t > & | columns,
|  | const std::vector< double > & | values )

inline virtual

Set values for given row.

Implements dolfin::GenericMatrix.

## shared_instance() [1/2]

virtual std::shared_ptr< LinearAlgebraObject > dolfin::Matrix::shared_instance | ( |  | ) |

inline virtual

Return concrete shared ptr instance / unwrap (non-const version).

Reimplemented from dolfin::LinearAlgebraObject.

## shared_instance() [2/2]

virtual std::shared_ptr< const LinearAlgebraObject > dolfin::Matrix::shared_instance | ( |  | ) | const

inline virtual

Return concrete shared ptr instance / unwrap (const version).

Reimplemented from dolfin::LinearAlgebraObject.

## size()

virtual std::size_t dolfin::Matrix::size | ( | std::size_t | dim | ) | const

inline virtual

Return size of given dimension.

Implements dolfin::GenericMatrix.

## str()

virtual std::string dolfin::Matrix::str | ( | bool | verbose | ) | const

inline virtual

Return informal string representation (pretty-print).

Implements dolfin::GenericMatrix.

## transpmult()

virtual void dolfin::Matrix::transpmult | ( | const GenericVector & | x,
|  | GenericVector & | y ) const

inline virtual

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Implements dolfin::GenericMatrix.

## zero() [1/2]

virtual void dolfin::Matrix::zero | ( |  | ) |

inline virtual

Set all entries to zero and keep any sparse structure.

Implements dolfin::GenericMatrix.

## zero() [2/2]

virtual void dolfin::Matrix::zero | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

inline virtual

Set given rows to zero.

Implements dolfin::GenericMatrix.

## zero_local()

virtual void dolfin::Matrix::zero_local | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

inline virtual

Set given rows (local row indices) to zero.

Implements dolfin::GenericMatrix.

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

- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/Matrix.h