Teko Version of the Day
Loading...
Searching...
No Matches
Functions
Teko_Utilities.hpp File Reference
#include "Teko_ConfigDefs.hpp"
#include "Tpetra_CrsMatrix.hpp"
#include "Teuchos_VerboseObject.hpp"
#include "Thyra_LinearOpBase.hpp"
#include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
#include "Thyra_ProductVectorSpaceBase.hpp"
#include "Thyra_VectorSpaceBase.hpp"
#include "Thyra_ProductMultiVectorBase.hpp"
#include "Thyra_MultiVectorStdOps.hpp"
#include "Thyra_MultiVectorBase.hpp"
#include "Thyra_VectorBase.hpp"
#include "Thyra_VectorStdOps.hpp"
#include "Thyra_DefaultBlockedLinearOp.hpp"
#include "Thyra_DefaultMultipliedLinearOp.hpp"
#include "Thyra_DefaultScaledAdjointLinearOp.hpp"
#include "Thyra_DefaultAddedLinearOp.hpp"
#include "Thyra_DefaultIdentityLinearOp.hpp"
#include "Thyra_DefaultZeroLinearOp.hpp"

Go to the source code of this file.

Functions

RCP< Tpetra::CrsMatrix< ST, LO, GO, NT > > Teko::buildGraphLaplacian (int dim, ST *coords, const Tpetra::CrsMatrix< ST, LO, GO, NT > &stencil)
 Build a graph Laplacian stenciled on a Epetra_CrsMatrix.
 
RCP< Tpetra::CrsMatrix< ST, LO, GO, NT > > Teko::buildGraphLaplacian (ST *x, ST *y, ST *z, GO stride, const Tpetra::CrsMatrix< ST, LO, GO, NT > &stencil)
 Build a graph Laplacian stenciled on a Epetra_CrsMatrix.
 
const Teuchos::RCP< Teuchos::FancyOStream > Teko::getOutputStream ()
 Function used internally by Teko to find the output stream.
 
Mathematical functions
void Teko::applyOp (const LinearOp &A, const MultiVector &x, MultiVector &y, double alpha, double beta)
 Apply a linear operator to a multivector (think of this as a matrix vector multiply).
 
void Teko::applyTransposeOp (const LinearOp &A, const MultiVector &x, MultiVector &y, double alpha, double beta)
 Apply a transposed linear operator to a multivector (think of this as a matrix vector multiply).
 
void Teko::applyOp (const LinearOp &A, const BlockedMultiVector &x, BlockedMultiVector &y, double alpha=1.0, double beta=0.0)
 Apply a linear operator to a blocked multivector (think of this as a matrix vector multiply).
 
void Teko::applyTransposeOp (const LinearOp &A, const BlockedMultiVector &x, BlockedMultiVector &y, double alpha=1.0, double beta=0.0)
 Apply a transposed linear operator to a blocked multivector (think of this as a matrix vector multiply).
 
void Teko::update (double alpha, const MultiVector &x, double beta, MultiVector &y)
 Update the y vector so that $y = \alpha x+\beta y$.
 
void Teko::update (double alpha, const BlockedMultiVector &x, double beta, BlockedMultiVector &y)
 Update for a BlockedMultiVector.
 
void Teko::scale (const double alpha, MultiVector &x)
 Scale a multivector by a constant.
 
void Teko::scale (const double alpha, BlockedMultiVector &x)
 Scale a multivector by a constant.
 
LinearOp Teko::scale (const double alpha, ModifiableLinearOp &a)
 Scale a modifiable linear op by a constant.
 
LinearOp Teko::adjoint (ModifiableLinearOp &a)
 Construct an implicit adjoint of the linear operators.
 

Epetra_Operator specific functions

enum  Teko::DiagonalType {
  Teko::Diagonal , Teko::Lumped , Teko::AbsRowSum , Teko::BlkDiag ,
  Teko::NotDiag
}
 Type describing the type of diagonal to construct. More...
 
const ModifiableLinearOp Teko::getDiagonalOp (const LinearOp &op)
 Get the diaonal of a linear operator.
 
const MultiVector Teko::getDiagonal (const LinearOp &op)
 Get the diagonal of a linear operator.
 
const ModifiableLinearOp Teko::getInvDiagonalOp (const LinearOp &op)
 Get the diaonal of a linear operator.
 
const LinearOp Teko::explicitMultiply (const LinearOp &opl, const LinearOp &opm, const LinearOp &opr)
 Multiply three linear operators.
 
const ModifiableLinearOp Teko::explicitMultiply (const LinearOp &opl, const LinearOp &opm, const LinearOp &opr, const ModifiableLinearOp &destOp)
 Multiply three linear operators.
 
const LinearOp Teko::explicitMultiply (const LinearOp &opl, const LinearOp &opr)
 Multiply two linear operators.
 
const ModifiableLinearOp Teko::explicitMultiply (const LinearOp &opl, const LinearOp &opr, const ModifiableLinearOp &destOp)
 Multiply two linear operators.
 
const LinearOp Teko::explicitAdd (const LinearOp &opl_in, const LinearOp &opr_in)
 Add two linear operators.
 
const ModifiableLinearOp Teko::explicitAdd (const LinearOp &opl, const LinearOp &opr, const ModifiableLinearOp &destOp)
 Add two linear operators.
 
const ModifiableLinearOp Teko::explicitSum (const LinearOp &op, const ModifiableLinearOp &destOp)
 Sum an operator.
 
const LinearOp Teko::explicitTranspose (const LinearOp &op)
 
double Teko::frobeniusNorm (const LinearOp &op_in)
 
double Teko::oneNorm (const LinearOp &op)
 
double Teko::infNorm (const LinearOp &op)
 
