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::SPIVec Struct Reference

#include <SPIVec.hpp>

Public Member Functions

 SPIVec (std::string _name="SPIVec")
 constructor with no arguments (no initialization) More...
 
 SPIVec (const SPIVec &A, std::string _name="SPIVec")
 constructor using another SPIVec More...
 
 SPIVec (const PetscInt _rows, const std::string _name="SPIVec")
 constructor with one arguement to make vector of length rows More...
 
PetscInt Init (const PetscInt _rows, const std::string name="SPIVec")
 initialize the vector of size _rows More...
 
PetscInt set (const PetscInt _row, const PetscScalar v)
 
PetscInt set (const PetscScalar v)
 
PetscInt add (PetscInt _row, const PetscScalar v)
 
PetscInt size ()
 
PetscScalar operator() (PetscInt _row, PetscBool global=PETSC_FALSE)
 
PetscScalar operator() (PetscInt _row, PetscBool global=PETSC_FALSE) const
 
PetscInt operator() (PetscInt _row, const PetscScalar v)
 
PetscInt operator() (PetscInt _row, const double v)
 
PetscInt operator() (PetscInt _row, const int v)
 
SPIVecoperator() ()
 
SPIVecoperator+= (const SPIVec &X)
 
SPIVecaxpy (const PetscScalar a, const SPIVec &X)
 
SPIVec operator+ (const SPIVec &X)
 
SPIVec operator+ (const PetscScalar a)
 
SPIVec operator+ (const double a)
 
SPIVec operator- (const PetscScalar a)
 
SPIVec operator- (const PetscInt a)
 
SPIVecoperator-= (const SPIVec &X)
 
SPIVec operator- (const SPIVec &X)
 
SPIVec operator- () const
 
SPIVec operator* (const PetscScalar a)
 
SPIVec operator* (const double a)
 
SPIVecoperator*= (const PetscScalar a)
 
SPIVecoperator*= (const double a)
 
SPIVecoperator*= (const SPIVec &a)
 
SPIVec operator* (const SPIVec &X)
 
SPIVec operator/ (const PetscScalar a)
 
SPIVec operator/ (const double a)
 
SPIVec operator/ (const SPIVec X)
 
SPIVecoperator/= (const PetscScalar a)
 
SPIVec operator^ (const PetscScalar p)
 pow operation pow(this,p) More...
 
SPIVec operator^ (const double p)
 pow operation pow(this,p) More...
 
SPIVec operator^ (const int p)
 pow operation pow(this,p) More...
 
SPIVec operator^ (SPIVec p)
 pow operation pow(this,p) More...
 
SPIVecoperator= (const SPIVec &X)
 
PetscBool operator== (const SPIVec &x2)
 == VecEqual test if this==x2 More...
 
SPIVecconj ()
 
PetscScalar max ()
 
PetscInt argmax ()
 
SPIVecreal ()
 take the real part of the vector More...
 
SPIVecimag ()
 take the imaginary part of the vector More...
 
PetscScalar dot (SPIVec y)
 take the inner product of two vectors More...
 
PetscInt print ()
 
 ~SPIVec ()
 

Data Fields

PetscInt rows =0
 number of rows in vec More...
 
Vec vec
 petsc Vec 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
 Vec name (important for hdf5 i/o) More...
 

Detailed Description

Definition at line 13 of file SPIVec.hpp.

Constructor & Destructor Documentation

◆ SPIVec() [1/3]

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

constructor with no arguments (no initialization)

Parameters
[in]_name[in] name of SPIVec (important with hdf5 i/o)

Definition at line 9 of file SPIVec.cpp.

◆ SPIVec() [2/3]

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

constructor using another SPIVec

Parameters
[in]A[in] SPIVec to copy and initialize from
[in]_name[in] name of SPIVec (important with hdf5 i/o)

Definition at line 13 of file SPIVec.cpp.

