GQCP
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
GQCP::Matrix< _Scalar, _Rows, _Cols > Class Template Reference

#include <Matrix.hpp>

Inheritance diagram for GQCP::Matrix< _Scalar, _Rows, _Cols >:
Inheritance graph
Collaboration diagram for GQCP::Matrix< _Scalar, _Rows, _Cols >:
Collaboration graph

Public Types

using Scalar = _Scalar
 
using Self = Matrix< Scalar, Rows, Cols >
 
using Base = Eigen::Matrix< Scalar, Rows, Cols >
 

Public Member Functions

template<typename Z = bool>
enable_if_t< Self::is_vector, Z > areEqualEigenvaluesAs (const Matrix< Scalar, Dynamic, 1 > &other, double tolerance=1.0e-12) const
 
template<typename Z = bool>
enable_if_t< Self::is_vector, Z > isEqualEigenvectorAs (const Matrix< Scalar, Dynamic, 1 > &other, double tolerance=1.0e-12) const
 
template<typename Z = bool>
enable_if_t< Self::is_matrix, Z > hasEqualSetsOfEigenvectorsAs (const Matrix< Scalar, Dynamic, Dynamic > &other, double tolerance=1.0e-12) const
 
template<typename Z = Scalar>
enable_if_t< Self::is_vector &&(Rows==3), Z > operator() (const CartesianDirection direction) const
 
template<typename Z = Scalar&>
enable_if_t< Self::is_vector &&(Rows==3), Z > operator() (const CartesianDirection direction)
 
template<typename Z = Self>
enable_if_t< Self::is_matrix, Z > calculateMinor (size_t i, size_t j) const
 
const BaseEigen () const
 
BaseEigen ()
 
const bool isPositiveSemiDefinite (const double threshold=-1.0e-5) const
 
template<typename Z = Matrix<Scalar, Rows, 1>>
enable_if_t< Self::is_matrix, Z > pairWiseReduced (const size_t start_i=0, size_t start_j=0) const
 
template<typename Z = void>
enable_if_t< Self::is_matrix, Z > print (std::ostream &output_stream=std::cout) const
 
void removeColumn (const size_t i)
 
void removeColumns (const std::vector< size_t > &column_indices)
 
void removeRow (const size_t i)
 
void removeRows (const std::vector< size_t > &row_indices)
 

Static Public Member Functions

template<typename Z = Self>
static enable_if_t<(Cols==Dynamic) &&(Rows==Dynamic), Z > FromColumnMajorVector (const Matrix< Scalar, Dynamic, 1 > &v, const size_t rows, const size_t cols)
 
template<typename Z = Self>
static enable_if_t< Self::is_vector, Z > FromFile (const std::string &filename, size_t rows)
 
template<typename Z = Self>
static enable_if_t< Self::is_matrix, Z > FromFile (const std::string &filename, size_t rows, size_t cols)
 
template<typename Z = Self>
static enable_if_t<(Cols==Dynamic) &&(Rows==Dynamic), Z > FromRowMajorVector (const Matrix< Scalar, Dynamic, 1 > &v, const size_t rows, const size_t cols)
 

Static Public Attributes

static constexpr auto Rows = _Rows
 
static constexpr auto Cols = _Cols
 

Detailed Description

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
class GQCP::Matrix< _Scalar, _Rows, _Cols >

An extension of the Eigen::Matrix class, with extra operations

Template Parameters
_Scalarthe scalar representation type
_Rowsthe number of rows (int or Dynamic)
_Colsthe number of columns (int or Dynamic)

We have decided to inherit from Eigen::Matrix, because we will use different hierarchies: see also: https://eigen.tuxfamily.org/dox-devel/TopicCustomizing_InheritingMatrix.html

Member Typedef Documentation

◆ Base

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
using GQCP::Matrix< _Scalar, _Rows, _Cols >::Base = Eigen::Matrix<Scalar, Rows, Cols>

◆ Scalar

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
using GQCP::Matrix< _Scalar, _Rows, _Cols >::Scalar = _Scalar

◆ Self

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
using GQCP::Matrix< _Scalar, _Rows, _Cols >::Self = Matrix<Scalar, Rows, Cols>

Member Function Documentation

◆ areEqualEigenvaluesAs()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = bool>
enable_if_t< Self::is_vector, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::areEqualEigenvaluesAs ( const Matrix< Scalar, Dynamic, 1 > &  other,
double  tolerance = 1.0e-12 
) const
inline

Check if two sets of eigenvalues are equal within a given tolerance.

Parameters
eigenvalues1The first set of eigenvalues.
eigenvalues2The second set of eigenvalues.
toleranceThe tolerance for comparison.
Returns
If two sets of eigenvalues are equal within a given tolerance.

◆ calculateMinor()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Self>
enable_if_t< Self::is_matrix, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::calculateMinor ( size_t  i,
size_t  j 
) const
inline
Parameters
irow index (starting from 0)
jcolumn index (starting from 0)
Returns
the i-j minor (i.e. delete the i-th row and j-th column)

