DataTagged.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __ESCRIPT_DATATAGGED_H__
#define __ESCRIPT_DATATAGGED_H__
#include "system_dep.h"
#include "DataReady.h"
#include "DataTypes.h"
#include <map>
#include <vector>
namespace escript {
class DataConstant;
class ESCRIPT_DLL_API DataTagged : public DataReady
{
typedef DataReady parent;
public:
//
// Types for the lists of tags and values.
typedef std::vector<int> TagListType;
typedef std::vector<DataTypes::RealVectorType::ElementType> FloatBatchType;
typedef std::vector<DataTypes::CplxVectorType::ElementType> CplxBatchType;
//
// Map from a tag to an offset into the data array.
typedef std::map<int, int> DataMapType;
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const int tags[],
const DataTypes::RealVectorType& data);
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const int tags[],
const DataTypes::CplxVectorType& data);
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const TagListType& tags,
const DataTypes::RealVectorType& data);
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType &shape,
const TagListType& tags,
const DataTypes::CplxVectorType& data);
DataTagged(const DataTagged& other);
explicit DataTagged(const DataConstant& other);
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType& shape,
const DataTypes::RealVectorType& defaultvalue,
const DataTagged* tagsource=0);
explicit DataTagged(const FunctionSpace& what,
const DataTypes::ShapeType& shape,
const DataTypes::CplxVectorType& defaultvalue,
const DataTagged* tagsource=0);
inline virtual
~DataTagged() {};
bool
isTagged() const
{
return true;
};
bool
hasNaN() const;
void
replaceNaN(DataTypes::real_t value);
void
replaceNaN(DataTypes::cplx_t value);
// ESCRIPT_DLL_API class already exported
virtual bool
hasInf() const;
// ESCRIPT_DLL_API class already exported
virtual void
replaceInf(DataTypes::real_t value);
// ESCRIPT_DLL_API class already exported
virtual void
replaceInf(DataTypes::cplx_t value);
virtual
DataAbstract*
deepCopy() const;
// ESCRIPT_DLL_API class already exported
virtual
DataAbstract*
zeroedCopy() const;
virtual
DataTypes::real_t*
getSampleDataByTag(int tag, DataTypes::real_t dummy=0);
virtual
DataTypes::cplx_t*
getSampleDataByTag(int tag, DataTypes::cplx_t dummy);
virtual
std::string
toString() const;
virtual
void
dump(const std::string fileName) const;
virtual int
matrixInverse(DataAbstract* out) const;
virtual
void
setToZero();
virtual
int
getTagNumber(int dpno);
virtual
DataTypes::RealVectorType::size_type
getPointOffset(int sampleNo,
int dataPointNo) const;
void
addTaggedValues(const TagListType& tagKeys,
const FloatBatchType& values,
const ShapeType& vShape);
void
addTaggedValues(const TagListType& tagKeys,
const DataTypes::RealVectorType& values,
const ShapeType& vShape);
void
addTaggedValue(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::RealVectorType& value,
int dataOffset=0);
void
addTaggedValue(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::CplxVectorType& value,
int dataOffset=0);
void
addTag(int tagKey);
void
setTaggedValue(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::RealVectorType& value,
int dataOffset=0);
void
setTaggedValue(int tagKey,
const DataTypes::ShapeType& pointshape,
const DataTypes::CplxVectorType& value,
int dataOffset=0);
DataTypes::RealVectorType::reference
getDataByTagRW(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0);
DataTypes::RealVectorType::const_reference
getDataByTagRO(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const;
DataTypes::CplxVectorType::reference
getDataByTagRW(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
DataTypes::CplxVectorType::const_reference
getDataByTagRO(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const;
DataTypes::RealVectorType::size_type
getOffsetForTag(int tag) const;
DataTypes::RealVectorType&
getVectorRW();
const DataTypes::RealVectorType&
getVectorRO() const;
DataTypes::CplxVectorType&
getVectorRWC();
const DataTypes::CplxVectorType&
getVectorROC() const;
virtual DataTypes::RealVectorType&
getTypedVectorRW(DataTypes::real_t dummy);
virtual const DataTypes::RealVectorType&
getTypedVectorRO(DataTypes::real_t dummy) const;
virtual DataTypes::CplxVectorType&
getTypedVectorRW(DataTypes::cplx_t dummy);
virtual const DataTypes::CplxVectorType&
getTypedVectorRO(DataTypes::cplx_t dummy) const;
const DataMapType&
getTagLookup() const;
bool
isCurrentTag(int tag) const;
DataTypes::RealVectorType::reference
getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0);
DataTypes::RealVectorType::const_reference
getDefaultValueRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const;
DataTypes::CplxVectorType::reference
getDefaultValueRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
DataTypes::CplxVectorType::const_reference
getDefaultValueRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const;
virtual
DataTypes::RealVectorType::size_type
getLength() const;
virtual
DataAbstract*
getSlice(const DataTypes::RegionType& region) const;
DataTagged(const DataTagged& other,
const DataTypes::RegionType& region);
virtual
void
setSlice(const DataAbstract* other,
const DataTypes::RegionType& region);
virtual void
symmetric(DataAbstract* ev);
virtual void
antisymmetric(DataAbstract* ev);
virtual void
hermitian(DataAbstract* ev);
virtual void
antihermitian(DataAbstract* ev);
virtual void
trace(DataAbstract* ev, int axis_offset);
virtual void
swapaxes(DataAbstract* ev, int axis0, int axis1);
virtual void
transpose(DataAbstract* ev, int axis_offset);
virtual void
eigenvalues(DataAbstract* ev);
virtual void
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
DataTypes::RealVectorType::size_type
getDefaultOffset() const;
size_t
getTagCount() const;
void
complicate();
protected:
private:
//
// The offset lookup table
DataMapType m_offsetLookup;
//
// the offset to the default value
static const int m_defaultValueOffset = 0;
// the actual data
DataTypes::RealVectorType m_data_r;
DataTypes::CplxVectorType m_data_c;
};
inline
bool
DataTagged::isCurrentTag(int tag) const
{
DataMapType::const_iterator pos(m_offsetLookup.find(tag));
return (pos!=m_offsetLookup.end());
}
inline
DataTypes::RealVectorType::size_type
DataTagged::getDefaultOffset() const
{
return m_defaultValueOffset;
}
inline
DataTypes::RealVectorType::reference
DataTagged::getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy)
{
return getVectorRW()[i]; // getVectorRW has exclusive write checks
}
inline
DataTypes::RealVectorType::const_reference
DataTagged::getDefaultValueRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy) const
{
return getVectorRO()[i];
}
inline
DataTypes::CplxVectorType::reference
DataTagged::getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::cplx_t dummy)
{
return getVectorRWC()[i]; // getVectorRW has exclusive write checks
}
inline
DataTypes::CplxVectorType::const_reference
DataTagged::getDefaultValueRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const
{
return getVectorROC()[i];
}
inline
const DataTagged::DataMapType&
DataTagged::getTagLookup() const
{
return m_offsetLookup;
}
inline
DataTypes::RealVectorType::size_type
DataTagged::getLength() const
{
return std::max(m_data_c.size(), m_data_r.size());
}
} // end of namespace
#endif // __ESCRIPT_DATATAGGED_H__
DataReady.h
DataTypes.h
V
#define V(_K_, _I_)
Definition: ShapeFunctions.cpp:121
escript::DataAbstract
Definition: DataAbstract.h:63
escript::DataConstant
DataConstant stores a single data point which represents the entire function space.
Definition: DataConstant.h:38
escript::DataReady
Definition: DataReady.h:37
escript::DataTagged
Simulates a full dataset accessible via sampleNo and dataPointNo.
Definition: DataTagged.h:46
escript::DataTagged::getDefaultValueRO
DataTypes::RealVectorType::const_reference getDefaultValueRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const
Definition: DataTagged.h:738
escript::DataTagged::isTagged
bool isTagged() const
Definition: DataTagged.h:153
escript::DataTagged::getDataByTagRO
DataTypes::CplxVectorType::const_reference getDataByTagRO(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const
escript::DataTagged::~DataTagged
virtual ~DataTagged()
Destructor.
Definition: DataTagged.h:150
escript::DataTagged::CplxBatchType
std::vector< DataTypes::CplxVectorType::ElementType > CplxBatchType
Definition: DataTagged.h:54
escript::DataTagged::isCurrentTag
bool isCurrentTag(int tag) const
isCurrentTag
Definition: DataTagged.h:716
escript::DataTagged::m_offsetLookup
DataMapType m_offsetLookup
Definition: DataTagged.h:701
escript::DataTagged::getDefaultOffset
DataTypes::RealVectorType::size_type getDefaultOffset() const
Returns the offset in the structure which stores the default value.
Definition: DataTagged.h:724
escript::DataTagged::FloatBatchType
std::vector< DataTypes::RealVectorType::ElementType > FloatBatchType
Definition: DataTagged.h:53
escript::DataTagged::parent
DataReady parent
Definition: DataTagged.h:47
escript::DataTagged::DataMapType
std::map< int, int > DataMapType
Definition: DataTagged.h:58
escript::DataTagged::getDataByTagRW
DataTypes::CplxVectorType::reference getDataByTagRW(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
escript::DataTagged::m_defaultValueOffset
static const int m_defaultValueOffset
Definition: DataTagged.h:705
escript::DataTagged::getLength
virtual DataTypes::RealVectorType::size_type getLength() const
getLength
Definition: DataTagged.h:769
escript::DataTagged::m_data_c
DataTypes::CplxVectorType m_data_c
Definition: DataTagged.h:709
escript::DataTagged::getDefaultValueRW
DataTypes::CplxVectorType::reference getDefaultValueRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
escript::DataTagged::TagListType
std::vector< int > TagListType
Definition: DataTagged.h:52
escript::DataTagged::m_data_r
DataTypes::RealVectorType m_data_r
Definition: DataTagged.h:708
escript::DataTagged::getDefaultValueRW
DataTypes::RealVectorType::reference getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0)
getDefaultValue
Definition: DataTagged.h:731
escript::DataTagged::getTagLookup
const DataMapType & getTagLookup() const
getTagLookup
Definition: DataTagged.h:762
escript::DataTagged::getVectorROC
const DataTypes::CplxVectorType & getVectorROC() const
Definition: DataTagged.cpp:1663
escript::DataTagged::getVectorRW
DataTypes::RealVectorType & getVectorRW()
Return a reference to the underlying DataVector.
Definition: DataTagged.cpp:1643
escript::DataTagged::getVectorRO
const DataTypes::RealVectorType & getVectorRO() const
Definition: DataTagged.cpp:1650
escript::DataTagged::getVectorRWC
DataTypes::CplxVectorType & getVectorRWC()
Definition: DataTagged.cpp:1656
escript::DataTypes::DataVectorAlt< real_t >
escript::DataTypes::DataVectorAlt::size
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:215
escript::DataTypes::DataVectorAlt< real_t >::const_reference
const ElementType & const_reference
Definition: DataVectorAlt.h:52
escript::DataTypes::DataVectorAlt< real_t >::reference
ElementType & reference
Definition: DataVectorAlt.h:51
escript::DataTypes::DataVectorAlt::size_type
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:50
escript::FunctionSpace
Definition: FunctionSpace.h:36
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:55
escript::DataTypes::RegionType
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:45
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:52
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:44
escript
Definition: AbstractContinuousDomain.cpp:23
escript::eigenvalues_and_eigenvectors
void eigenvalues_and_eigenvectors(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::RealVectorType::size_type evOffset, DataTypes::RealVectorType &V, const DataTypes::ShapeType &VShape, DataTypes::RealVectorType::size_type VOffset, const double tol=1.e-13)
solves a local eigenvalue problem
Definition: DataVectorOps.h:750
escript::eigenvalues
void eigenvalues(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::RealVectorType::size_type evOffset)
solves a local eigenvalue problem
Definition: DataVectorOps.h:639
escript::symmetric
void symmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
Definition: DataVectorOps.h:103
escript::swapaxes
void swapaxes(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis0, int axis1)
swaps the components axis0 and axis1.
Definition: DataVectorOps.h:488
escript::transpose
void transpose(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition: DataVectorOps.h:343
escript::antisymmetric
void antisymmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a antisymmetric matrix from your square matrix A: (A - transpose(A)) / 2
Definition: DataVectorOps.h:152
escript::antihermitian
void antihermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::CplxVectorType::size_type evOffset)
computes a antihermitian matrix from your square matrix A: (A - adjoint(A)) / 2
Definition: DataVectorOps.cpp:963
escript::trace
void trace(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
computes the trace of a matrix
Definition: DataVectorOps.h:242
escript::hermitian
void hermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::CplxVectorType::size_type evOffset)
computes an hermitian matrix from your square matrix A: (A + adjoint(A)) / 2
Definition: DataVectorOps.cpp:916
system_dep.h