◆ SPIVec() [3/3]

SPI::SPIVec::SPIVec ( const PetscInt  _rows,
const std::string  _name = "SPIVec" 
)

constructor with one arguement to make vector of length rows

Parameters
[in]_rows[in] number of rows to initialize vector
[in]_name[in] name of SPIVec (important with hdf5 i/o)

Definition at line 21 of file SPIVec.cpp.

◆ ~SPIVec()

SPI::SPIVec::~SPIVec ( )

destructor to delete memory

Definition at line 483 of file SPIVec.cpp.

Member Function Documentation

◆ add()

PetscInt SPI::SPIVec::add ( PetscInt  _row,
const PetscScalar  v 
)

add a scalar value at position row if owned by processor

Returns
0 if successful
Parameters
[in]_row[in] position to add value
[in]v[in] value to add at position _row

Definition at line 83 of file SPIVec.cpp.

◆ argmax()

PetscInt SPI::SPIVec::argmax ( )

maximum index value of vector

Returns
integer index of maximum value of the vector

Definition at line 437 of file SPIVec.cpp.

◆ axpy()

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

VecAXPY Y=a*X+Y operation to add a*X to the current vec

Returns
SPIVec Y
Parameters
[in]a[in] scalar a in Y=a*X+Y operation
[in]X[in] vec X in Y=a*X+Y operation

Definition at line 184 of file SPIVec.cpp.

◆ conj()

SPIVec & SPI::SPIVec::conj ( )

elementwise conjugate current vector

Returns
current vector after conjugate
See also
conj(const SPIVec&)

Definition at line 419 of file SPIVec.cpp.

◆ dot()

PetscScalar SPI::SPIVec::dot ( SPIVec  y)

take the inner product of two vectors

Returns
y^H this where H is the complex conjugate transpose
Parameters
[in]y[in] second vector in inner product (x,y) or y^H x

Definition at line 459 of file SPIVec.cpp.

◆ imag()

SPIVec & SPI::SPIVec::imag ( )

take the imaginary part of the vector

Returns
the vector after taking the imaginary part of it

Definition at line 454 of file SPIVec.cpp.

◆ Init()

PetscInt SPI::SPIVec::Init ( const PetscInt  _rows,
const std::string  _name = "SPIVec" 
)

initialize the vector of size _rows

Returns
0 if successful
Parameters
[in]_rows[in] number of rows to initialize vector
[in]_name[in] name of SPIVec (important with hdf5 i/o)

Definition at line 44 of file SPIVec.cpp.

◆ max()

PetscScalar SPI::SPIVec::max ( )

maximum value of vector

Returns
scalar maximum value of the vector (broadcasted to all processors)

Definition at line 425 of file SPIVec.cpp.

◆ operator()() [1/6]

SPIVec & SPI::SPIVec::operator() ( )

assemble the vector

Returns
SPIVec of assembled vector

Definition at line 170 of file SPIVec.cpp.

◆ operator()() [2/6]

PetscInt SPI::SPIVec::operator() ( PetscInt  _row,
const double  v 
)

same as above

Definition at line 158 of file SPIVec.cpp.

◆ operator()() [3/6]

PetscInt SPI::SPIVec::operator() ( PetscInt  _row,
const int  v 
)

same as above

Definition at line 163 of file SPIVec.cpp.

◆ operator()() [4/6]

PetscInt SPI::SPIVec::operator() ( PetscInt  _row,
const PetscScalar  v 
)

set operator the same as set function

Returns
0 if successful
Parameters
[in]_row[in] row to set the value
[in]v[in] value to set in the row

Definition at line 145 of file SPIVec.cpp.

◆ operator()() [5/6]

PetscScalar SPI::SPIVec::operator() ( PetscInt  _row,
PetscBool  global = PETSC_FALSE 
)

get value at row (on all processors)

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

Definition at line 125 of file SPIVec.cpp.