◆ Eigen() [1/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
Base & GQCP::Matrix< _Scalar, _Rows, _Cols >::Eigen ( )
inline
Returns
This as a non-const Eigen base.

◆ Eigen() [2/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
const Base & GQCP::Matrix< _Scalar, _Rows, _Cols >::Eigen ( ) const
inline
Returns
This as a const Eigen base.

◆ FromColumnMajorVector()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Self>
static enable_if_t<(Cols==Dynamic) &&(Rows==Dynamic), Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::FromColumnMajorVector ( const Matrix< Scalar, Dynamic, 1 > &  v,
const size_t  rows,
const size_t  cols 
)
inlinestatic

Convert a given column-major vector to a matrix with the given number of rows

Parameters
va vector that is supposed to be in a column-major ordering
rowsthe number of rows the resulting matrix should have
colsthe number of columns the resulting matrix should have

◆ FromFile() [1/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Self>
static enable_if_t< Self::is_vector, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::FromFile ( const std::string &  filename,
size_t  rows 
)
inlinestatic

Construct a vector by reading in a file

Parameters
filenamethe name of the file to be read in
rowsthe number of expected rows

◆ FromFile() [2/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Self>
static enable_if_t< Self::is_matrix, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::FromFile ( const std::string &  filename,
size_t  rows,
size_t  cols 
)
inlinestatic

Construct a matrix by reading in a file

Parameters
filenamethe name of the file to be read in
rowsthe number of expected rows
colsthe number of expected columns

◆ FromRowMajorVector()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Self>
static enable_if_t<(Cols==Dynamic) &&(Rows==Dynamic), Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::FromRowMajorVector ( const Matrix< Scalar, Dynamic, 1 > &  v,
const size_t  rows,
const size_t  cols 
)
inlinestatic

Convert a given row-major vector to a matrix with the given number of rows

Parameters
va vector that is supposed to be in a column-major ordering
rowsthe number of rows the resulting matrix should have
colsthe number of columns the resulting matrix should have

◆ hasEqualSetsOfEigenvectorsAs()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = bool>
enable_if_t< Self::is_matrix, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::hasEqualSetsOfEigenvectorsAs ( const Matrix< Scalar, Dynamic, Dynamic > &  other,
double  tolerance = 1.0e-12 
) const
inline

Check if two sets of eigenvectors are equal within a given tolerance.

Parameters
eigenvectors1The first set of eigenvectors.
eigenvectors2The second set of eigenvectors.
toleranceThe tolerance for comparison.
Returns
If two sets of eigenvectors are equal within a given tolerance.

◆ isEqualEigenvectorAs()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = bool>
enable_if_t< Self::is_vector, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::isEqualEigenvectorAs ( const Matrix< Scalar, Dynamic, 1 > &  other,
double  tolerance = 1.0e-12 
) const
inline

Check if two eigenvectors are equal, within a given tolerance.

Parameters
eigenvector1The first eigenvector.
eigenvector2The second eigenvector.
toleranceThe tolerance for comparison.
Returns
If two eigenvectors are equal.

◆ isPositiveSemiDefinite()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
const bool GQCP::Matrix< _Scalar, _Rows, _Cols >::isPositiveSemiDefinite ( const double  threshold = -1.0e-5) const
inline
Parameters
thresholdThe threshold on which the lowest eigenvalue is judged.
Returns
a boolean that states whether or not the matrix is positive semi-definite, i.e. has no strictly negative eigenvalues.

◆ operator()() [1/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Scalar&>
enable_if_t< Self::is_vector &&(Rows==3), Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::operator() ( const CartesianDirection  direction)
inline
Parameters
directionthe Cartesian direction (x, y, or z)
Returns
a modifiable value in the vector that corresponds to the given direction

◆ operator()() [2/2]

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Scalar>
enable_if_t< Self::is_vector &&(Rows==3), Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::operator() ( const CartesianDirection  direction) const
inline
Parameters
directionthe Cartesian direction (x, y, or z)
Returns
the value in the vector that corresponds to the given direction

◆ pairWiseReduced()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = Matrix<Scalar, Rows, 1>>
enable_if_t< Self::is_matrix, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::pairWiseReduced ( const size_t  start_i = 0,
size_t  start_j = 0 
) const
inline
Parameters
start_ithe index at which the rows should start
start_jthe index at which the columns should start
Returns
this matrix as a vector in a column-major storage, i.e. a pair-wise reduced form of this matrix. The elements of the matrix are put into the vector such that v(m) = M(i,j)

in which m is calculated from i and j in a column-major way

◆ print()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
template<typename Z = void>
enable_if_t< Self::is_matrix, Z > GQCP::Matrix< _Scalar, _Rows, _Cols >::print ( std::ostream &  output_stream = std::cout) const
inline

Print the contents of a this to an output filestream

Parameters
output_streamthe stream used for outputting

◆ removeColumn()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
void GQCP::Matrix< _Scalar, _Rows, _Cols >::removeColumn ( const size_t  i)
inline

Remove the i-th column of this matrix.

Parameters
ithe index of the column that should be removed
Note
Implementation adapted from (https://stackoverflow.com/a/46303314), while waiting for Eigen's 3.4 release.

◆ removeColumns()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
void GQCP::Matrix< _Scalar, _Rows, _Cols >::removeColumns ( const std::vector< size_t > &  column_indices)
inline

Remove the columns at the given indices.

Parameters
column_indicesthe indices of the columns that should be removed, in ascending order

◆ removeRow()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
void GQCP::Matrix< _Scalar, _Rows, _Cols >::removeRow ( const size_t  i)
inline

Remove the i-th row of this matrix.

Parameters
ithe index of the row that should be removed
Note
Implementation adapted from (https://stackoverflow.com/a/46303314), while waiting for Eigen's 3.4 release.

◆ removeRows()

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
void GQCP::Matrix< _Scalar, _Rows, _Cols >::removeRows ( const std::vector< size_t > &  row_indices)
inline

Remove the rows at the given indices.

Parameters
row_indicesthe indices of the columns that should be removed, in ascending order

Member Data Documentation

◆ Cols

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
constexpr auto GQCP::Matrix< _Scalar, _Rows, _Cols >::Cols = _Cols
staticconstexpr

◆ Rows

template<typename _Scalar = double, int _Rows = Dynamic, int _Cols = Dynamic>
constexpr auto GQCP::Matrix< _Scalar, _Rows, _Cols >::Rows = _Rows
staticconstexpr

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