escript  Revision_4925
DataExpanded.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
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 
161  virtual
162  std::string
163  toString() const;
164 
169  virtual
170  DataAbstract*
171  deepCopy();
172 
173 
179  virtual
180  void
181  dump(const std::string fileName) const;
182 
183 
190  virtual int
191  matrixInverse(DataAbstract* out) const;
192 
198  virtual
199  void
200  setToZero();
201 
212  virtual
214  getPointOffset(int sampleNo,
215  int dataPointNo) const;
216 
218  virtual
220  getPointOffset(int sampleNo,
221  int dataPointNo);
222 
230  getVectorRW();
231 
233  const DataTypes::ValueType&
234  getVectorRO() const;
235 
236 
237 
243  virtual
245  getLength() const;
246 
255  virtual
256  DataAbstract*
257  getSlice(const DataTypes::RegionType& region) const;
258 
267  virtual
268  void
269  setSlice(const DataAbstract* value,
270  const DataTypes::RegionType& region);
271 
284  void
285  setTaggedValue(int tagKey,
286  const DataTypes::ShapeType& pointshape,
287  const DataTypes::ValueType& value,
288  int dataOffset=0);
289 
290 
291 
300  virtual void
301  symmetric(DataAbstract* ev);
302 
311  virtual void
313 
323  virtual void
324  trace(DataAbstract* ev, int axis_offset);
325 
334  virtual void
335  transpose(DataAbstract* ev, int axis_offset);
336 
346  virtual void
347  swapaxes(DataAbstract* ev, int axis0, int axis1);
348 
349 
358  virtual void
360 
373  virtual void
374  eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
375 
383  virtual void
384  reorderByReferenceIDs(int *reference_ids);
385 
386 // /**
387 // \brief Fill the object with random values
388 //
389 // \param seed - random seed
390 // */
391 // ESCRIPT_DLL_API
392 // void randomFill(long seed);
393 
394  protected:
395 
396  private:
397 
412  void
413  initialise(int noSamples,
414  int noDataPointsPerSample);
415 
425  void
426  copy(const DataConstant& value);
427 
428 
429 
437  void
438  copy(const WrappedArray& value);
439 
440 
453  virtual void
454  copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
455 
456 
466  virtual void
467  copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
468 
469  //
470  // The main data storage array, a 2D array of data blocks.
471  // noSamples * noDataPointsPerSample
473 
474 };
475 
476 } // end of namespace
477 
478 #endif
virtual void swapaxes(DataAbstract *ev, int axis0, int axis1)
swaps components axis0 and axis1
Definition: DataExpanded.cpp:529
virtual void nonsymmetric(DataAbstract *ev)
Computes a nonsymmetric matrix (A - AT) / 2.
Definition: DataExpanded.cpp:461
Give a short description of what FunctionSpace does.
Definition: FunctionSpace.h:46
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:339
virtual void symmetric(DataAbstract *ev)
Computes a symmetric matrix (A + AT) / 2.
Definition: DataExpanded.cpp:439
DataReady parent
Definition: DataExpanded.h:46
virtual void reorderByReferenceIDs(int *reference_ids)
reorders data sample ordered by reference_ids to the ordering of the functions space ...
Definition: DataExpanded.cpp:784
const DataTypes::ValueType & getVectorRO() const
Definition: DataExpanded.cpp:829
virtual int matrixInverse(DataAbstract *out) const
invert square matricies
Definition: DataExpanded.cpp:604
virtual void setToZero()
sets all values to zero
Definition: DataExpanded.cpp:646
Definition: DataReady.h:35
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:39
virtual void trace(DataAbstract *ev, int axis_offset)
Computes the trace of a matrix.
Definition: DataExpanded.cpp:483
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:203
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:48
virtual void eigenvalues(DataAbstract *ev)
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
Definition: DataExpanded.cpp:551
Give a short description of what DataExpanded does.
Definition: DataExpanded.h:44
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:43
virtual void transpose(DataAbstract *ev, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition: DataExpanded.cpp:506
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:253
virtual void dump(const std::string fileName) const
dumps the object into a netCDF file
Definition: DataExpanded.cpp:666
void setTaggedValue(int tagKey, const DataTypes::ShapeType &pointshape, const DataTypes::ValueType &value, int dataOffset=0)
setTaggedValue
Definition: DataExpanded.cpp:754
bool isExpanded() const
Definition: DataExpanded.h:137
DataBlocks2D m_data
Definition: DataExpanded.h:472
virtual ValueType::size_type getLength() const
Return the number of doubles stored for the Data.
Definition: DataExpanded.cpp:353
void initialise(int noSamples, int noDataPointsPerSample)
Fill the object with random values.
Definition: DataExpanded.cpp:285
#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:822
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:64
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:573
virtual std::string toString() const
Return a textual representation of the data.
Definition: DataExpanded.cpp:313
Definition: DataAbstract.h:61
bool hasNaN() const
Return true if any value in the data contains a NaN.
Definition: DataExpanded.cpp:298
long size_type
Definition: DataVector.h:60
virtual ~DataExpanded()
Default destructor for DataExpanded.
Definition: DataExpanded.cpp:191
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:361
virtual DataAbstract * deepCopy()
Return a deep copy of the current object.
Definition: DataExpanded.cpp:196
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:209