const LinearOp Teko::buildDiagonal (const MultiVector &v, const std::string &lbl="ANYM")
 Take the first column of a multivector and build a diagonal linear operator.
 
const LinearOp Teko::buildInvDiagonal (const MultiVector &v, const std::string &lbl="ANYM")
 Using the first column of a multivector, take the elementwise build a inverse and build the inverse diagonal operator.
 
double Teko::computeSpectralRad (const Teuchos::RCP< const Thyra::LinearOpBase< double > > &A, double tol, bool isHermitian=false, int numBlocks=5, int restart=0, int verbosity=0)
 Compute the spectral radius of a matrix.
 
double Teko::computeSmallestMagEig (const Teuchos::RCP< const Thyra::LinearOpBase< double > > &A, double tol, bool isHermitian=false, int numBlocks=5, int restart=0, int verbosity=0)
 Compute the smallest eigenvalue of an operator.
 
ModifiableLinearOp Teko::getDiagonalOp (const Teko::LinearOp &A, const DiagonalType &dt)
 
ModifiableLinearOp Teko::getInvDiagonalOp (const Teko::LinearOp &A, const Teko::DiagonalType &dt)
 
const MultiVector Teko::getDiagonal (const LinearOp &op, const DiagonalType &dt)
 Get the diagonal of a sparse linear operator.
 
std::string Teko::getDiagonalName (const DiagonalType &dt)
 
DiagonalType Teko::getDiagonalType (std::string name)
 
double Teko::norm_1 (const MultiVector &v, std::size_t col)
 
double Teko::norm_2 (const MultiVector &v, std::size_t col)
 

MultiVector utilities

typedef Teuchos::RCP< Thyra::ProductMultiVectorBase< double > > Teko::BlockedMultiVector
 
typedef Teuchos::RCP< Thyra::MultiVectorBase< double > > Teko::MultiVector
 
MultiVector Teko::toMultiVector (BlockedMultiVector &bmv)
 Convert to a MultiVector from a BlockedMultiVector.
 
const MultiVector Teko::toMultiVector (const BlockedMultiVector &bmv)
 Convert to a MultiVector from a BlockedMultiVector.
 
const BlockedMultiVector Teko::toBlockedMultiVector (const MultiVector &bmv)
 Convert to a BlockedMultiVector from a MultiVector.
 
int Teko::blockCount (const BlockedMultiVector &bmv)
 Get the column count in a block linear operator.
 
MultiVector Teko::getBlock (int i, const BlockedMultiVector &bmv)
 Get the ith block from a BlockedMultiVector object.
 
MultiVector Teko::deepcopy (const MultiVector &v)
 Perform a deep copy of the vector.
 
MultiVector Teko::copyAndInit (const MultiVector &v, double scalar)
 Perform a deep copy of the vector.
 
BlockedMultiVector Teko::deepcopy (const BlockedMultiVector &v)
 Perform a deep copy of the blocked vector.
 
MultiVector Teko::datacopy (const MultiVector &src, MultiVector &dst)
 Copy the contents of a multivector to a destination vector.
 
BlockedMultiVector Teko::datacopy (const BlockedMultiVector &src, BlockedMultiVector &dst)
 Copy the contents of a blocked multivector to a destination vector.
 
BlockedMultiVector Teko::buildBlockedMultiVector (const std::vector< MultiVector > &mvv)
 build a BlockedMultiVector from a vector of MultiVectors
 
Teuchos::RCP< Thyra::VectorBase< double > > Teko::indicatorVector (const std::vector< int > &indices, const VectorSpace &vs, double onValue, double offValue)
 

LinearOp utilities

typedef Teuchos::RCP< Thyra::PhysicallyBlockedLinearOpBase< ST > > Teko::BlockedLinearOp
 
typedef Teuchos::RCP< const Thyra::LinearOpBase< ST > > Teko::LinearOp
 
typedef Teuchos::RCP< Thyra::LinearOpBase< ST > > Teko::InverseLinearOp
 
typedef Teuchos::RCP< Thyra::LinearOpBase< ST > > Teko::ModifiableLinearOp
 
LinearOp Teko::zero (const VectorSpace &vs)
 Build a square zero operator from a single vector space.
 
VectorSpace Teko::rangeSpace (const LinearOp &lo)
 Replace nonzeros with a scalar value, used to zero out an operator.
 
VectorSpace Teko::domainSpace (const LinearOp &lo)
 Get the domain space of a linear operator.
 
BlockedLinearOp Teko::toBlockedLinearOp (LinearOp &clo)
 Converts a LinearOp to a BlockedLinearOp.
 
const BlockedLinearOp Teko::toBlockedLinearOp (const LinearOp &clo)
 Converts a LinearOp to a BlockedLinearOp.
 
LinearOp Teko::toLinearOp (BlockedLinearOp &blo)
 Convert to a LinearOp from a BlockedLinearOp.
 
const LinearOp Teko::toLinearOp (const BlockedLinearOp &blo)
 Convert to a LinearOp from a BlockedLinearOp.
 
LinearOp Teko::toLinearOp (ModifiableLinearOp &blo)
 Convert to a LinearOp from a BlockedLinearOp.
 
const LinearOp Teko::toLinearOp (const ModifiableLinearOp &blo)
 Convert to a LinearOp from a BlockedLinearOp.
 
int Teko::blockRowCount (const BlockedLinearOp &blo)
 Get the row count in a block linear operator.
 
int Teko::blockColCount (const BlockedLinearOp &blo)
 Get the column count in a block linear operator.
 
LinearOp Teko::getBlock (int i, int j, const BlockedLinearOp &blo)
 Get the i,j block in a BlockedLinearOp object.
 
void Teko::setBlock (int i, int j, BlockedLinearOp &blo, const LinearOp &lo)
 Set the i,j block in a BlockedLinearOp object.
 
