escript
Revision_Unversioneddirectory
|
Contains maths operations performed on data vectors. More...
Functions | |
void | matMult (const DataTypes::ValueType &left, const DataTypes::ShapeType &leftShape, DataTypes::ValueType::size_type leftOffset, const DataTypes::ValueType &right, const DataTypes::ShapeType &rightShape, DataTypes::ValueType::size_type rightOffset, DataTypes::ValueType &result, const DataTypes::ShapeType &resultShape) |
Perform a matrix multiply of the given views. More... | |
DataTypes::ShapeType | determineResultShape (const DataTypes::ShapeType &left, const DataTypes::ShapeType &right) |
Determine the shape of the result array for a matrix multiplication of the given views. More... | |
void | matrixInverseError (int err) |
throws an appropriate exception based on failure of matrix_inverse. More... | |
int | matrix_inverse (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &out, const DataTypes::ShapeType &outShape, DataTypes::ValueType::size_type outOffset, int count, LapackInverseHelper &helper) |
computes the inverses of square (up to 3x3) matricies More... | |
template<class UnaryFunction > | |
void | unaryOp (DataTypes::ValueType &data, const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type offset, UnaryFunction operation) |
Perform the unary operation on the data point specified by the given offset. Applies the specified operation to each value in the data point. Operation must be a pointer to a function. More... | |
template<class BinaryFunction > | |
void | binaryOp (DataTypes::ValueType &left, const DataTypes::ShapeType &leftShape, DataTypes::ValueType::size_type leftOffset, const DataTypes::ValueType &right, const DataTypes::ShapeType &rightShape, DataTypes::ValueType::size_type rightOffset, BinaryFunction operation) |
Perform the binary operation on the data points specified by the given offsets in the "left" and "right" vectors. Applies the specified operation to corresponding values in both data points. Operation must be a pointer to a function. More... | |
template<class BinaryFunction > | |
void | binaryOp (DataTypes::ValueType &left, const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type offset, double right, BinaryFunction operation) |
Perform the binary operation on the data point specified by the given offset in the vector using the scalar value "right". Applies the specified operation to values in the data point. Operation must be a pointer to a function. More... | |
template<class BinaryFunction > | |
double | reductionOp (const DataTypes::ValueType &left, const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type offset, BinaryFunction operation, double initial_value) |
Perform the given data point reduction operation on the data point specified by the given offset into the view. Reduces all elements of the data point using the given operation, returning the result as a scalar. Operation must be a pointer to a function. More... | |
void | symmetric (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset) |
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2 More... | |
void | nonsymmetric (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset) |
computes a nonsymmetric matrix from your square matrix A: (A - transpose(A)) / 2 More... | |
void | trace (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset, int axis_offset) |
computes the trace of a matrix More... | |
void | transpose (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset, int axis_offset) |
Transpose each data point of this Data object around the given axis. More... | |
void | swapaxes (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset, int axis0, int axis1) |
swaps the components axis0 and axis1. More... | |
void | eigenvalues (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset) |
solves a local eigenvalue problem More... | |
void | eigenvalues_and_eigenvectors (const DataTypes::ValueType &in, const DataTypes::ShapeType &inShape, DataTypes::ValueType::size_type inOffset, DataTypes::ValueType &ev, const DataTypes::ShapeType &evShape, DataTypes::ValueType::size_type evOffset, DataTypes::ValueType &V, const DataTypes::ShapeType &VShape, DataTypes::ValueType::size_type VOffset, const double tol=1.e-13) |
solves a local eigenvalue problem More... | |
bool | checkOffset (const DataTypes::ValueType &data, const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type offset) |
bool | vectorHasNaN (const DataTypes::ValueType &in, DataTypes::ValueType::size_type inOffset, size_t count) |
returns true if the vector contains NaN More... | |
Contains maths operations performed on data vectors.
In order to properly identify the datapoints, in most cases, the vector, shape and offset of the point must all be supplied. Note that vector in this context refers to a data vector storing datapoints not a mathematical vector. (However, datapoints within the data vector could represent scalars, vectors, matricies, ...).
|
inline |
Perform the binary operation on the data points specified by the given offsets in the "left" and "right" vectors. Applies the specified operation to corresponding values in both data points. Operation must be a pointer to a function.
Called by escript::binaryOp.
left,right | - vectors containing the datapoints |
leftShape,rightShape | - shapes of datapoints in the vectors |
leftOffset,rightOffset | - beginnings of datapoints in the vectors |
operation | - Input - Operation to apply. Must be a pointer to a function. |
References checkOffset(), EsysAssert, escript::DataTypes::noValues(), and escript::DataVector::size().
Referenced by escript::binaryOp().
|
inline |
Perform the binary operation on the data point specified by the given offset in the vector using the scalar value "right". Applies the specified operation to values in the data point. Operation must be a pointer to a function.
Called by escript::binaryOp.
left | - vector containing the datapoints |
shape | - shape of datapoint in the vector |
offset | - beginning of datapoint in the vector |
right | - scalar value for the right hand side of the operation |
operation | - Input - Operation to apply. Must be a pointer to a function. |
References checkOffset(), EsysAssert, escript::DataTypes::noValues(), and escript::DataVector::size().
|
inline |
Inline function definitions.
References escript::DataTypes::noValues(), and escript::DataVector::size().
Referenced by binaryOp(), reductionOp(), and unaryOp().
DataTypes::ShapeType escript::DataMaths::determineResultShape | ( | const DataTypes::ShapeType & | left, |
const DataTypes::ShapeType & | right | ||
) |
Determine the shape of the result array for a matrix multiplication of the given views.
left,right | - shapes of the left and right matricies |
References escript::DataTypes::getRank().
|
inline |
solves a local eigenvalue problem
in | - vector containing the input matrix |
inShape | - shape of the input matrix |
inOffset | - the beginning of the input matrix within the vector "in" |
ev | - vector to store the eigenvalues |
evShape | - expected shape of the eigenvalues |
evOffset | - starting location for storing the eigenvalues in vector ev |
References escript::eigenvalues1(), escript::eigenvalues2(), escript::eigenvalues3(), ESCRIPT_DLL_API, and escript::DataTypes::getRelIndex().
Referenced by escript::DataConstant::eigenvalues(), escript::DataExpanded::eigenvalues(), escript::DataTagged::eigenvalues(), and escript::DataTagged::isTagged().
|
inline |
solves a local eigenvalue problem
in | - vector containing the input matrix |
inShape | - shape of the input matrix |
inOffset | - the beginning of the input matrix within the vector "in" |
ev | - vector to store the eigenvalues |
evShape | - expected shape of the eigenvalues |
evOffset | - starting location for storing the eigenvalues in ev |
V | - vector to store the eigenvectors |
VShape | - expected shape of the eigenvectors |
VOffset | - starting location for storing the eigenvectors in V |
tol | - Input - eigenvalues with relative difference tol are treated as equal |
References escript::eigenvalues_and_eigenvectors1(), escript::eigenvalues_and_eigenvectors2(), escript::eigenvalues_and_eigenvectors3(), and escript::DataTypes::getRelIndex().
Referenced by escript::DataConstant::eigenvalues_and_eigenvectors(), escript::DataExpanded::eigenvalues_and_eigenvectors(), escript::DataTagged::eigenvalues_and_eigenvectors(), and escript::DataTagged::isTagged().
void escript::DataMaths::matMult | ( | const DataTypes::ValueType & | left, |
const DataTypes::ShapeType & | leftShape, | ||
DataTypes::ValueType::size_type | leftOffset, | ||
const DataTypes::ValueType & | right, | ||
const DataTypes::ShapeType & | rightShape, | ||
DataTypes::ValueType::size_type | rightOffset, | ||
DataTypes::ValueType & | result, | ||
const DataTypes::ShapeType & | resultShape | ||
) |
Perform a matrix multiply of the given views.
NB: Only multiplies together the two given datapoints, would need to call this over all data-points to multiply the entire Data objects involved.
left,right | - vectors containing the datapoints |
leftShape,rightShape | - shapes of datapoints in the vectors |
leftOffset,rightOffset | - beginnings of datapoints in the vectors |
result | - Vector to store the resulting datapoint in |
resultShape | - expected shape of the resulting datapoint |
References escript::DataTypes::getRank(), and escript::DataTypes::getRelIndex().
int escript::DataMaths::matrix_inverse | ( | const DataTypes::ValueType & | in, |
const DataTypes::ShapeType & | inShape, | ||
DataTypes::ValueType::size_type | inOffset, | ||
DataTypes::ValueType & | out, | ||
const DataTypes::ShapeType & | outShape, | ||
DataTypes::ValueType::size_type | outOffset, | ||
int | count, | ||
LapackInverseHelper & | helper | ||
) |
computes the inverses of square (up to 3x3) matricies
in | - vector containing the input matricies |
inShape | - shape of the input matricies |
inOffset | - the beginning of the input matricies within the vector "in" |
out | - vector to store the inverses |
outShape | - expected shape of the inverses |
outOffset | - starting location for storing the inverses in out |
count | - number of matricies to invert |
helper | - associated working storage |
DataException | if input and output are not the correct shape or if any of the matricies are not invertible. |
References escript::DataTypes::getRank(), escript::DataTypes::getRelIndex(), escript::LapackInverseHelper::invert(), NEEDLAPACK, escript::DataTypes::noValues(), and SUCCESS.
Referenced by escript::DataExpanded::matrixInverse(), escript::DataTagged::matrixInverse(), escript::DataConstant::matrixInverse(), and reductionOp().
void escript::DataMaths::matrixInverseError | ( | int | err | ) |
throws an appropriate exception based on failure of matrix_inverse.
err | - error code returned from matrix_inverse |
References ERRFACTORISE, ERRINVERT, and NEEDLAPACK.
Referenced by escript::Data::matrixInverse(), and reductionOp().
|
inline |
computes a nonsymmetric matrix from your square matrix A: (A - transpose(A)) / 2
in | - vector containing the matrix A |
inShape | - shape of the matrix A |
inOffset | - the beginning of A within the vector in |
ev | - vector to store the output matrix |
evShape | - expected shape of the output matrix |
evOffset | - starting location for storing ev in vector ev |
References escript::DataTypes::getRank(), and escript::DataTypes::getRelIndex().
Referenced by escript::DataTagged::isTagged(), escript::DataConstant::nonsymmetric(), escript::DataExpanded::nonsymmetric(), escript::DataTagged::nonsymmetric(), and escript::DataLazy::resolveNodeNP1OUT().
|
inline |
Perform the given data point reduction operation on the data point specified by the given offset into the view. Reduces all elements of the data point using the given operation, returning the result as a scalar. Operation must be a pointer to a function.
Called by escript::algorithm.
left | - vector containing the datapoint |
shape | - shape of datapoints in the vector |
offset | - beginning of datapoint in the vector |
operation | - Input - Operation to apply. Must be a pointer to a function. |
initial_value |
References checkOffset(), EsysAssert, matrix_inverse(), matrixInverseError(), escript::DataTypes::noValues(), and escript::DataVector::size().
Referenced by escript::algorithm(), escript::dp_algorithm(), and escript::DataLazy::resolveNodeReduction().
|
inline |
swaps the components axis0 and axis1.
in | - vector containing the input matrix |
inShape | - shape of the input matrix |
inOffset | - the beginning of the input matrix within the vector "in" |
ev | - vector to store the output matrix |
evShape | - expected shape of the output matrix |
evOffset | - starting location for storing the output matrix in vector ev |
axis0 | - axis index |
axis1 | - axis index |
References ESCRIPT_DLL_API, escript::DataTypes::getRank(), and escript::DataTypes::getRelIndex().
Referenced by escript::DataTagged::isTagged(), escript::DataLazy::resolveNodeNP1OUT_2P(), escript::DataConstant::swapaxes(), escript::DataExpanded::swapaxes(), and escript::DataTagged::swapaxes().
|
inline |
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
in | - vector containing the matrix A |
inShape | - shape of the matrix A |
inOffset | - the beginning of A within the vector in |
ev | - vector to store the output matrix |
evShape | - expected shape of the output matrix |
evOffset | - starting location for storing ev in vector ev |
References ESCRIPT_DLL_API, escript::DataTypes::getRank(), and escript::DataTypes::getRelIndex().
Referenced by escript::DataTagged::isTagged(), ripley::RipleyDomain::newSystemMatrix(), escript::DataLazy::resolveNodeNP1OUT(), escript::DataConstant::symmetric(), escript::DataExpanded::symmetric(), and escript::DataTagged::symmetric().
|
inline |
computes the trace of a matrix
in | - vector containing the input matrix |
inShape | - shape of the input matrix |
inOffset | - the beginning of the input matrix within the vector "in" |
ev | - vector to store the output matrix |
evShape | - expected shape of the output matrix |
evOffset | - starting location for storing the output matrix in vector ev |
axis_offset |
References ESCRIPT_DLL_API, escript::DataTypes::getRank(), escript::DataTypes::getRelIndex(), and escript::DataTypes::noValues().
Referenced by getStringFromPyException(), escript::DataTagged::isTagged(), escript::DataLazy::resolveNodeNP1OUT_P(), escript::DataConstant::trace(), escript::DataExpanded::trace(), and escript::DataTagged::trace().
|
inline |
Transpose each data point of this Data object around the given axis.
in | - vector containing the input matrix |
inShape | - shape of the input matrix |
inOffset | - the beginning of the input matrix within the vector "in" |
ev | - vector to store the output matrix |
evShape | - expected shape of the output matrix |
evOffset | - starting location for storing the output matrix in vector ev |
axis_offset |
References ESCRIPT_DLL_API, escript::DataTypes::getRank(), and escript::DataTypes::getRelIndex().
Referenced by escript::DataTagged::isTagged(), escript::DataLazy::resolveNodeNP1OUT_P(), escript::DataConstant::transpose(), escript::DataExpanded::transpose(), and escript::DataTagged::transpose().
|
inline |
Perform the unary operation on the data point specified by the given offset. Applies the specified operation to each value in the data point. Operation must be a pointer to a function.
Called by escript::unaryOp.
data | - vector containing the datapoint |
shape | - shape of the point |
offset | - offset of the point within data |
operation | - Input - Operation to apply. Must be a pointer to a function. |
References checkOffset(), EsysAssert, escript::DataTypes::noValues(), and escript::DataVector::size().
Referenced by escript::unaryOp().
|
inline |
returns true if the vector contains NaN
References escript::nancheck().
Referenced by escript::Data::lazyAlgWorker().