Matrix Operations

It is possible to perform simple linear algebra routines:

/* Definition of the Matrix type */
using Matrix = danceq::internal::SparseMatrix<std::complex<double>>;


/* Creating and doing something with the Matrix */
Matrix A, B;
...

Matrix C = A * B;

Matrix D = A - B;

Matrix E = A.tensor_product(B);

/* transpose of A */
Matrix F = A.T();

/* G = 42 * A */
Matrix G = A.scale(42.);

Note

We recommend to use LAPACK libaries like MKL or Petsc. The functions do not support OpenMP.

SparseMatrix<ScalarType> danceq::internal::SparseMatrix::operator*(const SparseMatrix<ScalarType> &other) const

Overloaded multiplication.

Parameters:

other – Input matrix.

Returns:

this*other

SparseMatrix<ScalarType> danceq::internal::SparseMatrix::operator+(const SparseMatrix<ScalarType> &other) const

Overloaded addition.

Parameters:

other – Input matrix.

Returns:

this+other

SparseMatrix<ScalarType> danceq::internal::SparseMatrix::operator-(const SparseMatrix<ScalarType> &other) const

Overloaded subtraction.

Parameters:

other – Input matrix.

Returns:

this-other

SparseMatrix<ScalarType> &danceq::internal::SparseMatrix::operator=(const SparseMatrix<ScalarType> &other)

Overloaded equality.

Parameters:

other – Input matrix.

Returns:

other

SparseMatrix<ScalarType> danceq::internal::SparseMatrix::tensor_product(const SparseMatrix<ScalarType> &other) const

Tensor product between two matrices.

Returns the tensor product of this and other. The return matrix has the dimension this-> get_dim() times other. get_dim().

\[\mathrm{this} \otimes \mathrm{other}\]

Parameters:

other – Input matrix.

Returns:

this X other

SparseMatrix<ScalarType> danceq::internal::SparseMatrix::T(void) const

Returns the transpose of the matrix.

Returns:

Transposed matrix of other

int32_t danceq::internal::SparseMatrix::scale(ScalarType factor)

Scales matrix.

Parameters:

factor – Factor for scaling

Returns:

error_code