BlockedLinearOp Teko::createBlockedOp ()
 Build a new blocked linear operator.
 
void Teko::beginBlockFill (BlockedLinearOp &blo, int rowCnt, int colCnt)
 Let the blocked operator know that you are going to set the sub blocks.
 
void Teko::beginBlockFill (BlockedLinearOp &blo)
 Let the blocked operator know that you are going to set the sub blocks.
 
void Teko::endBlockFill (BlockedLinearOp &blo)
 Notify the blocked operator that the fill stage is completed.
 
BlockedLinearOp Teko::getUpperTriBlocks (const BlockedLinearOp &blo, bool callEndBlockFill)
 Get the strictly upper triangular portion of the matrix.
 
BlockedLinearOp Teko::getLowerTriBlocks (const BlockedLinearOp &blo, bool callEndBlockFill)
 Get the strictly lower triangular portion of the matrix.
 
BlockedLinearOp Teko::zeroBlockedOp (const BlockedLinearOp &blo)
 Build a zero operator mimicing the block structure of the passed in matrix.
 
bool Teko::isZeroOp (const LinearOp op)
 Figure out if this operator is the zero operator (or null!)
 
ModifiableLinearOp Teko::getAbsRowSumMatrix (const LinearOp &op)
 Compute absolute row sum matrix.
 
ModifiableLinearOp Teko::getAbsRowSumInvMatrix (const LinearOp &op)
 Compute inverse of the absolute row sum matrix.
 
ModifiableLinearOp Teko::getLumpedMatrix (const LinearOp &op)
 Compute the lumped version of this matrix.
 
ModifiableLinearOp Teko::getInvLumpedMatrix (const LinearOp &op)
 Compute the inverse of the lumped version of this matrix.
 

Detailed Description

This file contains a number of useful functions and classes used in Teko. They are distinct from the core functionality of the preconditioner factory, however, the functions are critical to construction of the preconditioners themselves.

Definition in file Teko_Utilities.hpp.

Enumeration Type Documentation

◆ DiagonalType

Type describing the type of diagonal to construct.

Enumerator
Diagonal 

Specifies that just the diagonal is used.

Lumped 

Specifies that row sum is used to form a diagonal.

AbsRowSum 

Specifies that the $i^{th}$ diagonal entry is $\sum_j |A_{ij}|$.

BlkDiag 

Specifies that a block diagonal approximation is to be used.

NotDiag 

For user convenience, if Teko recieves this value, exceptions will be thrown.

Definition at line 823 of file Teko_Utilities.hpp.

Function Documentation

◆ buildGraphLaplacian() [1/2]

Teuchos::RCP< Tpetra::CrsMatrix< ST, LO, GO, NT > > Teko::buildGraphLaplacian ( int  dim,
ST *  coords,
const Tpetra::CrsMatrix< ST, LO, GO, NT > &  stencil 
)

Build a graph Laplacian stenciled on a Epetra_CrsMatrix.

This function builds a graph Laplacian given a (locally complete) vector of coordinates and a stencil Epetra_CrsMatrix (could this be a graph of Epetra_RowMatrix instead?). The resulting matrix will have the negative of the inverse distance on off diagonals. And the sum of the positive inverse distance of the off diagonals on the diagonal. If there are no off diagonal entries in the stencil, the diagonal is set to 0.

Parameters
[in]dimNumber of physical dimensions (2D or 3D?).
[in]coordsA vector containing the coordinates, with the i-th coordinate beginning at coords[i*dim].
[in]stencilThe stencil matrix used to describe the connectivity of the graph Laplacian matrix.
Returns
The graph Laplacian matrix to be filled according to the stencil matrix.

This function builds a graph Laplacian given a (locally complete) vector of coordinates and a stencil Epetra_CrsMatrix (could this be a graph of Epetra_RowMatrix instead?). The resulting matrix will have the negative of the inverse distance on off diagonals. And the sum of the positive inverse distance of the off diagonals on the diagonal. If there are no off diagonal entries in the stencil, the diagonal is set to 0.

Parameters
[in]dimNumber of physical dimensions (2D or 3D?).
[in]coordsA vector containing the coordinates, with the i-th coordinate beginning at coords[i*dim].
[in]stencilThe stencil matrix used to describe the connectivity of the graph Laplacian matrix.
Returns
The graph Laplacian matrix to be filled according to the stencil matrix.

Definition at line 239 of file Teko_Utilities.cpp.

◆ buildGraphLaplacian() [2/2]

Teuchos::RCP< Tpetra::CrsMatrix< ST, LO, GO, NT > > Teko::buildGraphLaplacian ( ST *  x,
ST *  y,
ST *  z,
GO  stride,
const Tpetra::CrsMatrix< ST, LO, GO, NT > &  stencil 
)

Build a graph Laplacian stenciled on a Epetra_CrsMatrix.

This function builds a graph Laplacian given a (locally complete) vector of coordinates and a stencil Epetra_CrsMatrix (could this be a graph of Epetra_RowMatrix instead?). The resulting matrix will have the negative of the inverse distance on off diagonals. And the sum of the positive inverse distance of the off diagonals on the diagonal. If there are no off diagonal entries in the stencil, the diagonal is set to 0.

Parameters
[in]xA vector containing the x-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]yA vector containing the y-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]zA vector containing the z-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]strideStride between entries in the (x,y,z) coordinate array
[in]stencilThe stencil matrix used to describe the connectivity of the graph Laplacian matrix.
Returns
The graph Laplacian matrix to be filled according to the stencil matrix.

This function builds a graph Laplacian given a (locally complete) vector of coordinates and a stencil Epetra_CrsMatrix (could this be a graph of Epetra_RowMatrix instead?). The resulting matrix will have the negative of the inverse distance on off diagonals. And the sum of the positive inverse distance of the off diagonals on the diagonal. If there are no off diagonal entries in the stencil, the diagonal is set to 0.

