escript
Revision_
|
Contains the types to represent Shapes, Regions, RegionLoop ranges and vectors of data as well as the functions to manipulate them. More...
Classes | |
class | DataVectorAlt |
class | DataVectorTaipan |
DataVectorTaipan implements an arbitrarily long vector of data values. DataVectorTaipan is the underlying data container for Data objects. More... | |
Typedefs | |
typedef std::vector< int > | ShapeType |
The shape of a single datapoint. More... | |
typedef std::vector< std::pair< int, int > > | RegionType |
typedef std::vector< std::pair< int, int > > | RegionLoopRangeType |
typedef long | vec_size_type |
typedef double | real_t |
type of all real-valued scalars in escript More... | |
typedef std::complex< real_t > | cplx_t |
complex data type More... | |
typedef int | index_t |
type for array/matrix indices used both globally and on each rank More... | |
typedef std::vector< index_t > | IndexVector |
typedef index_t | dim_t |
typedef escript::DataTypes::DataVectorAlt< real_t > | RealVectorType |
Vector to store underlying data. More... | |
typedef escript::DataTypes::DataVectorAlt< cplx_t > | CplxVectorType |
Functions | |
int | noValues (const DataTypes::ShapeType &shape) |
Calculate the number of values in a datapoint with the given shape. More... | |
int | noValues (const DataTypes::RegionLoopRangeType ®ion) |
Calculate the number of values for the given region. More... | |
std::string | shapeToString (const DataTypes::ShapeType &shape) |
Return the given shape as a string. More... | |
DataTypes::RegionType | getSliceRegion (const DataTypes::ShapeType &shape, const bp::object &key) |
DataTypes::ShapeType | getResultSliceShape (const DataTypes::RegionType ®ion) |
Determine the shape of the specified slice region. More... | |
DataTypes::RegionLoopRangeType | getSliceRegionLoopRange (const DataTypes::RegionType ®ion) |
Modify region to copy from in order to deal with the case where one range in the region contains identical indexes, eg: <<1,1><0,3><0,3>> This situation implies we want to copy from an object with rank greater than that of this object. eg: we want to copy the values from a two dimensional slice out of a three dimensional object into a two dimensional object. We do this by taking a slice from the other object where one dimension of the slice region is of size 1. So in the above example, we modify the above region like so: <<1,2><0,3><0,3>> and take this slice. More... | |
std::string | createShapeErrorMessage (const std::string &messagePrefix, const DataTypes::ShapeType &other, const DataTypes::ShapeType &thisShape) |
Produce a string containing two shapes. More... | |
index_t | index_t_min () |
Returns the minimum finite value for the index_t type. More... | |
index_t | index_t_max () |
Returns the maximum finite value for the index_t type. More... | |
real_t | real_t_max () |
Returns the maximum finite value for the real_t type. More... | |
real_t | real_t_eps () |
Returns the machine epsilon for the real_t type. More... | |
DataTypes::RegionType | getSliceRegion (const DataTypes::ShapeType &shape, const boost::python::object &key) |
Determine the region specified by the given python slice object. More... | |
int | getRank (const DataTypes::ShapeType &shape) |
Return the rank (number of dimensions) of the given shape. More... | |
vec_size_type | getRelIndex (const DataTypes::ShapeType &shape, vec_size_type i) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
vec_size_type | getRelIndex (const DataTypes::ShapeType &shape, vec_size_type i, vec_size_type j) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
vec_size_type | getRelIndex (const DataTypes::ShapeType &shape, vec_size_type i, vec_size_type j, vec_size_type k) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
vec_size_type | getRelIndex (const DataTypes::ShapeType &shape, vec_size_type i, vec_size_type j, vec_size_type k, vec_size_type m) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
bool | checkShape (const ShapeType &s1, const ShapeType &s2) |
Test if two shapes are equal. More... | |
bool | checkOffset (vec_size_type offset, int size, int noval) |
void | pointToStream (std::ostream &os, const RealVectorType::ElementType *data, const ShapeType &shape, int offset, bool needsep=true, const std::string &sep=",") |
Display a single value (with the specified shape) from the data. More... | |
std::string | pointToString (const RealVectorType &data, const ShapeType &shape, int offset, const std::string &prefix) |
Display a single value (with the specified shape) from the data. More... | |
void | copyPoint (RealVectorType &dest, vec_size_type doffset, vec_size_type nvals, const RealVectorType &src, vec_size_type soffset) |
Copy a point from one vector to another. Note: This version does not check to see if shapes are the same. More... | |
void | fillComplexFromReal (const RealVectorType &r, CplxVectorType &c) |
copy data from a real vector to a complex vector The complex vector will be resized as needed and any previous values will be replaced. More... | |
template<class VEC > | |
void | copySlice (VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType ®ion) |
Copy a data slice specified by the given region and offset from the "other" vector into the "left" vector at the given offset. More... | |
template<typename VEC > | |
void | copySliceFrom (VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType ®ion) |
Copy data into a slice specified by the given region and offset in the left vector from the other vector at the given offset. More... | |
void | releaseUnusedMemory () |
releases unused memory in the memory manager. More... | |
Variables | |
static const int | maxRank =4 |
The maximum number of dimensions a datapoint can have. More... | |
static const ShapeType | scalarShape |
Use this instead of creating empty shape objects for scalars. More... | |
Taipan | arrayManager |
Contains the types to represent Shapes, Regions, RegionLoop ranges and vectors of data as well as the functions to manipulate them.
typedef std::complex<real_t> escript::DataTypes::cplx_t |
complex data type
typedef index_t escript::DataTypes::dim_t |
typedef int escript::DataTypes::index_t |
type for array/matrix indices used both globally and on each rank
typedef std::vector<index_t> escript::DataTypes::IndexVector |
typedef double escript::DataTypes::real_t |
type of all real-valued scalars in escript
Vector to store underlying data.
typedef std::vector<std::pair<int, int> > escript::DataTypes::RegionLoopRangeType |
typedef std::vector<std::pair<int, int> > escript::DataTypes::RegionType |
typedef std::vector<int> escript::DataTypes::ShapeType |
The shape of a single datapoint.
typedef long escript::DataTypes::vec_size_type |
|
inline |
Referenced by copySlice(), and copySliceFrom().
Test if two shapes are equal.
References createShapeErrorMessage().
Referenced by escript::DataTagged::addTaggedValue(), escript::DataExpanded::copy(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), escript::DataTagged::setSlice(), and escript::DataTagged::setTaggedValue().
void escript::DataTypes::copyPoint | ( | RealVectorType & | dest, |
vec_size_type | doffset, | ||
vec_size_type | nvals, | ||
const RealVectorType & | src, | ||
vec_size_type | soffset | ||
) |
Copy a point from one vector to another. Note: This version does not check to see if shapes are the same.
dest | - vector to copy to |
doffset | - beginning of the target datapoint in dest |
nvals | - the number of values comprising the datapoint |
src | - vector to copy from |
soffset | - beginning of the datapoint in src |
Referenced by escript::DataExpanded::copy(), and escript::DataExpanded::DataExpanded().
void escript::DataTypes::copySlice | ( | VEC & | left, |
const ShapeType & | leftShape, | ||
typename VEC::size_type | leftOffset, | ||
const VEC & | other, | ||
const ShapeType & | otherShape, | ||
typename VEC::size_type | otherOffset, | ||
const RegionLoopRangeType & | region | ||
) |
Copy a data slice specified by the given region and offset from the "other" vector into the "left" vector at the given offset.
left | - vector to copy into |
leftShape | - shape of datapoints for the left vector |
leftOffset | - location within left to start copying to |
other | - vector to copy from |
otherShape | - shape of datapoints for the other vector |
otherOffset | - location within other vector to start copying from |
region | - Input - Region in other vector to copy data from. |
References checkOffset(), ESCRIPT_DLL_API, ESYS_ASSERT, getRank(), getRelIndex(), getResultSliceShape(), and noValues().
Referenced by escript::DataConstant::DataConstant(), escript::DataExpanded::DataExpanded(), and escript::DataTagged::DataTagged().
void escript::DataTypes::copySliceFrom | ( | VEC & | left, |
const ShapeType & | leftShape, | ||
typename VEC::size_type | leftOffset, | ||
const VEC & | other, | ||
const ShapeType & | otherShape, | ||
typename VEC::size_type | otherOffset, | ||
const RegionLoopRangeType & | region | ||
) |
Copy data into a slice specified by the given region and offset in the left vector from the other vector at the given offset.
left | - vector to copy into |
leftShape | - shape of datapoints for the left vector |
leftOffset | - location within left to start copying to |
other | - vector to copy from |
otherShape | - shape of datapoints for the other vector |
otherOffset | - location within other vector to start copying from |
region | - Input - Region in the left vector to copy data to. |
References checkOffset(), ESYS_ASSERT, getRank(), getRelIndex(), getResultSliceShape(), and noValues().
Referenced by escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), and escript::DataTagged::setSlice().
std::string escript::DataTypes::createShapeErrorMessage | ( | const std::string & | messagePrefix, |
const DataTypes::ShapeType & | other, | ||
const DataTypes::ShapeType & | thisShape | ||
) |
Produce a string containing two shapes.
messagePrefix | - Beginning of the message. |
other | - displayed in the message as "Other shape" |
thisShape | - displayed in the message as "This shape" |
References shapeToString().
Referenced by escript::DataTagged::addTaggedValue(), checkShape(), escript::DataExpanded::copy(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), escript::DataTagged::setSlice(), and escript::DataTagged::setTaggedValue().
void escript::DataTypes::fillComplexFromReal | ( | const RealVectorType & | r, |
CplxVectorType & | c | ||
) |
copy data from a real vector to a complex vector The complex vector will be resized as needed and any previous values will be replaced.
Referenced by escript::DataConstant::complicate(), escript::DataExpanded::complicate(), escript::DataTagged::complicate(), escript::DataExpanded::setTaggedValue(), and escript::Data::setTaggedValue().
|
inline |
Return the rank (number of dimensions) of the given shape.
shape |
Referenced by escript::antihermitian(), escript::antisymmetric(), copySlice(), copySliceFrom(), escript::determineResultShape(), getRelIndex(), escript::DataAbstract::hasNoSamples(), escript::hermitian(), escript::matMult(), escript::matrix_inverse(), escript::swapaxes(), escript::symmetric(), escript::trace(), and escript::transpose().
|
inline |
Compute the offset (in 1D vector) of a given subscript with a shape.
shape | - Input - Shape of the datapoint. |
i | - Input - subscript to locate. |
References ESYS_ASSERT, getRank(), and noValues().
Referenced by escript::antihermitian(), escript::antisymmetric(), escript::WrappedArray::convertArrayC(), escript::WrappedArray::convertArrayR(), escript::WrappedArray::convertNumpyArray(), escript::WrappedArray::convertNumpyArrayC(), escript::DataTypes::DataVectorAlt< cplx_t >::copyFromArrayToOffset(), escript::DataTypes::DataVectorTaipan::copyFromArrayToOffset(), copySlice(), copySliceFrom(), escript::DataExpanded::copyToDataPoint(), escript::eigenvalues(), escript::eigenvalues_and_eigenvectors(), escript::WrappedArray::getElt(), escript::WrappedArray::getEltC(), escript::hermitian(), escript::matMult(), escript::matrix_inverse(), escript::swapaxes(), escript::symmetric(), escript::trace(), and escript::transpose().
|
inline |
Compute the offset (in 1D vector) of a given subscript with a shape.
shape | - Input - Shape of the datapoint. |
i | - Input - row |
j | - Input - column |
References ESYS_ASSERT, getRank(), and noValues().
|
inline |
Compute the offset (in 1D vector) of a given subscript with a shape.
shape | - Input - Shape of the datapoint. |
i,j,k | - Input - subscripts to locate. |
References ESYS_ASSERT, getRank(), and noValues().
|
inline |
Compute the offset (in 1D vector) of a given subscript with a shape.
shape | - Input - Shape of the datapoint. |
i,j,k,m | - Input - subscripts to locate. |
References ESYS_ASSERT, getRank(), and noValues().
DataTypes::ShapeType escript::DataTypes::getResultSliceShape | ( | const DataTypes::RegionType & | region | ) |
Determine the shape of the specified slice region.
region | - Input - Slice region |
Referenced by copySlice(), copySliceFrom(), escript::DataTagged::DataTagged(), real_t_eps(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), and escript::DataTagged::setSlice().
DataTypes::RegionType escript::DataTypes::getSliceRegion | ( | const DataTypes::ShapeType & | shape, |
const bp::object & | key | ||
) |
Referenced by escript::Data::getItem(), real_t_eps(), and escript::Data::setItemD().
DataTypes::RegionType escript::DataTypes::getSliceRegion | ( | const DataTypes::ShapeType & | shape, |
const boost::python::object & | key | ||
) |
Determine the region specified by the given python slice object.
shape | - Input - Shape of the object being sliced. |
key | - Input - python slice object specifying region to be returned. |
The slice object is a tuple of n python slice specifiers, where n <= the rank of this Data object. Each slice specifier specifies the range of indexes to be sliced from the corresponding dimension. The first specifier corresponds to the first dimension, the second to the second and so on. Where n < the rank, the remaining dimensions are sliced across the full range of their indices.
Each slice specifier is of the form "a:b", which specifies a slice from index a, up to but not including index b. Where index a is omitted a is assumed to be 0. Where index b is omitted, b is assumed to be the length of this dimension. Where both are omitted (eg: ":") the slice is assumed to encompass that entire dimension.
Where one of the slice specifiers is a single integer, eg: [1], we want to generate a rank-1 dimension object, as opposed to eg: [1,2] which implies we want to take a rank dimensional object with one dimension of size 1.
The return value is a vector of pairs with length equal to the rank of this object. Each pair corresponds to the range of indices from the corresponding dimension to be sliced from, as specified in the input slice object.
Examples:
For a rank 1 object of shape(5):
getSliceRegion(:) => < <0,5> > getSliceRegion(2:3) => < <2,3> > getSliceRegion(:3) => < <0,3> > getSliceRegion(2:) => < <2,5> >
For a rank 2 object of shape(4,5):
getSliceRegion(2:3) => < <2,3> <0,5> > getSliceRegion(2) => < <2,3> <0,5> > NB: but return object requested will have rank 1, shape(5), with values taken from index 2 of this object's first dimension.
For a rank 3 object of shape (2,4,6):
getSliceRegion(0:2,0:4,0:6) => < <0,2> <0,4> <0,6> > getSliceRegion(:,:,:) => < <0,2> <0,4> <0,6> > getSliceRegion(0:1) => < <0,1> <0,4> <0,6> > getSliceRegion(:1,0:2) => < <0,1> <0,2> <0,6> >
Note: Not unit tested in c++.
DataTypes::RegionLoopRangeType escript::DataTypes::getSliceRegionLoopRange | ( | const DataTypes::RegionType & | region | ) |
Modify region to copy from in order to deal with the case where one range in the region contains identical indexes, eg: <<1,1><0,3><0,3>> This situation implies we want to copy from an object with rank greater than that of this object. eg: we want to copy the values from a two dimensional slice out of a three dimensional object into a two dimensional object. We do this by taking a slice from the other object where one dimension of the slice region is of size 1. So in the above example, we modify the above region like so: <<1,2><0,3><0,3>> and take this slice.
Referenced by escript::DataConstant::DataConstant(), escript::DataExpanded::DataExpanded(), escript::DataTagged::DataTagged(), real_t_eps(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), and escript::DataTagged::setSlice().
|
inline |
Returns the maximum finite value for the index_t type.
Referenced by dudley::NodeFile::createDenseDOFLabeling(), dudley::util::getFlaggedMinMaxInt(), finley::util::getFlaggedMinMaxInt(), dudley::util::getMinMaxInt(), finley::util::getMinMaxInt(), dudley::DudleyDomain::resolveNodeIds(), and finley::FinleyDomain::resolveNodeIds().
|
inline |
Returns the minimum finite value for the index_t type.
Referenced by dudley::NodeFile::createDenseDOFLabeling(), dudley::util::getFlaggedMinMaxInt(), finley::util::getFlaggedMinMaxInt(), dudley::util::getMinMaxInt(), finley::util::getMinMaxInt(), and paso::util::iMax().
int escript::DataTypes::noValues | ( | const ShapeType & | shape | ) |
Calculate the number of values in a datapoint with the given shape.
References noValues().
Referenced by speckley::Rectangle::assembleGradient(), escript::binaryOpDataReadyHelperCCC(), escript::binaryOpDataReadyHelperECE(), escript::binaryOpDataReadyHelperEEC(), escript::binaryOpDataReadyHelperEEE(), escript::binaryOpDataReadyHelperEET(), escript::binaryOpDataReadyHelperETE(), escript::binaryOpDataReadyHelperTCT(), escript::binaryOpDataReadyHelperTTC(), escript::binaryOpDataReadyHelperTTT(), escript::checkOffset(), escript::WrappedArray::convertArrayC(), escript::WrappedArray::convertArrayR(), escript::WrappedArray::convertNumpyArray(), escript::WrappedArray::convertNumpyArrayC(), escript::DataTypes::DataVectorAlt< cplx_t >::copyFromArray(), escript::DataTypes::DataVectorTaipan::copyFromArray(), escript::DataTypes::DataVectorAlt< cplx_t >::copyFromArrayToOffset(), escript::DataTypes::DataVectorTaipan::copyFromArrayToOffset(), copySlice(), copySliceFrom(), escript::Data::Data(), escript::DataTagged::DataTagged(), getRelIndex(), escript::Data::getValueOfGlobalDataPointAsTuple(), escript::MPIDataReducer::groupSend(), ripley::Brick::interpolateNodesOnFaces(), ripley::Rectangle::interpolateNodesOnFaces(), escript::matrix_inverse(), speckley::Brick::randomFill(), ripley::Rectangle::randomFillWorker(), real_t_eps(), escript::MPIDataReducer::recvFrom(), escript::reductionOpVector(), escript::DataLazy::resolveNodeReduction(), escript::saveDataCSV(), and escript::trace().
int escript::DataTypes::noValues | ( | const RegionLoopRangeType & | region | ) |
Calculate the number of values for the given region.
Referenced by noValues().
void escript::DataTypes::pointToStream | ( | std::ostream & | os, |
const RealVectorType::ElementType * | data, | ||
const ShapeType & | shape, | ||
int | offset, | ||
bool | needsep = true , |
||
const std::string & | sep = "," |
||
) |
Display a single value (with the specified shape) from the data.
Despite its similar name this function behaves differently to pointToString. There are no prefixes or (i,j,k) identifiers on each field. each datapoint is printed without new lines. It also works with double* rather than vectors so be careful what you pass it.
os | - stream to write to |
data | - vector containing the datapoint |
shape | - shape of the datapoint |
offset | - start of the datapoint within data |
needsep | - Does this output need to start with a separator |
sep | - separator string to print between components |
Referenced by escript::saveDataCSV().
std::string escript::DataTypes::pointToString | ( | const RealVectorType & | data, |
const ShapeType & | shape, | ||
int | offset, | ||
const std::string & | prefix | ||
) |
Display a single value (with the specified shape) from the data.
data | - vector containing the datapoint |
shape | - shape of the datapoint |
offset | - start of the datapoint within data |
prefix | - string to prepend to the output |
Referenced by escript::DataLazy::resolveNodeTProd(), escript::DataConstant::toString(), escript::DataExpanded::toString(), and escript::DataTagged::toString().
|
inline |
Returns the machine epsilon for the real_t type.
References getResultSliceShape(), getSliceRegion(), getSliceRegionLoopRange(), noValues(), and shapeToString().
Referenced by paso::Function::derivative(), ripley::Brick::findNode(), ripley::Rectangle::findNode(), paso::FCT_Solver::initialize(), paso::TransportProblem::solve(), and paso::Solver().
|
inline |
Returns the maximum finite value for the real_t type.
Referenced by finley::FinleyDomain::addDiracPoints(), paso::ReactiveSolver::getSafeTimeStepSize(), paso::FCT_FluxLimiter::setU_tilde(), and paso::TransportProblem::solve().
void escript::DataTypes::releaseUnusedMemory | ( | ) |
releases unused memory in the memory manager.
References escript::Taipan::release_unused_arrays().
Referenced by BOOST_PYTHON_MODULE().
std::string escript::DataTypes::shapeToString | ( | const DataTypes::ShapeType & | shape | ) |
Return the given shape as a string.
shape | - Input. |
Referenced by escript::Data::copyWithMask(), createShapeErrorMessage(), escript::DataAbstract::operandCheck(), real_t_eps(), escript::DataLazy::resolveNodeBinary(), and escript::DataLazy::resolveNodeTProd().
Taipan escript::DataTypes::arrayManager |
|
static |
The maximum number of dimensions a datapoint can have.
Referenced by escript::DataConstant::dump(), escript::DataExpanded::dump(), escript::DataTagged::dump(), and escript::load().
|
static |
Use this instead of creating empty shape objects for scalars.
Referenced by escript::Data::dp_algorithm(), escript::TestDomain::getX(), escript::Data::interpolateFromTable1D(), escript::Data::interpolateFromTable2D(), escript::Data::interpolateFromTable3D(), ripley::Brick::interpolateNodesOnFaces(), escript::Data::nonuniforminterp(), escript::Data::nonuniformslope(), and ripley::Rectangle::randomFillWorker().