SPI
SLEPc PETSc Interface is used for rapid development and intuitive matrix operations similar to MatLab or NumPy style of operations
Public Member Functions | Data Fields
SPI::SPIMat Struct Reference

#include <SPIMat.hpp>

Public Member Functions

 SPIMat (std::string _name="SPIMat")
 constructor with no arguments (no initialization) More...
 
 SPIMat (const std::vector< SPIVec > &A, std::string _name="SPIMat")
 
 SPIMat (const SPIMat &A, std::string _name="SPIMat")
 
 SPIMat (PetscInt rowscols, std::string _name="SPIMat")
 
 SPIMat (PetscInt rowsm, PetscInt colsn, std::string _name="SPIMat")
 constructor of rectangular matrix More...
 
PetscInt Init (PetscInt m, PetscInt n, std::string name="SPIMat")
 
SPIMatset (PetscInt m, PetscInt n, const PetscScalar v)
 
SPIMatset_col (const PetscInt col, const SPIVec &v)
 
SPIMatadd (PetscInt m, PetscInt n, const PetscScalar v)
 add a scalar value at position row m and column n More...
 
PetscScalar operator() (PetscInt m, PetscInt n, PetscBool global=PETSC_FALSE)
 get local value at row m, column n More...
 
PetscScalar operator() (PetscInt m, PetscInt n, PetscBool global=PETSC_FALSE) const
 get local value at row m, column n More...
 
SPIMatoperator() (PetscInt m, PetscInt n, const PetscScalar v)
 set operator the same as set function More...
 
SPIMatoperator() (PetscInt m, PetscInt n, const double v)
 set operator the same as set function More...
 
SPIMatoperator() (PetscInt m, PetscInt n, const int v)
 set operator the same as set function More...
 
SPIMatoperator() (PetscInt m, PetscInt n, const SPIMat &Asub, InsertMode addv=INSERT_VALUES)
 set submatrix into matrix at row m, col n More...
 
SPIMatoperator() ()
 assmelbe the matrix More...
 
SPIMatoperator+= (const SPIMat &X)
 MatAXPY, Y = 1.*X + Y operation. More...
 
SPIMataxpy (const PetscScalar a, const SPIMat &X)
 MatAXPY function call to add a*X to the current mat. More...
 
SPIMat operator+ (const SPIMat &X)
 Y + X operation. More...
 
SPIMatoperator-= (const SPIMat &X)
 Y = -1.*X + Y operation. More...
 
SPIMat operator- (const SPIMat &X)
 Y - X operation. More...
 
SPIMat operator- () const
 -X operation More...
 
SPIMat operator* (const PetscScalar a)
 Y*a operation. More...
 
SPIMat operator* (const double a)
 Y*a operation. More...
 
SPIVec operator* (const SPIVec &x)
 A*x operation to return a vector. More...
 
SPIMatoperator*= (const PetscScalar a)
 Y = Y*a operation. More...
 
SPIMatoperator*= (const double a)
 Y = Y*a operation. More...
 
SPIMatoperator/= (const PetscScalar a)
 Y = Y/a operation. More...
 
SPIMat operator/ (const PetscScalar a)
 Z = Y/a operation. More...
 
SPIMat operator/ (const SPIMat &A)
 Z = Y/A operation. More...
 
SPIMat operator* (const SPIMat &A)
 Y*A operation. More...
 
SPIMatoperator= (const SPIMat &A)
 Y=X with initialization of Y using MatConvert. More...
 
PetscInt T (SPIMat &A)
 A = Transpose(*this.mat) operation with initialization of A. More...
 
SPIMatT ()
 Transpose the current mat. More...
 
PetscInt H (SPIMat &A)
 A = Hermitian Transpose(*this.mat) operation with initialization of A (tranpose and complex conjugate) More...
 
SPIMatH ()
 Hermitian Transpose the current mat. More...
 
SPIVec H (const SPIVec &q)
 Hermitian Transpose multiplication with the current mat. More...
 
SPIMatconj ()
 elemenwise conjugate current matrix More...
 