Parameters
[in]xA vector containing the x-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]yA vector containing the y-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]zA vector containing the z-coordinates, with the i-th coordinate beginning at coords[i*stride].
[in]strideStride between entries in the (x,y,z) coordinate array
[in]stencilThe stencil matrix used to describe the connectivity of the graph Laplacian matrix.
Returns
The graph Laplacian matrix to be filled according to the stencil matrix.

Definition at line 379 of file Teko_Utilities.cpp.

◆ getOutputStream()

const Teuchos::RCP< Teuchos::FancyOStream > Teko::getOutputStream ( )

Function used internally by Teko to find the output stream.

Function used internally by Teko to find the output stream.

Returns
An output stream to use for printing

Definition at line 128 of file Teko_Utilities.cpp.

◆ toMultiVector() [1/2]

MultiVector Teko::toMultiVector ( BlockedMultiVector &  bmv)
inline

Convert to a MultiVector from a BlockedMultiVector.

Definition at line 219 of file Teko_Utilities.hpp.

◆ toMultiVector() [2/2]

const MultiVector Teko::toMultiVector ( const BlockedMultiVector &  bmv)
inline

Convert to a MultiVector from a BlockedMultiVector.

Definition at line 222 of file Teko_Utilities.hpp.

◆ toBlockedMultiVector()

const BlockedMultiVector Teko::toBlockedMultiVector ( const MultiVector &  bmv)
inline

Convert to a BlockedMultiVector from a MultiVector.

Definition at line 225 of file Teko_Utilities.hpp.

◆ blockCount()

int Teko::blockCount ( const BlockedMultiVector &  bmv)
inline

Get the column count in a block linear operator.

Definition at line 229 of file Teko_Utilities.hpp.

◆ getBlock() [1/2]

MultiVector Teko::getBlock ( int  i,
const BlockedMultiVector &  bmv 
)
inline

Get the ith block from a BlockedMultiVector object.

Definition at line 233 of file Teko_Utilities.hpp.

◆ deepcopy() [1/2]

MultiVector Teko::deepcopy ( const MultiVector &  v)
inline

Perform a deep copy of the vector.

Definition at line 237 of file Teko_Utilities.hpp.

◆ copyAndInit()

MultiVector Teko::copyAndInit ( const MultiVector &  v,
double  scalar 
)
inline

Perform a deep copy of the vector.

Definition at line 241 of file Teko_Utilities.hpp.

◆ deepcopy() [2/2]

BlockedMultiVector Teko::deepcopy ( const BlockedMultiVector &  v)
inline

Perform a deep copy of the blocked vector.

Definition at line 245 of file Teko_Utilities.hpp.

◆ datacopy() [1/2]

MultiVector Teko::datacopy ( const MultiVector &  src,
MultiVector &  dst 
)
inline

Copy the contents of a multivector to a destination vector.

Copy the contents of a multivector to a new vector. If the destination vector is null, a deep copy of the source multivector is made to a newly allocated vector. Also, if the destination and the source do not match, a new destination object is allocated and returned to the user.

Parameters
[in]srcSource multivector to be copied.
[in]dstDestination multivector. If null a new multivector will be allocated.
Returns
A copy of the source multivector. If dst is not null a pointer to this object is returned. Otherwise a new multivector is returned.

Definition at line 261 of file Teko_Utilities.hpp.

◆ datacopy() [2/2]

BlockedMultiVector Teko::datacopy ( const BlockedMultiVector &  src,
BlockedMultiVector &  dst 
)
inline

Copy the contents of a blocked multivector to a destination vector.

Copy the contents of a blocked multivector to a new vector. If the destination vector is null, a deep copy of the source multivector is made to a newly allocated vector. Also, if the destination and the source do not match, a new destination object is allocated and returned to the user.

Parameters
[in]srcSource multivector to be copied.
[in]dstDestination multivector. If null a new multivector will be allocated.
Returns
A copy of the source multivector. If dst is not null a pointer to this object is returned. Otherwise a new multivector is returned.

Definition at line 290 of file Teko_Utilities.hpp.

◆ buildBlockedMultiVector()

BlockedMultiVector Teko::buildBlockedMultiVector ( const std::vector< MultiVector > &  mvv)

build a BlockedMultiVector from a vector of MultiVectors

Definition at line 2254 of file Teko_Utilities.cpp.

◆ indicatorVector()

Teuchos::RCP< Thyra::VectorBase< double > > Teko::indicatorVector ( const std::vector< int > &  indices,
const VectorSpace &  vs,
double  onValue,
double  offValue 
)

