escript  Revision_Unversioneddirectory
DataExpanded.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 #if !defined escript_DataExpanded_20040323_H
19 #define escript_DataExpanded_20040323_H
20 #include "system_dep.h"
21 
22 #include "DataReady.h"
23 #include "DataBlocks2D.h"
24 
25 namespace escript {
26 
27 //
28 // Forward declarations of other Data types.
29 class DataConstant;
30 class DataTagged;
31 
44 class DataExpanded : public DataReady {
45 
46 typedef DataReady parent;
47 
48  public:
49 
65  DataExpanded(const WrappedArray& value,
66  const FunctionSpace& what);
67 
77  DataExpanded(const DataExpanded& other,
78  const DataTypes::RegionType& region);
79 
93  DataExpanded(const FunctionSpace& what,
94  const DataTypes::ShapeType &shape,
95  const DataTypes::ValueType &data);
96 
97 
99  DataExpanded(const FunctionSpace& what,
100  const DataTypes::ShapeType &shape,
101  const double data);
102 
109  DataExpanded(const DataExpanded& other);
110 
117  DataExpanded(const DataConstant& other);
118 
125  DataExpanded(const DataTagged& other);
126 
132  virtual
133  ~DataExpanded();
134 
136  bool
137  isExpanded() const
138  {
139  return true;
140  };
141 
143  bool
144  actsExpanded() const
145  {
146  return true;
147  }
148 
153  bool
154  hasNaN() const;
155 
160  void
161  replaceNaN(double value);
162 
168  virtual
169  std::string
170  toString() const;
171 
176  virtual
177  DataAbstract*
178  deepCopy();
179 
180 
186  virtual
187  void
188  dump(const std::string fileName) const;
189 
190 
197  virtual int
198  matrixInverse(DataAbstract* out) const;
199 
205  virtual
206  void
207  setToZero();
208 
219  virtual
221  getPointOffset(int sampleNo,
222  int dataPointNo) const;
223 
225  virtual
227  getPointOffset(int sampleNo,
228  int dataPointNo);
229 
237  getVectorRW();
238 
240  const DataTypes::ValueType&
241  getVectorRO() const;
242 
243 
244 
250  virtual
252  getLength() const;
253 
262  virtual
263  DataAbstract*
264  getSlice(const DataTypes::RegionType& region) const;
265 
274  virtual
275  void
276  setSlice(const DataAbstract* value,
277  const DataTypes::RegionType& region);
278 
291  void
292  setTaggedValue(int tagKey,
293  const DataTypes::ShapeType& pointshape,
294  const DataTypes::ValueType& value,
295  int dataOffset=0);
296 
297 
298 
307  virtual void
308  symmetric(DataAbstract* ev);
309 
318  virtual void
320 
330  virtual void
331  trace(DataAbstract* ev, int axis_offset);
332 
341  virtual void
342  transpose(DataAbstract* ev, int axis_offset);
343 
353  virtual void
354  swapaxes(DataAbstract* ev, int axis0, int axis1);
355 
356 
365  virtual void
367 
380  virtual void
381  eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
382 
390  virtual void
391  reorderByReferenceIDs(dim_t *reference_ids);
392 
393  protected:
394 
395  private:
396 
411  void
412  initialise(int noSamples,
413  int noDataPointsPerSample);
414 
424  void
425  copy(const DataConstant& value);
426 
427 
428 
436  void
437  copy(const WrappedArray& value);
438 
439 
452  virtual void
453  copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
454 
455 
465  virtual void
466  copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
467 
468  //
469  // The main data storage array, a 2D array of data blocks.
470  // noSamples * noDataPointsPerSample
472 
473 };
474 
475 } // end of namespace
476 
477 #endif
virtual void swapaxes(DataAbstract *ev, int axis0, int axis1)
swaps components axis0 and axis1
Definition: DataExpanded.cpp:485
virtual void nonsymmetric(DataAbstract *ev)
Computes a nonsymmetric matrix (A - AT) / 2.
Definition: DataExpanded.cpp:419
Definition: FunctionSpace.h:34
DataVector implements an arbitrarily long vector of data values. DataVector is the underlying data co...
Definition: DataVector.h:44
virtual DataTypes::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const
Return the offset for the given given data point. This returns the offset in bytes for the given poin...
Definition: DataExpanded.cpp:305
virtual void symmetric(DataAbstract *ev)
Computes a symmetric matrix (A + AT) / 2.
Definition: DataExpanded.cpp:397
DataReady parent
Definition: DataExpanded.h:46
const DataTypes::ValueType & getVectorRO() const
Definition: DataExpanded.cpp:755
virtual int matrixInverse(DataAbstract *out) const
invert square matricies
Definition: DataExpanded.cpp:560
virtual void setToZero()
sets all values to zero
Definition: DataExpanded.cpp:598
Definition: DataReady.h:35
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:39
Definition: AbstractContinuousDomain.cpp:24
virtual void trace(DataAbstract *ev, int axis_offset)
Computes the trace of a matrix.
Definition: DataExpanded.cpp:441
virtual DataAbstract * getSlice(const DataTypes::RegionType &region) const
Factory method that returns a newly created DataExpanded. The caller is reponsible for managing the o...
Definition: DataExpanded.cpp:173
DataConstant stores a single data point which represents the entire function space.
Definition: DataConstant.h:37
DataExpanded(const WrappedArray &value, const FunctionSpace &what)
Constructor for DataExpanded.
Definition: DataExpanded.cpp:49
virtual void eigenvalues(DataAbstract *ev)
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
Definition: DataExpanded.cpp:507
Give a short description of what DataExpanded does.
Definition: DataExpanded.h:44
void replaceNaN(double value)
replaces all NaN values with value
Definition: DataExpanded.cpp:269
virtual void reorderByReferenceIDs(dim_t *reference_ids)
reorders data sample ordered by reference_ids to the ordering of the functions space ...
Definition: DataExpanded.cpp:716
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:38
Simulates a full dataset accessible via sampleNo and dataPointNo.
Definition: DataTagged.h:44
virtual void transpose(DataAbstract *ev, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition: DataExpanded.cpp:463
bool actsExpanded() const
Return true if this Data is expanded or resolves to expanded. That is, if it has a separate value for...
Definition: DataExpanded.h:144
void copy(const DataConstant &value)
Copy the given data point value to all data points in this object.
Definition: DataExpanded.cpp:217
virtual void dump(const std::string fileName) const
dumps the object into a netCDF file
Definition: DataExpanded.cpp:617
void setTaggedValue(int tagKey, const DataTypes::ShapeType &pointshape, const DataTypes::ValueType &value, int dataOffset=0)
setTaggedValue
Definition: DataExpanded.cpp:689
bool isExpanded() const
Definition: DataExpanded.h:137
DataBlocks2D m_data
Definition: DataExpanded.h:471
virtual ValueType::size_type getLength() const
Return the number of doubles stored for the Data.
Definition: DataExpanded.cpp:317
void initialise(int noSamples, int noDataPointsPerSample)
Common initialisation called from constructors.
Definition: DataExpanded.cpp:244
#define V(_K_, _I_)
Definition: ShapeFunctions.cpp:120
DataBlocks2D manages a 2D array of multi-dimensional data points.
Definition: DataBlocks2D.h:38
DataTypes::ValueType & getVectorRW()
Return a a reference to the underlying DataVector.
Definition: DataExpanded.cpp:749
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:54
virtual void eigenvalues_and_eigenvectors(DataAbstract *ev, DataAbstract *V, const double tol=1.e-13)
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V ...
Definition: DataExpanded.cpp:529
index_t dim_t
Definition: types.h:27
virtual std::string toString() const
Return a textual representation of the data.
Definition: DataExpanded.cpp:279
Definition: DataAbstract.h:61
bool hasNaN() const
Return true if any value in the data contains a NaN.
Definition: DataExpanded.cpp:253
long size_type
Definition: DataVector.h:60
virtual ~DataExpanded()
Default destructor for DataExpanded.
Definition: DataExpanded.cpp:164
virtual void copyToDataPoint(const int sampleNo, const int dataPointNo, const double value)
Copy a double value to the data point dataPointNo of sample sampleNo in this object.
Definition: DataExpanded.cpp:322
virtual DataAbstract * deepCopy()
Return a deep copy of the current object.
Definition: DataExpanded.cpp:168
Definition: WrappedArray.h:29
virtual void setSlice(const DataAbstract *value, const DataTypes::RegionType &region)
Copy the specified region from the given value.
Definition: DataExpanded.cpp:178