SPIMatreal ()
 take the real part of the vector More...
 
SPIVec diag ()
 get diagonal of matrix More...
 
SPIMatzero_row (const PetscInt row)
 set a row to zero More...
 
SPIMateye_row (const PetscInt row)
 set a row to zero and set 1 in diagonal entry More...
 
SPIMatzero_row_full (const PetscInt row)
 set a row to zero using dense format More...
 
SPIMatzero_rows (std::vector< PetscInt > rows)
 set rows to zero More...
 
SPIMateye_rows (std::vector< PetscInt > rows)
 set rows to zero and set main diagonal to 1 More...
 
SPIVec col (const PetscInt i)
 get column vector More...
 
PetscInt print ()
 print mat to screen using PETSC_VIEWER_STDOUT_WORLD More...
 
 ~SPIMat ()
 destructor to delete memory More...
 

Data Fields

PetscInt rows
 number of rows in mat More...
 
PetscInt cols
 number of columns in mat More...
 
Mat mat
 petsc Mat data More...
 
PetscErrorCode ierr
 ierr for various routines and operators More...
 
PetscBool flag_init =PETSC_FALSE
 flag if it has been initialized More...
 
std::string name
 Matrix name. More...
 

Detailed Description

Definition at line 17 of file SPIMat.hpp.

Constructor & Destructor Documentation

◆ SPIMat() [1/5]

SPI::SPIMat::SPIMat ( std::string  _name = "SPIMat")

constructor with no arguments (no initialization)

Parameters
[in]_name[in] name of SPIMat

Definition at line 13 of file SPIMat.cpp.

◆ SPIMat() [2/5]

SPI::SPIMat::SPIMat ( const std::vector< SPIVec > &  A,
std::string  _name = "SPIMat" 
)

constructor using a vector of column vectors

Definition at line 25 of file SPIMat.cpp.

◆ SPIMat() [3/5]

SPI::SPIMat::SPIMat ( const SPIMat A,
std::string  _name = "SPIMat" 
)

constructor using another SPIMat

Parameters
[in]A[in] another SPIMat to copy into this new SPIMat
[in]_name[in] name of SPIMat

Definition at line 17 of file SPIMat.cpp.

◆ SPIMat() [4/5]

SPI::SPIMat::SPIMat ( PetscInt  rowscols,
std::string  _name = "SPIMat" 
)

constructor with one arguement to make square matrix

Parameters
[in]rowscols[in] number of rows and columns to make the square matrix
[in]_name[in] name of SPIMat

Definition at line 38 of file SPIMat.cpp.

◆ SPIMat() [5/5]

SPI::SPIMat::SPIMat ( PetscInt  rowsm,
PetscInt  colsn,
std::string  _name = "SPIMat" 
)

constructor of rectangular matrix

Parameters
[in]rowsm[in] number of rows in matrix
[in]colsn[in] number of columns in matrix
[in]_name[in] name of SPIMat

Definition at line 45 of file SPIMat.cpp.

◆ ~SPIMat()

SPI::SPIMat::~SPIMat ( )

destructor to delete memory

Definition at line 508 of file SPIMat.cpp.

Member Function Documentation

◆ add()

SPIMat & SPI::SPIMat::add ( PetscInt  m,
PetscInt  n,
const PetscScalar  v 
)

add a scalar value at position row m and column n

Returns
current matrix after adding the value
Parameters
[in]m[in] row to add scalar
[in]n[in] column to add scalar
[in]v[in] scalar to add in matrix

Definition at line 97 of file SPIMat.cpp.

◆ axpy()

SPIMat & SPI::SPIMat::axpy ( const PetscScalar  a,
const SPIMat X 
)

MatAXPY function call to add a*X to the current mat.

Returns
current matrix after operation
Parameters
[in]a[in] scalar a in Y = a*X + Y operation
[in]X[in] matrix X in Y = a*X + Y operation

Definition at line 232 of file SPIMat.cpp.

◆ col()

SPIVec SPI::SPIMat::col ( const PetscInt  i)

get column vector

Returns
SPIVec of column vector

Definition at line 489 of file SPIMat.cpp.

◆ conj()

SPIMat & SPI::SPIMat::conj ( )

elemenwise conjugate current matrix

Returns
current matrix after conjugate of each element

Definition at line 435 of file SPIMat.cpp.

◆ diag()

SPIVec SPI::SPIMat::diag ( )

get diagonal of matrix

Returns
vector of current diagonal

Definition at line 445 of file SPIMat.cpp.

◆ eye_row()

SPIMat & SPI::SPIMat::eye_row ( const PetscInt  row)

set a row to zero and set 1 in diagonal entry

Returns
matrix after setting the row to zero and setting 1 in diagonal
Parameters
[in]row[in] which row to zero out of the matrix

Definition at line 458 of file SPIMat.cpp.

◆ eye_rows()

SPIMat & SPI::SPIMat::eye_rows ( std::vector< PetscInt >  rows)

set rows to zero and set main diagonal to 1

Returns
matrix after setting the rows to zero and main diagonals to 1
Parameters
[in]rows[in] which rows to zero out of the matrix

Definition at line 482 of file SPIMat.cpp.

◆ H() [1/3]

SPIMat & SPI::SPIMat::H ( )

Hermitian Transpose the current mat.

Returns
current matrix after transpose

Definition at line 422 of file SPIMat.cpp.

◆ H() [2/3]

SPIVec SPI::SPIMat::H ( const SPIVec x)

Hermitian Transpose multiplication with the current mat.

Returns
Vector y after y=A^H*x operation
Parameters
[in]x[in] x vector to multiply by the Hermitian Transpose. y = A^H*x

Definition at line 427 of file SPIMat.cpp.

◆ H() [3/3]

PetscInt SPI::SPIMat::H ( SPIMat A)

A = Hermitian Transpose(*this.mat) operation with initialization of A (tranpose and complex conjugate)

Returns
current matrix without hermitian transpose
Parameters
[out]A[out] hermitian transpose of current matrix saved in new initialized matrix

Definition at line 415 of file SPIMat.cpp.

◆ Init()

PetscInt SPI::SPIMat::Init ( PetscInt  m,
PetscInt  n,
std::string  _name = "SPIMat" 
)

initialize the matrix of size m by n

Returns
0 if successful
Parameters
[in]m[in] number of rows
[in]n[in] number of columns
[in]_name[in] name of SPIMat

Definition at line 55 of file SPIMat.cpp.

◆ operator()() [1/7]

SPIMat & SPI::SPIMat::operator() ( )

assmelbe the matrix

Returns
the current matrix

Definition at line 218 of file SPIMat.cpp.

◆ operator()() [2/7]

SPIMat & SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
const double  v 
)

set operator the same as set function

Returns
current matrix after setting value
Parameters
[in]m[in] row to set scalar
[in]n[in] column to set scalar
[in]v[in] scalar to set in matrix

Definition at line 160 of file SPIMat.cpp.

◆ operator()() [3/7]

SPIMat & SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
const int  v 
)

set operator the same as set function

Returns
current matrix after setting value
Parameters
[in]m[in] row to set scalar
[in]n[in] column to set scalar
[in]v[in] scalar to set in matrix

Definition at line 169 of file SPIMat.cpp.

◆ operator()() [4/7]

SPIMat & SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
const PetscScalar  v 
)

set operator the same as set function

Returns
current matrix after setting value
Parameters
[in]m[in] row to set scalar
[in]n[in] column to set scalar
[in]v[in] scalar to set in matrix

Definition at line 150 of file SPIMat.cpp.

◆ operator()() [5/7]

SPIMat & SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
const SPIMat Asub,
InsertMode  addv = INSERT_VALUES 
)

set submatrix into matrix at row m, col n

Returns
current matrix after setting value
Parameters
[in]m[in] row to set submatrix
[in]n[in] column to set submatrix
[in]Asub[in] submatrix to set in matrix
[in]addv[in] default to ADD_VALUES in submatrix, can do INSERT_VALUES instead

Definition at line 180 of file SPIMat.cpp.