Construct an indicator vector specified by a vector of indices to be set to `‘on’'.

Parameters
[in]indicesVector of indicies to turn on
[in]vsVector space to construct the vector from
[in]onValueValue to set in the vector to on
[in]offValueValue to set in the vector to off
Returns
Vector of on and off values.

Definition at line 2283 of file Teko_Utilities.cpp.

◆ zero()

LinearOp Teko::zero ( const VectorSpace &  vs)
inline

Build a square zero operator from a single vector space.

Definition at line 336 of file Teko_Utilities.hpp.

◆ rangeSpace()

VectorSpace Teko::rangeSpace ( const LinearOp &  lo)
inline

Replace nonzeros with a scalar value, used to zero out an operator.

Get the range space of a linear operator

Definition at line 345 of file Teko_Utilities.hpp.

◆ domainSpace()

VectorSpace Teko::domainSpace ( const LinearOp &  lo)
inline

Get the domain space of a linear operator.

Definition at line 349 of file Teko_Utilities.hpp.

◆ toBlockedLinearOp() [1/2]

BlockedLinearOp Teko::toBlockedLinearOp ( LinearOp &  clo)
inline

Converts a LinearOp to a BlockedLinearOp.

Definition at line 353 of file Teko_Utilities.hpp.

◆ toBlockedLinearOp() [2/2]

const BlockedLinearOp Teko::toBlockedLinearOp ( const LinearOp &  clo)
inline

Converts a LinearOp to a BlockedLinearOp.

Definition at line 360 of file Teko_Utilities.hpp.

◆ toLinearOp() [1/4]

LinearOp Teko::toLinearOp ( BlockedLinearOp &  blo)
inline

Convert to a LinearOp from a BlockedLinearOp.

Definition at line 367 of file Teko_Utilities.hpp.

◆ toLinearOp() [2/4]

const LinearOp Teko::toLinearOp ( const BlockedLinearOp &  blo)
inline

Convert to a LinearOp from a BlockedLinearOp.

Definition at line 370 of file Teko_Utilities.hpp.

◆ toLinearOp() [3/4]

LinearOp Teko::toLinearOp ( ModifiableLinearOp &  blo)
inline

Convert to a LinearOp from a BlockedLinearOp.

Definition at line 373 of file Teko_Utilities.hpp.

◆ toLinearOp() [4/4]

const LinearOp Teko::toLinearOp ( const ModifiableLinearOp &  blo)
inline

Convert to a LinearOp from a BlockedLinearOp.

Definition at line 376 of file Teko_Utilities.hpp.

◆ blockRowCount()

int Teko::blockRowCount ( const BlockedLinearOp &  blo)
inline

Get the row count in a block linear operator.

Definition at line 379 of file Teko_Utilities.hpp.

◆ blockColCount()

int Teko::blockColCount ( const BlockedLinearOp &  blo)
inline

Get the column count in a block linear operator.

Definition at line 383 of file Teko_Utilities.hpp.

◆ getBlock() [2/2]

LinearOp Teko::getBlock ( int  i,
int  j,
const BlockedLinearOp &  blo 
)
inline

Get the i,j block in a BlockedLinearOp object.

Definition at line 387 of file Teko_Utilities.hpp.

◆ setBlock()

void Teko::setBlock ( int  i,
int  j,
BlockedLinearOp &  blo,
const LinearOp &  lo 
)
inline

Set the i,j block in a BlockedLinearOp object.

Definition at line 391 of file Teko_Utilities.hpp.

◆ createBlockedOp()

BlockedLinearOp Teko::createBlockedOp ( )
inline

Build a new blocked linear operator.

Definition at line 395 of file Teko_Utilities.hpp.

◆ beginBlockFill() [1/2]

void Teko::beginBlockFill ( BlockedLinearOp &  blo,
int  rowCnt,
int  colCnt 
)
inline

Let the blocked operator know that you are going to set the sub blocks.

Let the blocked operator know that you are going to set the sub blocks. This is a simple wrapper around the member function of the same name in Thyra.

Parameters
[in,out]bloBlocked operator to have its fill stage activated
[in]rowCntNumber of block rows in this operator
[in]colCntNumber of block columns in this operator

Definition at line 409 of file Teko_Utilities.hpp.

◆ beginBlockFill() [2/2]

void Teko::beginBlockFill ( BlockedLinearOp &  blo)
inline

Let the blocked operator know that you are going to set the sub blocks.

Let the blocked operator know that you are going to set the sub blocks. This is a simple wrapper around the member function of the same name in Thyra.

Parameters
[in,out]bloBlocked operator to have its fill stage activated

Definition at line 421 of file Teko_Utilities.hpp.

◆ endBlockFill()

void Teko::endBlockFill ( BlockedLinearOp &  blo)
inline

Notify the blocked operator that the fill stage is completed.

Definition at line 425 of file Teko_Utilities.hpp.

◆ getUpperTriBlocks()

BlockedLinearOp Teko::getUpperTriBlocks ( const BlockedLinearOp &  blo,
bool  callEndBlockFill 
)

Get the strictly upper triangular portion of the matrix.

Definition at line 493 of file Teko_Utilities.cpp.

◆ getLowerTriBlocks()

BlockedLinearOp Teko::getLowerTriBlocks ( const BlockedLinearOp &  blo,
bool  callEndBlockFill 
)

Get the strictly lower triangular portion of the matrix.

Definition at line 532 of file Teko_Utilities.cpp.

◆ zeroBlockedOp()

BlockedLinearOp Teko::zeroBlockedOp ( const BlockedLinearOp &  blo)

Build a zero operator mimicing the block structure of the passed in matrix.

Build a zero operator mimicing the block structure of the passed in matrix. Currently this function assumes that the operator is "block" square. Also, this function calls beginBlockFill but does not call endBlockFill. This is so that the user can fill the matrix as they wish once created.

Parameters
[in]bloBlocked operator with desired structure.
Returns
A zero operator with the same block structure as the argument blo.

\notes The caller is responsible for calling endBlockFill on the returned blocked operator.

Build a zero operator mimicing the block structure of the passed in matrix. Currently this function assumes that the operator is "block" square. Also, this function calls beginBlockFill but does not call endBlockFill. This is so that the user can fill the matrix as they wish once created.

Parameters
[in]bloBlocked operator with desired structure.
Returns
A zero operator with the same block structure as the argument blo.
Note
The caller is responsible for calling endBlockFill on the returned blocked operator.

Definition at line 589 of file Teko_Utilities.cpp.

◆ isZeroOp()

bool Teko::isZeroOp ( const LinearOp  op)

Figure out if this operator is the zero operator (or null!)

Definition at line 617 of file Teko_Utilities.cpp.

◆ getAbsRowSumMatrix()

ModifiableLinearOp Teko::getAbsRowSumMatrix ( const LinearOp &  op)

Compute absolute row sum matrix.

Compute the absolute row sum matrix. That is a diagonal operator composed of the absolute value of the row sum.

Returns
A diagonal operator.

Compute the absolute row sum matrix. That is a diagonal operator composed of the absolute value of the row sum.

Returns
A diagonal operator.

Definition at line 719 of file Teko_Utilities.cpp.

◆ getAbsRowSumInvMatrix()

ModifiableLinearOp Teko::getAbsRowSumInvMatrix ( const LinearOp &  op)

Compute inverse of the absolute row sum matrix.

Compute the inverse of the absolute row sum matrix. That is a diagonal operator composed of the inverse of the absolute value of the row sum.

Returns
A diagonal operator.

Compute the inverse of the absolute row sum matrix. That is a diagonal operator composed of the inverse of the absolute value of the row sum.

Returns
A diagonal operator.

Definition at line 761 of file Teko_Utilities.cpp.

◆ getLumpedMatrix()

ModifiableLinearOp Teko::getLumpedMatrix ( const LinearOp &  op)

Compute the lumped version of this matrix.

Compute the lumped version of this matrix. That is a diagonal operator composed of the row sum.

Returns
A diagonal operator.

Compute the lumped version of this matrix. That is a diagonal operator composed of the row sum.

Returns
A diagonal operator.

Definition at line 850 of file Teko_Utilities.cpp.

◆ getInvLumpedMatrix()

ModifiableLinearOp Teko::getInvLumpedMatrix ( const LinearOp &  op)

Compute the inverse of the lumped version of this matrix.

Compute the inverse of the lumped version of this matrix. That is a diagonal operator composed of the row sum.

Returns
A diagonal operator.

Compute the inverse of the lumped version of this matrix. That is a diagonal operator composed of the row sum.

Returns
A diagonal operator.

Definition at line 873 of file Teko_Utilities.cpp.

◆ applyOp() [1/2]

void Teko::applyOp ( const LinearOp &  A,
const MultiVector &  x,
MultiVector &  y,
double  alpha,
double  beta 
)

Apply a linear operator to a multivector (think of this as a matrix vector multiply).

Apply a linear operator to a multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A x + \beta y $

Parameters
[in]A
[in]x
[in,out]y
[in]

alpha

Parameters
[in]

beta

Apply a linear operator to a multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A x + \beta y $

It is required that the range space of A is compatible with y and the domain space of A is compatible with x.

Parameters
[in]A
[in]x
[in,out]y
[in]alpha
[in]beta

Definition at line 452 of file Teko_Utilities.cpp.

◆ applyTransposeOp() [1/2]

void Teko::applyTransposeOp ( const LinearOp &  A,
const MultiVector &  x,
MultiVector &  y,
double  alpha,
double  beta 
)

Apply a transposed linear operator to a multivector (think of this as a matrix vector multiply).

Apply a transposed linear operator to a multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A^T x + \beta y $

Parameters
[in]A
[in]x
[in,out]y
[in]

alpha

Parameters
[in]

beta

Apply a transposed linear operator to a multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A^T x + \beta y $

It is required that the domain space of A is compatible with y and the range space of A is compatible with x.

Parameters
[in]A
[in]x
[in,out]y
[in]alpha
[in]beta

Definition at line 472 of file Teko_Utilities.cpp.

◆ applyOp() [2/2]

void Teko::applyOp ( const LinearOp &  A,
const BlockedMultiVector &  x,
BlockedMultiVector &  y,
double  alpha = 1.0,
double  beta = 0.0 
)
inline

Apply a linear operator to a blocked multivector (think of this as a matrix vector multiply).

Apply a linear operator to a blocked multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A x + \beta y $

It is required that the range space of A is compatible with y and the domain space of A is compatible with x.

Parameters
[in]A
[in]x
[in,out]y
[in]alpha
[in]beta

Definition at line 561 of file Teko_Utilities.hpp.

◆ applyTransposeOp() [2/2]

void Teko::applyTransposeOp ( const LinearOp &  A,
const BlockedMultiVector &  x,
BlockedMultiVector &  y,
double  alpha = 1.0,
double  beta = 0.0 
)
inline

Apply a transposed linear operator to a blocked multivector (think of this as a matrix vector multiply).

Apply a transposed linear operator to a blocked multivector. This also permits arbitrary scaling and addition of the result. This function gives

$ y = \alpha A^T x + \beta y $

It is required that the domain space of A is compatible with y and the range space of A is compatible with x.

Parameters
[in]A
[in]x
[in,out]y
[in]alpha
[in]beta

Definition at line 583 of file Teko_Utilities.hpp.

◆ update() [1/2]

void Teko::update ( double  alpha,
const MultiVector &  x,
double  beta,
MultiVector &  y 
)

Update the y vector so that $y = \alpha x+\beta y$.

Compute the linear combination $y=\alpha x + \beta y$.

Parameters
[in]alpha
[in]x
[in]beta
[in,out]y

Definition at line 479 of file Teko_Utilities.cpp.

◆ update() [2/2]

void Teko::update ( double  alpha,
const BlockedMultiVector &  x,
double  beta,
BlockedMultiVector &  y 
)
inline

Update for a BlockedMultiVector.

Definition at line 599 of file Teko_Utilities.hpp.

◆ scale() [1/3]

void Teko::scale ( const double  alpha,
MultiVector &  x 
)
inline

Scale a multivector by a constant.

Definition at line 604 of file Teko_Utilities.hpp.

◆ scale() [2/3]

void Teko::scale ( const double  alpha,
BlockedMultiVector &  x 
)
inline

Scale a multivector by a constant.

Definition at line 607 of file Teko_Utilities.hpp.

◆ scale() [3/3]

LinearOp Teko::scale ( const double  alpha,
ModifiableLinearOp &  a 
)
inline

Scale a modifiable linear op by a constant.

Definition at line 611 of file Teko_Utilities.hpp.

◆ adjoint()

LinearOp Teko::adjoint ( ModifiableLinearOp &  a)
inline

Construct an implicit adjoint of the linear operators.

Definition at line 615 of file Teko_Utilities.hpp.

◆ getDiagonalOp() [1/2]

const ModifiableLinearOp Teko::getDiagonalOp ( const LinearOp &  op)

Get the diaonal of a linear operator.

Get the diagonal of a linear operator. Currently it is assumed that the underlying operator is an Epetra_RowMatrix.

Parameters
[in]opThe operator whose diagonal is to be extracted.
Returns
An diagonal operator.

Get the diagonal of a linear operator. Currently it is assumed that the underlying operator is an Epetra_RowMatrix.

Parameters
[in]opThe operator whose diagonal is to be extracted.
Returns
An diagonal operator.

Definition at line 947 of file Teko_Utilities.cpp.

◆ getDiagonal() [1/2]

const MultiVector Teko::getDiagonal ( const LinearOp &  op)

Get the diagonal of a linear operator.

Get the diagonal of a linear operator, putting it in the first column of a multivector.

Definition at line 980 of file Teko_Utilities.cpp.

◆ getInvDiagonalOp() [1/2]

const ModifiableLinearOp Teko::getInvDiagonalOp ( const LinearOp &  op)

Get the diaonal of a linear operator.

Get the inverse of the diagonal of a linear operator. Currently it is assumed that the underlying operator is an Epetra_RowMatrix.

Parameters
[in]opThe operator whose diagonal is to be extracted and inverted
Returns
An diagonal operator.

Get the inverse of the diagonal of a linear operator. Currently it is assumed that the underlying operator is an Epetra_RowMatrix.

Parameters
[in]opThe operator whose diagonal is to be extracted and inverted
Returns
An diagonal operator.

Definition at line 1034 of file Teko_Utilities.cpp.

◆ explicitMultiply() [1/4]

const LinearOp Teko::explicitMultiply ( const LinearOp &  opl,
const LinearOp &  opm,
const LinearOp &  opr 
)

Multiply three linear operators.

Multiply three linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]opmMiddle operator (assumed to be a diagonal matrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix product with a Epetra_CrsMatrix implementation

Multiply three linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]opmMiddle operator (assumed to be a Epetra_CrsMatrix or a diagonal matrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix product with a Epetra_CrsMatrix implementation

Definition at line 1110 of file Teko_Utilities.cpp.

◆ explicitMultiply() [2/4]

const ModifiableLinearOp Teko::explicitMultiply ( const LinearOp &  opl,
const LinearOp &  opm,
const LinearOp &  opr,
const ModifiableLinearOp &  destOp 
)

Multiply three linear operators.

Multiply three linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]opmMiddle operator (assumed to be a Epetra_CrsMatrix or a diagonal matrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix product with a Epetra_CrsMatrix implementation

Multiply three linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]opmMiddle operator (assumed to be a Epetra_CrsMatrix or a diagonal matrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix product with a Epetra_CrsMatrix implementation

Definition at line 1327 of file Teko_Utilities.cpp.

◆ explicitMultiply() [3/4]

const LinearOp Teko::explicitMultiply ( const LinearOp &  opl,
const LinearOp &  opr 
)

Multiply two linear operators.

Multiply two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix product with a Epetra_CrsMatrix implementation

Multiply two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix product with a Epetra_CrsMatrix implementation

Definition at line 1439 of file Teko_Utilities.cpp.

◆ explicitMultiply() [4/4]

const ModifiableLinearOp Teko::explicitMultiply ( const LinearOp &  opl,
const LinearOp &  opr,
const ModifiableLinearOp &  destOp 
)

Multiply two linear operators.

Multiply two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix product with a Epetra_CrsMatrix implementation

Multiply two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix. The exception is that opm is allowed to be an diagonal matrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix product with a Epetra_CrsMatrix implementation

Definition at line 1642 of file Teko_Utilities.cpp.

◆ explicitAdd() [1/2]

const LinearOp Teko::explicitAdd ( const LinearOp &  opl_in,
const LinearOp &  opr_in 
)

Add two linear operators.

Add two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix sum with a Epetra_CrsMatrix implementation

Add two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
Returns
Matrix sum with a Epetra_CrsMatrix implementation

Definition at line 1849 of file Teko_Utilities.cpp.

◆ explicitAdd() [2/2]

const ModifiableLinearOp Teko::explicitAdd ( const LinearOp &  opl,
const LinearOp &  opr,
const ModifiableLinearOp &  destOp 
)

Add two linear operators.

Add two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix sum with a Epetra_CrsMatrix implementation

Add two linear operators. This currently assumes that the underlying implementation uses Epetra_CrsMatrix.

Parameters
[in]oplLeft operator (assumed to be a Epetra_CrsMatrix)
[in]oprRight operator (assumed to be a Epetra_CrsMatrix)
[in,out]destOpThe operator to be used as the destination operator, if this is null this function creates a new operator
Returns
Matrix sum with a Epetra_CrsMatrix implementation

Definition at line 1980 of file Teko_Utilities.cpp.

◆ explicitSum()

const ModifiableLinearOp Teko::explicitSum ( const LinearOp &  op,
const ModifiableLinearOp &  destOp 
)

Sum an operator.

Returns
Matrix sum with a Epetra_CrsMatrix implementation

Sum into the modifiable linear op.

Definition at line 2084 of file Teko_Utilities.cpp.

◆ explicitTranspose()

const LinearOp Teko::explicitTranspose ( const LinearOp &  op)

Build an explicit transpose of a linear operator. (Concrete data underneath.

Definition at line 2110 of file Teko_Utilities.cpp.

◆ frobeniusNorm()

double Teko::frobeniusNorm ( const LinearOp &  op)

Rturn the frobenius norm of a linear operator

Definition at line 2151 of file Teko_Utilities.cpp.

◆ buildDiagonal()

const LinearOp Teko::buildDiagonal ( const MultiVector &  src,
const std::string &  lbl 
)

Take the first column of a multivector and build a diagonal linear operator.

Definition at line 2236 of file Teko_Utilities.cpp.

◆ buildInvDiagonal()

const LinearOp Teko::buildInvDiagonal ( const MultiVector &  src,
const std::string &  lbl 
)

Using the first column of a multivector, take the elementwise build a inverse and build the inverse diagonal operator.

Definition at line 2244 of file Teko_Utilities.cpp.

◆ computeSpectralRad()

double Teko::computeSpectralRad ( const Teuchos::RCP< const Thyra::LinearOpBase< double > > &  A,
double  tol,
bool  isHermitian = false,
int  numBlocks = 5,
int  restart = 0,
int  verbosity = 0 
)

Compute the spectral radius of a matrix.

Compute the spectral radius of matrix A. This utilizes the Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. It attempts to compute the largest (in magnitude) eigenvalue to a given level of tolerance.

Parameters
[in]Amatrix whose spectral radius is needed
[in]tolThe most accuracy needed (the algorithm will run until it reaches this level of accuracy and then it will quit). If this level is not reached it will return something to indicate it has not converged.
[in]isHermitianIs the matrix Hermitian
[in]numBlocksThe size of the orthogonal basis built (like in GMRES) before restarting. Increase the memory usage by O(restart*n). At least restart=3 is required.
[in]restartHow many restarts are permitted
[in]verbositySee the Anasazi documentation
Returns
The spectral radius of the matrix. If the algorithm didn't converge the number is the negative of the ritz-values. If a NaN is returned there was a problem constructing the Anasazi problem

◆ computeSmallestMagEig()

double Teko::computeSmallestMagEig ( const Teuchos::RCP< const Thyra::LinearOpBase< double > > &  A,
double  tol,
bool  isHermitian = false,
int  numBlocks = 5,
int  restart = 0,
int  verbosity = 0 
)

Compute the smallest eigenvalue of an operator.

Compute the smallest eigenvalue of matrix A. This utilizes the Trilinos-Anasazi BlockKrylovShcur method for computing eigenvalues. It attempts to compute the smallest (in magnitude) eigenvalue to a given level of tolerance.

Parameters
[in]Amatrix whose spectral radius is needed
[in]tolThe most accuracy needed (the algorithm will run until it reaches this level of accuracy and then it will quit). If this level is not reached it will return something to indicate it has not converged.
[in]isHermitianIs the matrix Hermitian
[in]numBlocksThe size of the orthogonal basis built (like in GMRES) before restarting. Increase the memory usage by O(restart*n). At least restart=3 is required.
[in]restartHow many restarts are permitted
[in]verbositySee the Anasazi documentation
Returns
The smallest magnitude eigenvalue of the matrix. If the algorithm didn't converge the number is the negative of the ritz-values. If a NaN is returned there was a problem constructing the Anasazi problem

◆ getDiagonalOp() [2/2]

ModifiableLinearOp Teko::getDiagonalOp ( const Teko::LinearOp &  A,
const DiagonalType dt 
)

Get a diagonal operator from a matrix. The mechanism for computing the diagonal is specified by a DiagonalType arugment.

Parameters
[in]AEpetra_CrsMatrix to extract the diagonal from.
[in]dtSpecifies the type of diagonal that is desired.
Returns
A diagonal operator.

Definition at line 2480 of file Teko_Utilities.cpp.

◆ getInvDiagonalOp() [2/2]

ModifiableLinearOp Teko::getInvDiagonalOp ( const Teko::LinearOp &  A,
const Teko::DiagonalType dt 
)

Get the inverse of a diagonal operator from a matrix. The mechanism for computing the diagonal is specified by a DiagonalType arugment.

Parameters
[in]AEpetra_CrsMatrix to extract the diagonal from.
[in]dtSpecifies the type of diagonal that is desired.
Returns
A inverse of a diagonal operator.

Definition at line 2505 of file Teko_Utilities.cpp.

◆ getDiagonal() [2/2]

const MultiVector Teko::getDiagonal ( const LinearOp &  op,
const DiagonalType dt 
)

Get the diagonal of a sparse linear operator.

Parameters
[in]OpSparse linear operator to get diagonal of
[in]dtType of diagonal operator required.

Definition at line 1014 of file Teko_Utilities.cpp.

◆ getDiagonalName()

std::string Teko::getDiagonalName ( const DiagonalType dt)

Get a string corresponding to the type of diagonal specified.

Parameters
[in]dtThe type of diagonal.
Returns
A string name representing this diagonal type.

Get a string corresponding to the type of digaonal specified.

Parameters
[in]dtThe type of diagonal.
Returns
A string name representing this diagonal type.

Definition at line 2528 of file Teko_Utilities.cpp.

◆ getDiagonalType()

DiagonalType Teko::getDiagonalType ( std::string  name)

Get a type corresponding to the name of a diagonal specified.

Parameters
[in]nameString representing the diagonal type
Returns
The type representation of the string, if the string is not recognized this function returns a NotDiag

Definition at line 2554 of file Teko_Utilities.cpp.

◆ norm_1()

double Teko::norm_1 ( const MultiVector &  v,
std::size_t  col 
)

Get the one norm of the vector

Definition at line 2585 of file Teko_Utilities.cpp.

◆ norm_2()

double Teko::norm_2 ( const MultiVector &  v,
std::size_t  col 
)

Get the two norm of the vector

Definition at line 2593 of file Teko_Utilities.cpp.