escript
Revision_
|
Contains the types to represent Shapes, Regions, RegionLoop ranges and vectors of data as well as the functions to manipulate them. More...
Typedefs | |
typedef escript::DataVector | ValueType |
Vector to store underlying data. More... | |
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 |
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 boost::python::object &key) |
Determine the region specified by the given python slice object. More... | |
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... | |
bool | checkOffset (ValueType::size_type offset, int size, int noval) |
void | copySlice (ValueType &left, const ShapeType &leftShape, ValueType::size_type leftOffset, const ValueType &other, const ShapeType &otherShape, ValueType::size_type otherOffset, const RegionLoopRangeType ®ion) |
Copy a data slice specified by the given region and offset from the "other" view into the "left" view at the given offset. More... | |
void | copySliceFrom (ValueType &left, const ShapeType &leftShape, ValueType::size_type leftOffset, const ValueType &other, const ShapeType &otherShape, ValueType::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 | pointToStream (std::ostream &os, const ValueType::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 ValueType &data, const ShapeType &shape, int offset, const std::string &prefix) |
Display a single value (with the specified shape) from the data. More... | |
void | copyPoint (ValueType &dest, ValueType::size_type doffset, ValueType::size_type nvals, const ValueType &src, ValueType::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... | |
int | getRank (const DataTypes::ShapeType &shape) |
Return the rank (number of dimensions) of the given shape. More... | |
DataTypes::ValueType::size_type | getRelIndex (const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type i) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
DataTypes::ValueType::size_type | getRelIndex (const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type i, DataTypes::ValueType::size_type j) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
DataTypes::ValueType::size_type | getRelIndex (const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type i, DataTypes::ValueType::size_type j, DataTypes::ValueType::size_type k) |
Compute the offset (in 1D vector) of a given subscript with a shape. More... | |
DataTypes::ValueType::size_type | getRelIndex (const DataTypes::ShapeType &shape, DataTypes::ValueType::size_type i, DataTypes::ValueType::size_type j, DataTypes::ValueType::size_type k, DataTypes::ValueType::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... | |
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... | |
Contains the types to represent Shapes, Regions, RegionLoop ranges and vectors of data as well as the functions to manipulate them.
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.
Vector to store underlying data.
|
inline |
Referenced by copyPoint(), copySlice(), and copySliceFrom().
Test if two shapes are equal.
References copyPoint(), copySlice(), copySliceFrom(), createShapeErrorMessage(), ESCRIPT_DLL_API, pointToStream(), and pointToString().
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 | ( | ValueType & | dest, |
ValueType::size_type | doffset, | ||
ValueType::size_type | nvals, | ||
const ValueType & | src, | ||
ValueType::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 |
References checkOffset(), EsysAssert, and escript::DataVector::size().
Referenced by checkShape(), escript::DataExpanded::copy(), and escript::DataExpanded::DataExpanded().
void escript::DataTypes::copySlice | ( | ValueType & | left, |
const ShapeType & | leftShape, | ||
ValueType::size_type | leftOffset, | ||
const ValueType & | other, | ||
const ShapeType & | otherShape, | ||
ValueType::size_type | otherOffset, | ||
const RegionLoopRangeType & | region | ||
) |
Copy a data slice specified by the given region and offset from the "other" view into the "left" view 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 view to copy data from. |
References checkOffset(), EsysAssert, getRank(), getRelIndex(), getResultSliceShape(), noValues(), and escript::DataVector::size().
Referenced by checkShape(), escript::DataConstant::DataConstant(), escript::DataExpanded::DataExpanded(), and escript::DataTagged::DataTagged().
void escript::DataTypes::copySliceFrom | ( | ValueType & | left, |
const ShapeType & | leftShape, | ||
ValueType::size_type | leftOffset, | ||
const ValueType & | other, | ||
const ShapeType & | otherShape, | ||
ValueType::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(), EsysAssert, getRank(), getRelIndex(), getResultSliceShape(), noValues(), and escript::DataVector::size().
Referenced by checkShape(), 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().
|
inline |
Return the rank (number of dimensions) of the given shape.
shape |
References ESCRIPT_DLL_API.
Referenced by escript::binaryOp(), copySlice(), copySliceFrom(), escript::DataMaths::determineResultShape(), getRelIndex(), escript::DataMaths::matMult(), escript::DataMaths::matrix_inverse(), escript::DataMaths::nonsymmetric(), pointToStream(), pointToString(), escript::DataMaths::swapaxes(), escript::DataMaths::symmetric(), escript::DataMaths::trace(), and escript::DataMaths::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 ESCRIPT_DLL_API, EsysAssert, getRank(), and noValues().
Referenced by escript::WrappedArray::convertArray(), escript::WrappedArray::convertNumpyArray(), escript::DataVector::copyFromArrayToOffset(), copySlice(), copySliceFrom(), escript::DataExpanded::copyToDataPoint(), escript::DataMaths::eigenvalues(), escript::DataMaths::eigenvalues_and_eigenvectors(), escript::WrappedArray::getElt(), escript::DataMaths::matMult(), escript::DataMaths::matrix_inverse(), escript::DataMaths::nonsymmetric(), pointToStream(), pointToString(), escript::DataMaths::swapaxes(), escript::DataMaths::symmetric(), escript::DataMaths::trace(), and escript::DataMaths::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 ESCRIPT_DLL_API, EsysAssert, 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 ESCRIPT_DLL_API, EsysAssert, 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 ESCRIPT_DLL_API, EsysAssert, 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(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), and escript::DataTagged::setSlice().
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++.
Referenced by escript::Data::getItem(), and escript::Data::setItemD().
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(), escript::DataConstant::setSlice(), escript::DataExpanded::setSlice(), and escript::DataTagged::setSlice().
int escript::DataTypes::noValues | ( | const ShapeType & | shape | ) |
Calculate the number of values in a datapoint with the given shape.
References noValues().
Referenced by escript::DataMaths::binaryOp(), escript::DataMaths::checkOffset(), escript::WrappedArray::convertArray(), escript::WrappedArray::convertNumpyArray(), escript::DataVector::copyFromArray(), escript::DataVector::copyFromArrayToOffset(), escript::Data::Data(), escript::DataTagged::DataTagged(), getRelIndex(), escript::Data::getValueOfGlobalDataPointAsTuple(), escript::MPIDataReducer::groupSend(), escript::DataMaths::matrix_inverse(), ripley::Brick::randomFill(), ripley::Rectangle::randomFill(), speckley::Rectangle::randomFill(), speckley::Brick::randomFill(), ripley::Brick::randomFillWorker(), ripley::Rectangle::randomFillWorker(), escript::MPIDataReducer::recvFrom(), escript::DataMaths::reductionOp(), escript::DataLazy::resolveNodeReduction(), escript::saveDataCSV(), escript::DataMaths::trace(), and escript::DataMaths::unaryOp().
int escript::DataTypes::noValues | ( | const RegionLoopRangeType & | region | ) |
Calculate the number of values for the given region.
Referenced by copySlice(), copySliceFrom(), and noValues().
void escript::DataTypes::pointToStream | ( | std::ostream & | os, |
const ValueType::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 |
References EsysAssert, getRank(), and getRelIndex().
Referenced by checkShape(), and escript::saveDataCSV().
std::string escript::DataTypes::pointToString | ( | const ValueType & | 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 |
References EsysAssert, getRank(), getRelIndex(), and escript::DataVector::size().
Referenced by checkShape(), escript::DataLazy::resolveNodeTProd(), escript::DataConstant::toString(), escript::DataExpanded::toString(), and escript::DataTagged::toString().
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(), escript::DataLazy::resolveNodeBinary(), and escript::DataLazy::resolveNodeTProd().
|
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(), escript::Data::nonuniforminterp(), escript::Data::nonuniformslope(), ripley::Brick::randomFillWorker(), and ripley::Rectangle::randomFillWorker().