◆ operator()() [6/6]

PetscScalar SPI::SPIVec::operator() ( PetscInt  _row,
PetscBool  global = PETSC_FALSE 
) const

get value at row (on all processors)

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

Definition at line 105 of file SPIVec.cpp.

◆ operator*() [1/3]

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

same as above

Definition at line 280 of file SPIVec.cpp.

◆ operator*() [2/3]

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

Y*a operation

Returns
Z in Z=Y*a
Parameters
[in]a[in] a in Z=Y*a operation

Definition at line 271 of file SPIVec.cpp.

◆ operator*() [3/3]

SPIVec SPI::SPIVec::operator* ( const SPIVec X)

Y*X pointwise multiply operation

Returns
Z in Z=Y*X operation
Parameters
[in]X[in] X in Z=Y*X operation

Definition at line 311 of file SPIVec.cpp.

◆ operator*=() [1/3]

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

Y = Y*a operation

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

Definition at line 296 of file SPIVec.cpp.

◆ operator*=() [2/3]

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

Y = Y*a operation

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

Definition at line 289 of file SPIVec.cpp.

◆ operator*=() [3/3]

SPIVec & SPI::SPIVec::operator*= ( const SPIVec a)

Y = Y*a operation

Returns
Y in Y*=a
Parameters
[in]a[in] SPIVec a in Y*=a operation

Definition at line 303 of file SPIVec.cpp.

◆ operator+() [1/3]

SPIVec SPI::SPIVec::operator+ ( const double  a)

Y+a operation

Returns
SPIVec Z=Y+a
Parameters
[in]a[in] scalar a in Y+a operation

Definition at line 216 of file SPIVec.cpp.

◆ operator+() [2/3]

SPIVec SPI::SPIVec::operator+ ( const PetscScalar  a)

Y+a operation

Returns
SPIVec Z=Y+a
Parameters
[in]a[in] scalar a in Y+a operation

Definition at line 207 of file SPIVec.cpp.

◆ operator+() [3/3]

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

Y+X operation

Returns
SPIVec Z=Y+X
Parameters
[in]X[in] X in Z=Y+X operation

Definition at line 193 of file SPIVec.cpp.

◆ operator+=()

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

VecAXPY Y = 1.*X + Y operation

Returns
SPIVec Y
Parameters
[in]X[in] X in Y += X operation

Definition at line 177 of file SPIVec.cpp.

◆ operator-() [1/4]

SPIVec SPI::SPIVec::operator- ( ) const

-X operation

Returns
Z in Z=-X operation

Definition at line 266 of file SPIVec.cpp.

◆ operator-() [2/4]

SPIVec SPI::SPIVec::operator- ( const PetscInt  a)

Y-a operation

Returns
Z in Z=Y-a
Parameters
[in]a[in] scalar a in Y-a operation

Definition at line 234 of file SPIVec.cpp.

◆ operator-() [3/4]

SPIVec SPI::SPIVec::operator- ( const PetscScalar  a)

Y-a operation

Returns
Z in Z=Y-a
Parameters
[in]a[in] scalar a in Y-a operation

Definition at line 225 of file SPIVec.cpp.

◆ operator-() [4/4]

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

Y - X operation

Returns
Z in Z=Y-X operation
Parameters
[in]X[in] X in Y-X operation

Definition at line 252 of file SPIVec.cpp.

◆ operator-=()

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

Y = -1.*X + Y operation

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

Definition at line 244 of file SPIVec.cpp.

◆ operator/() [1/3]

SPIVec SPI::SPIVec::operator/ ( const double  a)

same as above

Definition at line 332 of file SPIVec.cpp.

◆ operator/() [2/3]

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

pointwise divide by scalar a

Returns
Z in Z=Y/a operation
Parameters
[in]a[in] scalar a in Z=Y/a operation

Definition at line 323 of file SPIVec.cpp.

◆ operator/() [3/3]

SPIVec SPI::SPIVec::operator/ ( const SPIVec  X)

pointwise divide by X

Returns
Z in Z=Y/X operation
Parameters
[in]X[in] X in Z=Y/X operation

Definition at line 340 of file SPIVec.cpp.

◆ operator/=()

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

Y = Y*a pointwise divide operation

Returns
Y in Y/=a operation
Parameters
[in]a[in] scalar a in Y/=a operation

Definition at line 349 of file SPIVec.cpp.

◆ operator=()

SPIVec & SPI::SPIVec::operator= ( const SPIVec X)

Y=X with initialization of Y using VecCopy and VecDuplicate

Returns
Y initialized and copied of X

Definition at line 382 of file SPIVec.cpp.

◆ operator==()

PetscBool SPI::SPIVec::operator== ( const SPIVec x2)

== VecEqual test if this==x2

Returns
PETSC_TRUE if this==x2
Parameters
[in]x2[in] x2 in test

Definition at line 404 of file SPIVec.cpp.

◆ operator^() [1/4]

SPIVec SPI::SPIVec::operator^ ( const double  p)

pow operation pow(this,p)

Parameters
[in]p[in] exponent of this^p operation

Definition at line 363 of file SPIVec.cpp.

◆ operator^() [2/4]

SPIVec SPI::SPIVec::operator^ ( const int  p)

pow operation pow(this,p)

Parameters
[in]p[in] exponent of this^p operation

Definition at line 369 of file SPIVec.cpp.

◆ operator^() [3/4]

SPIVec SPI::SPIVec::operator^ ( const PetscScalar  p)

pow operation pow(this,p)

Parameters
[in]p[in] exponent of this^p operation

Definition at line 357 of file SPIVec.cpp.

◆ operator^() [4/4]

SPIVec SPI::SPIVec::operator^ ( SPIVec  p)

pow operation pow(this,p)

Parameters
[in]p[in] exponent of this^p operation

Definition at line 375 of file SPIVec.cpp.

◆ print()

PetscInt SPI::SPIVec::print ( )

print vec to screen using PETSC_VIEWER_STDOUT_WORLD

Returns
0 if successful

Definition at line 470 of file SPIVec.cpp.

◆ real()

SPIVec & SPI::SPIVec::real ( )

take the real part of the vector

Returns
the vector after taking the real part of it

Definition at line 449 of file SPIVec.cpp.

◆ set() [1/2]

PetscInt SPI::SPIVec::set ( const PetscInt  _row,
const PetscScalar  v 
)

set a scalar value at a position row if owned by processor

Returns
0 if successful
Parameters
[in]_row[in] position to set value
[in]v[in] value to set in vec

Definition at line 64 of file SPIVec.cpp.

◆ set() [2/2]

PetscInt SPI::SPIVec::set ( const PetscScalar  v)

set a scalar value at all positions

Returns
0 if successful
Parameters
[in]v[in] value to set in vec

Definition at line 76 of file SPIVec.cpp.

◆ size()

PetscInt SPI::SPIVec::size ( )

get the global size of the vector

Definition at line 96 of file SPIVec.cpp.

Field Documentation

◆ flag_init

PetscBool SPI::SPIVec::flag_init =PETSC_FALSE

flag if it has been initialized

Definition at line 25 of file SPIVec.hpp.

◆ ierr

PetscErrorCode SPI::SPIVec::ierr

ierr for various routines and operators

Definition at line 22 of file SPIVec.hpp.

◆ name

std::string SPI::SPIVec::name

Vec name (important for hdf5 i/o)

Definition at line 26 of file SPIVec.hpp.

◆ rows

PetscInt SPI::SPIVec::rows =0

number of rows in vec

Definition at line 14 of file SPIVec.hpp.

◆ vec

Vec SPI::SPIVec::vec

petsc Vec data

Definition at line 21 of file SPIVec.hpp.


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