◆ operator()() [6/7]

PetscScalar SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
PetscBool  global = PETSC_FALSE 
)

get local value at row m, column n

Returns
scalar at specified location
Parameters
[in]m[in] row to get scalar
[in]n[in] column to get scalar
[in]global[in] whether to broadcast value to all processors or not (default is false)

Definition at line 129 of file SPIMat.cpp.

◆ operator()() [7/7]

PetscScalar SPI::SPIMat::operator() ( PetscInt  m,
PetscInt  n,
PetscBool  global = PETSC_FALSE 
) const

get local value at row m, column n

Returns
scalar at specified location
Parameters
[in]m[in] row to get scalar
[in]n[in] column to get scalar
[in]global[in] whether to broadcast value to all processors or not (default is false)

Definition at line 106 of file SPIMat.cpp.

◆ operator*() [1/4]

SPIMat SPI::SPIMat::operator* ( const double  a)

Y*a operation.

Returns
new matrix after operation
Parameters
[in]a[in] scalar

Definition at line 294 of file SPIMat.cpp.

◆ operator*() [2/4]

SPIMat SPI::SPIMat::operator* ( const PetscScalar  a)

Y*a operation.

Returns
new matrix after operation
Parameters
[in]a[in] scalar

Definition at line 285 of file SPIMat.cpp.

◆ operator*() [3/4]

SPIMat SPI::SPIMat::operator* ( const SPIMat A)

Y*A operation.

Returns
new matrix after matrix matrix multiply
Parameters
[in]A[in] A matrix in Y*A operation

Definition at line 354 of file SPIMat.cpp.

◆ operator*() [4/4]

SPIVec SPI::SPIMat::operator* ( const SPIVec x)

A*x operation to return a vector.

Returns
new vector after operation
Parameters
[in]x[in] x in A*x matrix vector multiplication

Definition at line 303 of file SPIMat.cpp.

◆ operator*=() [1/2]

SPIMat & SPI::SPIMat::operator*= ( const double  a)

Y = Y*a operation.

Returns
Y after operation
Parameters
[in]a[in] scalar in Y*a operation

Definition at line 313 of file SPIMat.cpp.

◆ operator*=() [2/2]

SPIMat & SPI::SPIMat::operator*= ( const PetscScalar  a)

Y = Y*a operation.

Returns
Y after operation
Parameters
[in]a[in] scalar in Y*a operation

Definition at line 320 of file SPIMat.cpp.

◆ operator+()

SPIMat SPI::SPIMat::operator+ ( const SPIMat X)

Y + X operation.

Returns
new matrix after operation
Parameters
[in]X[in] X in Y+X operation

Definition at line 241 of file SPIMat.cpp.

◆ operator+=()

SPIMat & SPI::SPIMat::operator+= ( const SPIMat X)

MatAXPY, Y = 1.*X + Y operation.

Returns
current matrix after operation
Parameters
[in]X[in] X in Y+=X operation

Definition at line 225 of file SPIMat.cpp.

◆ operator-() [1/2]

SPIMat SPI::SPIMat::operator- ( ) const

-X operation

Returns
new matrix after operation

Definition at line 278 of file SPIMat.cpp.

◆ operator-() [2/2]

SPIMat SPI::SPIMat::operator- ( const SPIMat X)

Y - X operation.

Returns
new matrix after operation
Parameters
[in]X[in] X in Y-X operation

Definition at line 264 of file SPIMat.cpp.

◆ operator-=()

SPIMat & SPI::SPIMat::operator-= ( const SPIMat X)

Y = -1.*X + Y operation.

Returns
Y after operation
Parameters
[in]X[in] X in Y = -1.*X + Y operation

Definition at line 256 of file SPIMat.cpp.

◆ operator/() [1/2]

SPIMat SPI::SPIMat::operator/ ( const PetscScalar  a)

Z = Y/a operation.

Returns
Z after operation
Parameters
[in]a[in] scalar in Y*a operation

Definition at line 334 of file SPIMat.cpp.

◆ operator/() [2/2]

