Quandary
Loading...
Searching...
No Matches
Functions
mastereq.cpp File Reference
#include "mastereq.hpp"
Include dependency graph for mastereq.cpp:

Functions

int applyRHS_sparsemat (Mat RHS, Vec x, Vec y)
 Sparse matrix MatMult.
 
int applyRHS_sparsemat_transpose (Mat RHS, Vec x, Vec y)
 Transpose sparse matrix MatMult.
 
void compute_dRHS_dParams_sparsemat (const double t, const Vec x, const Vec xbar, const double alpha, Vec grad, std::vector< size_t > &nlevels, IS isu, IS isv, std::vector< Mat > &Ac_vec, std::vector< Mat > &Bc_vec, Vec aux, Oscillator **oscil_vec)
 : Sparse-matrix version to compute gradient of RHS with respect to parameters
 
void compute_dRHS_dParams_matfree (const PetscInt dim, const double t, const Vec x, const Vec xbar, const double alpha, Vec grad, std::vector< size_t > &nlevels, DecoherenceType decoherence_type, Oscillator **oscil_vec)
 : Matrix free version to compute gradient of RHS with respect to parameters
 
template<int n0>
int applyRHS_matfree (Mat RHS, Vec x, Vec y)
 
template<int n0>
int applyRHS_matfree_transpose (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1>
int applyRHS_matfree (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1>
int applyRHS_matfree_transpose (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2>
int applyRHS_matfree (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2>
int applyRHS_matfree_transpose (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2, int n3>
int applyRHS_matfree (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2, int n3>
int applyRHS_matfree_transpose (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2, int n3, int n4>
int applyRHS_matfree (Mat RHS, Vec x, Vec y)
 
template<int n0, int n1, int n2, int n3, int n4>
int applyRHS_matfree_transpose (Mat RHS, Vec x, Vec y)
 
int applyRHS_matfree_1Osc (Mat RHS, Vec x, Vec y)
 Matrix-vector products to apply the RHS system matrix to a state vector.
 
int applyRHS_matfree_transpose_1Osc (Mat RHS, Vec x, Vec y)
 Transpose matrix-free MatMult for 1 oscillator.
 
int applyRHS_matfree_2Osc (Mat RHS, Vec x, Vec y)
 Matrix-free MatMult for 2 oscillators.
 
int applyRHS_matfree_transpose_2Osc (Mat RHS, Vec x, Vec y)
 Transpose matrix-free MatMult for 2 oscillators.
 
int applyRHS_matfree_3Osc (Mat RHS, Vec x, Vec y)
 Matrix-free MatMult for 3 oscillators.
 
int applyRHS_matfree_transpose_3Osc (Mat RHS, Vec x, Vec y)
 Transpose matrix-free MatMult for 3 oscillators.
 
int applyRHS_matfree_4Osc (Mat RHS, Vec x, Vec y)
 Matrix-free MatMult for 4 oscillators.
 
int applyRHS_matfree_transpose_4Osc (Mat RHS, Vec x, Vec y)
 Transpose matrix-free MatMult for 4 oscillators.
 
int applyRHS_matfree_5Osc (Mat RHS, Vec x, Vec y)
 Matrix-free MatMult for 5 oscillators.
 
int applyRHS_matfree_transpose_5Osc (Mat RHS, Vec x, Vec y)
 Transpose matrix-free MatMult for 5 oscillators.
 

Function Documentation

◆ applyRHS_matfree() [1/5]

template<int n0>
int applyRHS_matfree ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree() [2/5]

template<int n0, int n1>
int applyRHS_matfree ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree() [3/5]

template<int n0, int n1, int n2>
int applyRHS_matfree ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree() [4/5]

template<int n0, int n1, int n2, int n3>
int applyRHS_matfree ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree() [5/5]

template<int n0, int n1, int n2, int n3, int n4>
int applyRHS_matfree ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_1Osc()

int applyRHS_matfree_1Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Matrix-vector products to apply the RHS system matrix to a state vector.

Each function returns y = RHS*x. Matrix-free versions as well as sparse-matrix versions are implemented. Those functions will be passed to PETSc's MatMult operations to realize a Matrix-Vector Multiplication of the RHS with a state vector, such that one can call PETSc's MatMult(RHS, x, y) for the RHS. Note: The RHS matrix must be assembled before usage, see MasterEq::assemble_RHS. Matrix-free MatMult for 1 oscillator

◆ applyRHS_matfree_2Osc()

int applyRHS_matfree_2Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Matrix-free MatMult for 2 oscillators.

◆ applyRHS_matfree_3Osc()

int applyRHS_matfree_3Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Matrix-free MatMult for 3 oscillators.

◆ applyRHS_matfree_4Osc()

int applyRHS_matfree_4Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Matrix-free MatMult for 4 oscillators.

◆ applyRHS_matfree_5Osc()

int applyRHS_matfree_5Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Matrix-free MatMult for 5 oscillators.

◆ applyRHS_matfree_transpose() [1/5]

template<int n0>
int applyRHS_matfree_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_transpose() [2/5]

template<int n0, int n1>
int applyRHS_matfree_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_transpose() [3/5]

template<int n0, int n1, int n2>
int applyRHS_matfree_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_transpose() [4/5]

template<int n0, int n1, int n2, int n3>
int applyRHS_matfree_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_transpose() [5/5]

template<int n0, int n1, int n2, int n3, int n4>
int applyRHS_matfree_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

◆ applyRHS_matfree_transpose_1Osc()

int applyRHS_matfree_transpose_1Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose matrix-free MatMult for 1 oscillator.

◆ applyRHS_matfree_transpose_2Osc()

int applyRHS_matfree_transpose_2Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose matrix-free MatMult for 2 oscillators.

◆ applyRHS_matfree_transpose_3Osc()

int applyRHS_matfree_transpose_3Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose matrix-free MatMult for 3 oscillators.

◆ applyRHS_matfree_transpose_4Osc()

int applyRHS_matfree_transpose_4Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose matrix-free MatMult for 4 oscillators.

◆ applyRHS_matfree_transpose_5Osc()

int applyRHS_matfree_transpose_5Osc ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose matrix-free MatMult for 5 oscillators.

◆ applyRHS_sparsemat()

int applyRHS_sparsemat ( Mat  RHS,
Vec  x,
Vec  y 
)

Sparse matrix MatMult.

◆ applyRHS_sparsemat_transpose()

int applyRHS_sparsemat_transpose ( Mat  RHS,
Vec  x,
Vec  y 
)

Transpose sparse matrix MatMult.

◆ compute_dRHS_dParams_matfree()

void compute_dRHS_dParams_matfree ( const PetscInt  dim,
const double  t,
const Vec  x,
const Vec  x_bar,
const double  alpha,
Vec  grad,
std::vector< size_t > &  nlevels,
DecoherenceType  decoherence_type,
Oscillator **  oscil_vec 
)

: Matrix free version to compute gradient of RHS with respect to parameters

Updates grad += alpha * x^T * (d RHS / d params)^T * x_bar in a matrix-free manner. See compute_dRHS_dParams_sparsemat for the sparse-matrix version of this routine.

Parameters
[in]dimDimension of full vectorized system: N^2 if Lindblad, N if Schroedinger
[in]tCurrent time
[in]xState vector
[in]x_barAdjoint state vector
[in]alphaScaling factor
[out]gradGradient vector to update
[in]nlevelsNumber of energy levels per subsystem
[in]decoherence_typeType of Lindblad decoherence operators, or NONE
[in]oscil_vecVector of quantum oscillators

◆ compute_dRHS_dParams_sparsemat()

void compute_dRHS_dParams_sparsemat ( const double  t,
const Vec  x,
const Vec  x_bar,
const double  alpha,
Vec  grad,
std::vector< size_t > &  nlevels,
IS  isu,
IS  isv,
std::vector< Mat > &  Ac_vec,
std::vector< Mat > &  Bc_vec,
Vec  aux,
Oscillator **  oscil_vec 
)

: Sparse-matrix version to compute gradient of RHS with respect to parameters

Updates grad += alpha * x^T * (d RHS / d params)^T * x_bar with sparse-matrix version of RHS. Compare compute_dRHS_dParams_matfree for the matrix-free version of this routine.

Parameters
[in]tCurrent time
[in]xState vector
[in]x_barAdjoint state vector
[in]alphaScaling factor
[out]gradGradient vector to update
[in]nlevelsNumber of energy levels per subsystem
[in]isuIndex stride to access real parts of a state vector
[in]isvIndex stride to access imaginar parts of a state vector
[in]Ac_vecVector of real parts of control matrices per oscillator
[in]Bc_vecVector of imaginary parts of control matrices per oscillator
[in]auxAuxiliary vector for computations
[in]oscil_vecVector of quantum oscilators