Public Member Functions | Private Types | Private Member Functions | Private Attributes

escript::DataLazy Class Reference

Wraps an expression tree of other DataObjects. The data will be evaluated when required. More...

#include <DataLazy.h>

Inheritance diagram for escript::DataLazy:
escript::DataAbstract

List of all members.

Public Member Functions

ESCRIPT_DLL_API DataLazy (DataAbstract_ptr p)
 Create an IDENTITY DataLazy for the given DataAbstract.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, ES_optype op)
 Produce a DataLazy for a unary operation.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, ES_optype op, double tol)
 Produce a DataLazy for a unary operation.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, ES_optype op, int axis_offset)
 Produce a DataLazy for a unary operation which requires a parameter.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op)
 Produce a DataLazy for a binary operation.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, DataAbstract_ptr right, ES_optype op, int axis_offset, int transpose)
 Produce a DataLazy for a binary operation with additional paramters.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr left, ES_optype op, const int axis0, const int axis1)
 Produce a DataLazy for a unary operation which requires two integer parameters.
ESCRIPT_DLL_API DataLazy (DataAbstract_ptr mask, DataAbstract_ptr left, DataAbstract_ptr right)
 Produce a DataLazy for a unary operation which requires two integer parameters.
ESCRIPT_DLL_API ~DataLazy ()
ESCRIPT_DLL_API DataReady_ptr resolve ()
 Evaluate the lazy expression.
ESCRIPT_DLL_API std::string toString () const
 Write the data as a string.
ESCRIPT_DLL_API DataAbstractdeepCopy ()
 Return a deep copy of the current object.
ESCRIPT_DLL_API
ValueType::size_type 
getLength () const
 This method throws an exception. It does not really make sense to ask this question of lazy data.
ESCRIPT_DLL_API DataAbstractgetSlice (const DataTypes::RegionType &region) const
 Return the given slice from this object.
DataTypes::ValueType::size_type getPointOffset (int sampleNo, int dataPointNo) const
 Return the offset for the given sample. This returns the offset for the given point into the container holding the point data.
DataTypes::ValueType::size_type getPointOffset (int sampleNo, int dataPointNo)
ESCRIPT_DLL_API size_t getMaxSampleSize () const
ESCRIPT_DLL_API const ValueTyperesolveSample (int sampleNo, size_t &roffset)
 Compute the value of the expression for the given sample.
ESCRIPT_DLL_API bool actsExpanded () const
 if resolve() was called would it produce expanded data.
virtual ESCRIPT_DLL_API void setToZero ()
 Produces an IDENTITY DataLazy containing zero. The result will have the same shape and functionspace as before.
ESCRIPT_DLL_API void resolveGroupWorker (std::vector< DataLazy * > &dats)

Private Types

typedef DataAbstract parent
typedef DataTypes::ValueType ValueType
typedef DataTypes::ShapeType ShapeType

Private Member Functions

