SPI
SLEPc PETSc Interface is used for rapid development and intuitive matrix operations similar to MatLab or NumPy style of operations
Namespaces | Macros | Functions
SPIMat.cpp File Reference
#include "SPIMat.hpp"
#include "SPIprint.hpp"
#include <petscviewerhdf5.h>
#include <petscmath.h>
#include <slepcsvd.h>

Go to the source code of this file.

Namespaces

 SPI
 

Macros

#define USE_GPU   0
 

Functions

SPIMat SPI::operator* (const PetscScalar a, const SPIMat A)
 a*A operation to be equivalent to A*a More...
 
SPIMat SPI::operator* (const SPIMat A, const PetscScalar a)
 A*a operation to be equivalent to A*a. More...
 
SPIVec SPI::operator/ (const SPIVec &b, const SPIMat &A)
 Solve linear system, Ax=b using b/A notation. More...
 
SPIMat SPI::operator^ (const PetscScalar a, const SPIMat &A)
 Y=a^A operation. More...
 
SPIVec SPI::solve (const SPIMat &A, const SPIVec &b)
 Solve linear system, Ax=b using solve(A,b) notation. More...
 
SPIMat SPI::inv (const SPIMat &A)
 Solve linear system A*Ainv=B using MatMatSolve. More...
 
SPIMat SPI::eye (const PetscInt n)
 create, form, and return identity matrix of size n More...
 
SPIMat SPI::zeros (const PetscInt m, const PetscInt n)
 create, form, and return zeros matrix of size mxn More...
 
SPIMat SPI::diag (const SPIVec &d, const PetscInt k)
 set diagonal of matrix More...
 
SPIMat SPI::kron (const SPIMat &A, const SPIMat &B)
 set kronecker inner product of two matrices More...
 
std::tuple< std::vector< PetscReal >, std::vector< SPIVec >, std::vector< SPIVec > > SPI::svd (const SPIMat &A)
 solve SVD problem of A=U*E*V^H for skinny A matrix More...
 
SPIVec SPI::lstsq (const SPIMat &A, SPIVec &y)
 solve least squares problem of A*x=y for skinny A matrix using SVD More...
 
SPIVec SPI::lstsq (const std::vector< SPIVec > &A, SPIVec &y)
 solve least squares problem of A*x=y for skinny A matrix (or vectors of columns vectors) using SVD More...
 
std::tuple< PetscScalar, SPIVec, SPIVec > SPI::eig (const SPIMat &A, const SPIMat &B, const PetscScalar target, const PetscReal tol, const PetscInt max_iter)
 solve general eigenvalue problem of Ax = kBx and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< PetscScalar, SPIVec > SPI::eig_right (const SPIMat &A, const SPIMat &B, const PetscScalar target, const PetscReal tol, const PetscInt max_iter)
 solve general eigenvalue problem of Ax = kBx and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< PetscScalar, SPIVec, SPIVec > SPI::eig_init (const SPIMat &A, const SPIMat &B, const PetscScalar target, const SPIVec &ql, const SPIVec &qr, PetscReal tol, const PetscInt max_iter)
 solve general eigenvalue problem of Ax = kBx and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< PetscScalar, SPIVec > SPI::eig_init_right (const SPIMat &A, const SPIMat &B, const PetscScalar target, const SPIVec &qr, PetscReal tol, const PetscInt max_iter)
 solve general eigenvalue problem of Ax = kBx and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< std::vector< PetscScalar >, std::vector< SPIVec > > SPI::eig_init_rights (const SPIMat &A, const SPIMat &B, const std::vector< PetscScalar > targets, const std::vector< SPIVec > &qrs, PetscReal tol, const PetscInt max_iter)
 solve general eigenvalue problem of Ax = kBx and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< PetscScalar, SPIVec > SPI::polyeig (const std::vector< SPIMat > &As, const PetscScalar target, const PetscReal tol, const PetscInt max_iter)
 solve general polynomial eigenvalue problem of (A0 + A1*alpha + A2*alpha^2 + ...)*x = 0 and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) More...
 
std::tuple< PetscScalar, SPIVec > SPI::polyeig_init (const std::vector< SPIMat > &As, const PetscScalar target, const SPIVec &qr, const PetscReal tol, const PetscInt max_iter)
 solve general polynomial eigenvalue problem of (A0 + A1*alpha + A2*alpha^2 + ...)*x = 0 and return a tuple of tie(PetscScalar alpha, SPIVec eig_vector) using initial subspace vector More...
 
SPIMat SPI::block ( const Block2D< SPIMat > Blocks)
 set block matrices using an input array of size rows*cols. Fills rows first More...
 
std::tuple< SPIMat, SPIMat > SPI::meshgrid (SPIVec &x, SPIVec &y)
 
PetscInt SPI::save (const SPIMat &A, const std::string filename)
 save matrix to filename in binary format (see Petsc documentation for format ) Format is (from Petsc documentation): int MAT_FILE_CLASSID int number of rows int number of columns int total number of nonzeros int *number nonzeros in each row int *column indices of all nonzeros (starting index is zero) PetscScalar *values of all nonzeros More...
 
PetscInt SPI::save (const std::vector< SPIMat > &As, const std::string filename)
 save matrices to filename in binary format (see Petsc documentation for format More...
 
PetscInt SPI::load (SPIMat &A, const std::string filename)
 load matrix from filename from binary format (works with save(SPIMat,std::string) function More...
 
PetscInt SPI::load (std::vector< SPIMat > &As, const std::string filename)
 load matrix from filename from binary format (works with save(SPIMat,std::string) function More...
 
PetscInt SPI::draw (const SPIMat &A)
 draw nonzero structure of matrix More...
 
template<class T >
SPIMat SPI::_Function_on_each_element (T(*f)(T const &), const SPIMat &A)
 take the function of each element in a matrix, e.g. (*f)(A(i,j)) for each i,j More...
 
SPIMat SPI::sin (const SPIMat &A)
 take the sin of each element in a matrix More...
 
SPIMat SPI::cos (const SPIMat &A)
 take the cos of each element in a matrix More...
 
SPIMat SPI::acos (const SPIMat &A)
 take the arccos of each element in a matrix More...
 
SPIMat SPI::tan (const SPIMat &A)
 take the tan of each element in a matrix More...
 
SPIMat SPI::operator% (const SPIMat &A, const SPIMat &B)
 take the elementwise multiplication of each element in a matrix More...
 
SPIMat SPI::abs (const SPIMat &A)
 take the abs of each element in a matrix More...
 
SPIMat SPI::orthogonalize (const std::vector< SPIVec > &x)
 

Macro Definition Documentation

◆ USE_GPU

#define USE_GPU   0

Definition at line 7 of file SPIMat.cpp.