SPIMat SPI::SPIMat::operator/ ( const SPIMat A)

Z = Y/A operation.

Returns
Z after operation
Parameters
[in]A[in] A in Y/A operation

Definition at line 340 of file SPIMat.cpp.

◆ operator/=()

SPIMat & SPI::SPIMat::operator/= ( const PetscScalar  a)

Y = Y/a operation.

Returns
Y after operation
Parameters
[in]a[in] scalar in Y*a operation

Definition at line 327 of file SPIMat.cpp.

◆ operator=()

SPIMat & SPI::SPIMat::operator= ( const SPIMat A)

Y=X with initialization of Y using MatConvert.

Returns
Y after operation
Parameters
[in]A[in] A in Y=A operation

Definition at line 367 of file SPIMat.cpp.

◆ print()

PetscInt SPI::SPIMat::print ( )

print mat to screen using PETSC_VIEWER_STDOUT_WORLD

Returns
0 if successful

Definition at line 498 of file SPIMat.cpp.

◆ real()

SPIMat & SPI::SPIMat::real ( )

take the real part of the vector

Returns
the vector after taking the real part of it

Definition at line 440 of file SPIMat.cpp.

◆ set()

SPIMat & SPI::SPIMat::set ( PetscInt  m,
PetscInt  n,
const PetscScalar  v 
)

set a scalar value at position row m and column n

Returns
current SPIMat after setting value
Parameters
[in]m[in] row to insert scalar
[in]n[in] column to insert scalar
[in]v[in] scalar to insert in matrix

Definition at line 77 of file SPIMat.cpp.

◆ set_col()

SPIMat & SPI::SPIMat::set_col ( const PetscInt  col,
const SPIVec v 
)

set a column vector into a matrix

Parameters
[in]col[in]
[in]v[in]

Definition at line 86 of file SPIMat.cpp.

◆ T() [1/2]

SPIMat & SPI::SPIMat::T ( )

Transpose the current mat.

Returns
current matrix after transpose

Definition at line 405 of file SPIMat.cpp.

◆ T() [2/2]

PetscInt SPI::SPIMat::T ( SPIMat A)

A = Transpose(*this.mat) operation with initialization of A.

Returns
0 if solves
Parameters
[out]A[out] transpose of current matrix

Definition at line 392 of file SPIMat.cpp.

◆ zero_row()

SPIMat & SPI::SPIMat::zero_row ( const PetscInt  row)

set a row to zero

Returns
matrix after setting the row to zero
Parameters
[in]row[in] which row to zero out of the matrix

Definition at line 451 of file SPIMat.cpp.

◆ zero_row_full()

SPIMat & SPI::SPIMat::zero_row_full ( const PetscInt  row)

set a row to zero using dense format

Returns
matrix after setting the row to zero
Parameters
[in]row[in] which row to zero out of the matrix

Definition at line 465 of file SPIMat.cpp.

◆ zero_rows()

SPIMat & SPI::SPIMat::zero_rows ( std::vector< PetscInt >  rows)

set rows to zero

Returns
matrix after setting the rows to zero
Parameters
[in]rows[in] which rows to zero out of the matrix

Definition at line 475 of file SPIMat.cpp.

Field Documentation

◆ cols

PetscInt SPI::SPIMat::cols

number of columns in mat

Definition at line 19 of file SPIMat.hpp.

◆ flag_init

PetscBool SPI::SPIMat::flag_init =PETSC_FALSE

flag if it has been initialized

Definition at line 32 of file SPIMat.hpp.

◆ ierr

PetscErrorCode SPI::SPIMat::ierr

ierr for various routines and operators

Definition at line 29 of file SPIMat.hpp.

◆ mat

Mat SPI::SPIMat::mat

petsc Mat data

Definition at line 28 of file SPIMat.hpp.

◆ name

std::string SPI::SPIMat::name

Matrix name.

Definition at line 33 of file SPIMat.hpp.

◆ rows

PetscInt SPI::SPIMat::rows

number of rows in mat

Definition at line 18 of file SPIMat.hpp.


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