void LazyNodeSetup ()
const DataTypes::ValueTyperesolveNodeUnary (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeReduction (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeSample (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeBinary (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeNP1OUT (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeNP1OUT_P (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeTProd (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeNP1OUT_2P (int tid, int sampleNo, size_t &roffset)
const DataTypes::ValueTyperesolveNodeCondEval (int tid, int sampleNo, size_t &roffset)
void intoString (std::ostringstream &oss) const
void intoTreeString (std::ostringstream &oss, std::string indent) const
void collapse ()
 Converts the DataLazy into an IDENTITY storing the value of the expression. This method uses the original methods on the Data class to evaluate the expressions. For this reason, it should not be used on DataExpanded instances. (To do so would defeat the purpose of using DataLazy in the first place).
DataReady_ptr collapseToReady ()
 Evaluates the expression using methods on Data. This does the work for the collapse method. For reasons of efficiency do not call this method on DataExpanded nodes.
void resolveToIdentity ()
 resolve the expression can store it in the current node The current node will be converted to an identity node.
void makeIdentity (const DataReady_ptr &p)
 helper method for resolveToIdentity and the identity constructor
DataReady_ptr resolveNodeWorker ()
 resolve to a ReadyData object using storage at nodes

Private Attributes

DataReady_ptr m_id
DataLazy_ptr m_left
DataLazy_ptr m_right
DataLazy_ptr m_mask
ES_optype m_op
size_t m_samplesize
char m_readytype
int m_axis_offset
int m_transpose
int m_SL
int m_SM
int m_SR
double m_tol
size_t m_children
size_t m_height
int * m_sampleids
DataVector m_samples

Detailed Description

Wraps an expression tree of other DataObjects. The data will be evaluated when required.

NOTE: This class assumes that the Data being pointed at are immutable.


Member Typedef Documentation


Constructor & Destructor Documentation

escript::DataLazy::DataLazy ( DataAbstract_ptr  p  ) 

Create an IDENTITY DataLazy for the given DataAbstract.

Parameters:
p DataAbstract to be wrapped.
Exceptions:
DataException if p is lazy data or it is not constant, tagged or expanded.

References LAZYDEBUG, m_id, m_samplesize, and makeIdentity().

Referenced by DataLazy(), and deepCopy().

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
ES_optype  op 
)

Produce a DataLazy for a unary operation.

Parameters:
left DataAbstract to be operated on.
op unary operation to perform.
Exceptions:
DataException if op is not a unary operation or if p cannot be converted to a DataLazy. Note that IDENTITY is not considered a unary operation.

References DataLazy(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
ES_optype  op,
double  tol 
)

Produce a DataLazy for a unary operation.

Parameters:
left DataAbstract to be operated on.
op unary operation to perform.
tol tolerance for operation
Exceptions:
DataException if op is not a unary operation or if p cannot be converted to a DataLazy. Note that IDENTITY is not considered a unary operation.

References DataLazy(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
ES_optype  op,
int  axis_offset 
)

Produce a DataLazy for a unary operation which requires a parameter.

Parameters:
left DataAbstract to be operated on.
op unary operation to perform.
axis_offset the parameter for the operation
Exceptions:
DataException if op is not a unary operation or if p cannot be converted to a DataLazy. Note that IDENTITY is not considered a unary operation.

References DataLazy(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
DataAbstract_ptr  right,
ES_optype  op 
)

Produce a DataLazy for a binary operation.

Parameters:
left left operand
right right operand
op unary operation to perform.
Exceptions:
DataException if op is not a binary operation or if left or right cannot be converted to a DataLazy.

References escript::Data::borrowDataPtr(), DataLazy(), escript::DataAbstract::getFunctionSpace(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_right, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
DataAbstract_ptr  right,
ES_optype  op,
int  axis_offset,
int  transpose 
)

Produce a DataLazy for a binary operation with additional paramters.

Parameters:
left left operand
right right operand
op unary operation to perform.
axis_offset 
transpose 
Exceptions:
DataException if op is not a binary operation requiring parameters or if left or right cannot be converted to a DataLazy.

References escript::Data::borrowDataPtr(), DataLazy(), escript::DataAbstract::getFunctionSpace(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_right, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  left,
ES_optype  op,
const int  axis0,
const int  axis1 
)

Produce a DataLazy for a unary operation which requires two integer parameters.

Parameters:
left DataAbstract to be operated on.
op unary operation to perform.
axis0 the first parameter for the operation
axis1 the second parameter for the operation
Exceptions:
DataException if op is not a unary operation or if p cannot be converted to a DataLazy. Note that IDENTITY is not considered a unary operation.

References DataLazy(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_readytype, m_samplesize, and SIZELIMIT.

escript::DataLazy::DataLazy ( DataAbstract_ptr  mask,
DataAbstract_ptr  left,
DataAbstract_ptr  right 
)

Produce a DataLazy for a unary operation which requires two integer parameters.

Parameters:
mask scalar mask to select values.
left DataAbstract to use for true mask.
right DataAbstract to use for false mask.

References DataLazy(), escript::DataAbstract::getNoValues(), escript::DataAbstract::getNumDPPSample(), LAZYDEBUG, LazyNodeSetup(), m_children, m_height, m_left, m_mask, m_readytype, m_right, m_samplesize, and SIZELIMIT.

escript::DataLazy::~DataLazy (  ) 

References m_sampleids.


Member Function Documentation

bool escript::DataLazy::actsExpanded (  )  const [virtual]

if resolve() was called would it produce expanded data.

Reimplemented from escript::DataAbstract.

References m_readytype.

void escript::DataLazy::collapse (  )  [private]

Converts the DataLazy into an IDENTITY storing the value of the expression. This method uses the original methods on the Data class to evaluate the expressions. For this reason, it should not be used on DataExpanded instances. (To do so would defeat the purpose of using DataLazy in the first place).

References collapseToReady(), escript::IDENTITY, m_id, m_op, and m_readytype.

Referenced by getPointOffset(), resolveNodeSample(), and resolveNodeWorker().

DataReady_ptr escript::DataLazy::collapseToReady (  )  [private]

Evaluates the expression using methods on Data. This does the work for the collapse method. For reasons of efficiency do not call this method on DataExpanded nodes.

References escript::Data::abs(), escript::ABS, escript::Data::acos(), escript::ACOS, escript::Data::acosh(), escript::ACOSH, escript::ADD, escript::Data::asin(), escript::ASIN, escript::Data::asinh(), escript::ASINH, escript::Data::atan(), escript::ATAN, escript::Data::atanh(), escript::ATANH, escript::Data::borrowReadyPtr(), escript::C_GeneralTensorProduct(), escript::Data::cos(), escript::COS, escript::Data::cosh(), escript::COSH, escript::DIV, escript::Data::erf(), escript::ERF, escript::Data::exp(), escript::EXP, escript::EZ, escript::GEZ, escript::GZ, escript::IDENTITY, escript::LEZ, escript::Data::log(), escript::LOG, escript::Data::log10(), escript::LOG10, escript::LZ, m_axis_offset, m_id, m_left, m_op, m_readytype, m_right, m_tol, m_transpose, escript::MAXVAL, escript::Data::minval(), escript::MINVAL, escript::MUL, escript::Data::neg(), escript::NEG, escript::NEZ, escript::Data::nonsymmetric(), escript::NSYM, escript::Data::oneOver(), escript::opToString(), escript::POS, escript::PROD, escript::RECIP, escript::Data::sign(), escript::SIGN, escript::Data::sin(), escript::SIN, escript::Data::sinh(), escript::SINH, escript::Data::sqrt(), escript::SQRT, escript::SUB, escript::SWAP, escript::Data::swapaxes(), escript::SYM, escript::Data::symmetric(), escript::Data::tan(), escript::TAN, escript::Data::tanh(), escript::TANH, escript::Data::trace(), escript::TRACE, escript::TRANS, escript::Data::transpose(), escript::Data::whereNegative(), escript::Data::whereNonNegative(), escript::Data::whereNonPositive(), escript::Data::whereNonZero(), escript::Data::wherePositive(), and escript::Data::whereZero().

Referenced by collapse().

DataAbstract * escript::DataLazy::deepCopy (  )  [virtual]

Return a deep copy of the current object.

Implements escript::DataAbstract.

References DataLazy(), m_axis_offset, m_id, m_left, m_op, m_right, m_tol, m_transpose, and escript::opToString().

DataTypes::ValueType::size_type escript::DataLazy::getLength (  )  const [virtual]

This method throws an exception. It does not really make sense to ask this question of lazy data.

Implements escript::DataAbstract.

ESCRIPT_DLL_API size_t escript::DataLazy::getMaxSampleSize (  )  const
Returns:
the largest samplesize required to evaluate the expression.
DataTypes::ValueType::size_type escript::DataLazy::getPointOffset ( int  sampleNo,
int  dataPointNo 
) const [virtual]

Return the offset for the given sample. This returns the offset for the given point into the container holding the point data.

Parameters:
sampleNo - Input - sample number.
dataPointNo - Input - data point number.

Implements escript::DataAbstract.

References escript::IDENTITY, m_id, m_left, m_op, m_readytype, and m_right.

DataTypes::ValueType::size_type escript::DataLazy::getPointOffset ( int  sampleNo,
int  dataPointNo 
) [virtual]
DataAbstract * escript::DataLazy::getSlice ( const DataTypes::RegionType region  )  const [virtual]

Return the given slice from this object.

NB: The caller is responsible for managing the object created.

Implements escript::DataAbstract.

void escript::DataLazy::intoString ( std::ostringstream &  oss  )  const [private]

Does the work for toString.

References m_axis_offset, m_id, m_left, m_mask, m_op, m_right, m_transpose, and escript::opToString().

Referenced by toString().

void escript::DataLazy::intoTreeString ( std::ostringstream &  oss,
std::string  indent 
) const [private]
Warning:
internal use only!!

References m_axis_offset, m_id, m_left, m_op, escript::DataAbstract::m_rank, m_right, m_samplesize, m_transpose, and escript::opToString().

Referenced by toString().

void escript::DataLazy::LazyNodeSetup (  )  [private]

Allocates sample storage at each node

References m_sampleids, m_samples, m_samplesize, omp_get_max_threads, and escript::DataVector::resize().

Referenced by DataLazy().

void escript::DataLazy::makeIdentity ( const DataReady_ptr p  )  [private]

helper method for resolveToIdentity and the identity constructor

References m_axis_offset, m_children, m_height, m_id, m_left, m_op, m_readytype, m_right, m_samplesize, m_SL, m_SM, m_SR, and m_transpose.

Referenced by DataLazy(), and resolveToIdentity().

DataReady_ptr escript::DataLazy::resolve (  )  [virtual]

Evaluate the lazy expression.

Returns:
A DataReady with the value of the lazy expresion.

Implements escript::DataAbstract.

References m_id, and resolveToIdentity().

const DataTypes::ValueType * escript::DataLazy::resolveNodeBinary ( int  tid,
int  sampleNo,
size_t &  roffset 
) [private]
const DataTypes::ValueType * escript::DataLazy::resolveNodeCondEval ( int  tid,
int  sampleNo,
size_t &  roffset 
) [private]
const DataTypes::ValueType * escript::DataLazy::resolveSample ( int  sampleNo,
size_t &  roffset 
)

Compute the value of the expression for the given sample.

Returns:
Vector which stores the value of the subexpression for the given sample.
Parameters:
sampleNo Sample number to evaluate.
roffset (output parameter) the offset in the return vector where the result begins.

The return value will be an existing vector so do not deallocate it.

References omp_get_thread_num, and resolveNodeSample().

Referenced by escript::Data::getSampleDataRO(), and escript::Data::lazyAlgWorker().

void escript::DataLazy::resolveToIdentity (  )  [private]

resolve the expression can store it in the current node The current node will be converted to an identity node.

References escript::IDENTITY, m_op, makeIdentity(), and resolveNodeWorker().

Referenced by resolve().

void escript::DataLazy::setToZero (  )  [virtual]

Produces an IDENTITY DataLazy containing zero. The result will have the same shape and functionspace as before.

Reimplemented from escript::DataAbstract.

std::string escript::DataLazy::toString (  )  const [virtual]

Member Data Documentation

Referenced by DataLazy(), and makeIdentity().

size_t escript::DataLazy::m_height [private]

Referenced by DataLazy(), makeIdentity(), and toString().

int escript::DataLazy::m_SL [private]

Referenced by makeIdentity(), and resolveNodeTProd().

int escript::DataLazy::m_SM [private]

Referenced by makeIdentity(), and resolveNodeTProd().

int escript::DataLazy::m_SR [private]

Referenced by makeIdentity(), and resolveNodeTProd().


The documentation for this class was generated from the following files: