escript  Revision_
DataVectorTaipan.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 
19 #if !defined escript_DataVectorTaipan_H
20 #define escript_DataVectorTaipan_H
21 #include "system_dep.h"
22 
23 #include "Assert.h"
24 #include "DataTypes.h"
25 #include "WrappedArray.h"
26 
27 namespace escript
28 {
29 
30 namespace DataTypes
31 {
32 
45 class ESCRIPT_DLL_API DataVectorTaipan {
46 
47  public:
48 
49  //
50  // The type of the elements stored in the vector.
51  typedef double ElementType;
52 
53  //
54  // The underlying type used to implement the vector.
55  typedef ElementType * VectorStorageType;
56 
57 
58  //
59  // Various types exported to clients of this class.
60  typedef const ElementType * const_pointer;
61  typedef ElementType value_type;
62  typedef long size_type;
63  typedef ElementType & reference;
64  typedef const ElementType & const_reference;
65 
73  DataVectorTaipan();
74 
83  DataVectorTaipan(const DataVectorTaipan& other);
84 
103  DataVectorTaipan(const size_type size,
104  const value_type val=0.0,
105  const size_type blockSize=1);
106 
114  ~DataVectorTaipan();
115 
126  void
127  resize(const size_type newSize,
128  const value_type newVal=0.0,
129  const size_type newBlockSize=1);
130 
137  void
138  copyFromArray(const escript::WrappedArray& value, size_type copies);
139 
140  void
141  copyFromArrayToOffset(const escript::WrappedArray& value, size_type offset, size_type copies);
142 
143 
148  inline
149  size_type
150  size() const;
151 
157  DataVectorTaipan&
158  operator=(const DataVectorTaipan& other);
159 
165  bool
166  operator==(const DataVectorTaipan& other) const;
167 
173  bool
174  operator!=(const DataVectorTaipan& other) const;
175 
184  inline
185  reference
186  operator[](const size_type i);
187 
188  inline
189  const_reference
190  operator[](const size_type i) const;
191 
192 
193  protected:
194 
195  private:
196 
197  size_type m_size;
198  size_type m_dim;
199  size_type m_N;
200 
201  //
202  // The container for the elements contained in this DataVectorTaipan.
203  VectorStorageType m_array_data;
204 };
205 
206 
213 
214 
215 
216 inline
219 {
220  return m_size;
221 }
222 
223 inline
226 {
227  ESYS_ASSERT(i<size(), "DataVectorTaipan: invalid index specified. " << i << " of " << size());
228  return m_array_data[i];
229 }
230 
231 inline
234 {
235  ESYS_ASSERT(i<size(),"DataVectorTaipan: invalid index specified. " << i << " of " << size());
236  return m_array_data[i];
237 }
238 
239 
240 } // end of namespace
241 } // end of namespace
242 
243 
244 
245 #endif
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
escript::DataTypes::DataVectorTaipan::DataVectorTaipan
DataVectorTaipan()
Default constructor for DataVectorTaipan.
Definition: DataVectorTaipan.cpp:46
escript::WrappedArray::getElt
DataTypes::real_t getElt() const
Definition: WrappedArray.h:88
escript::DataTypes::DataVectorTaipan::operator==
bool operator==(const DataVectorTaipan &other) const
DataVectorTaipan equality comparison operator "==". Return true if the given DataVectorTaipan is equa...
Definition: DataVectorTaipan.cpp:157
escript::DataTypes::DataVectorTaipan::size
size_type size() const
Return the number of elements in this DataVectorTaipan.
Definition: DataVectorTaipan.h:243
escript::DataTypes::DataVectorTaipan::m_N
size_type m_N
Definition: DataVectorTaipan.h:237
escript::DataTypes::DataVectorTaipan::m_dim
size_type m_dim
Definition: DataVectorTaipan.h:236
escript::DataTypes::DataVectorTaipan
DataVectorTaipan implements an arbitrarily long vector of data values. DataVectorTaipan is the underl...
Definition: DataVectorTaipan.h:70
escript::WrappedArray
Definition: WrappedArray.h:31
escript::DataTypes::DataVectorTaipan::~DataVectorTaipan
~DataVectorTaipan()
Default destructor for DataVectorTaipan.
Definition: DataVectorTaipan.cpp:78
Assert.h
escript::DataTypes::DataVectorTaipan::m_size
size_type m_size
Definition: DataVectorTaipan.h:235
system_dep.h
escript::WrappedArray::getRank
unsigned int getRank() const
Definition: WrappedArray.h:76
escript::DataTypes::DataVectorTaipan::operator=
DataVectorTaipan & operator=(const DataVectorTaipan &other)
DataVectorTaipan assignment operator "=". Assign the given DataVectorTaipan object to this.
Definition: DataVectorTaipan.cpp:134
escript::DataException
Definition: DataException.h:39
escript::DataTypes::DataVectorTaipan::m_array_data
VectorStorageType m_array_data
Definition: DataVectorTaipan.h:241
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:68
escript::DataTypes::DataVectorTaipan::resize
void resize(const size_type newSize, const value_type newVal=0.0, const size_type newBlockSize=1)
Resize the DataVectorTaipan to the given length "newSize". All current data is lost....
Definition: DataVectorTaipan.cpp:93
escript::DataTypes::noValues
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:90
escript::Taipan
Taipan array manager, C++ version. Based on TaipanMemManager C module by Lutz Gross.
Definition: Taipan.h:56
escript::DataTypes::DataVectorTaipan::size_type
long size_type
Definition: DataVectorTaipan.h:100
Taipan.h
escript::DataTypes::arrayManager
Taipan arrayManager
Definition: DataVectorTaipan.cpp:38
WrappedArray.h
escript::DataTypes::DataVectorTaipan::copyFromArray
void copyFromArray(const escript::WrappedArray &value, size_type copies)
Populates the vector with the data from value. This method currently throws an exception if the speci...
Definition: DataVectorTaipan.cpp:282
escript::DataTypes::RealVectorType
escript::DataTypes::DataVectorAlt< real_t > RealVectorType
Vector to store underlying data.
Definition: DataVector.h:43
escript::DataTypes::releaseUnusedMemory
void releaseUnusedMemory()
releases unused memory in the memory manager.
Definition: DataVectorTaipan.cpp:40
escript::Taipan::new_array
double * new_array(size_type dim, size_type N)
Taipan data-array allocator.
Definition: Taipan.cpp:104
escript::DataTypes::DataVectorTaipan::operator!=
bool operator!=(const DataVectorTaipan &other) const
DataVectorTaipan inequality comparison operator "!=". Return true if the given DataVectorTaipan is no...
Definition: DataVectorTaipan.cpp:179
escript::Taipan::delete_array
void delete_array(double *array)
Taipan data-array deallocator.
Definition: Taipan.cpp:191
escript::DataTypes::DataVectorTaipan::operator[]
reference operator[](const size_type i)
Return a reference to the element at position i in this DataVectorTaipan. Will throw an exception if ...
Definition: DataVectorTaipan.h:250
escript
Definition: AbstractContinuousDomain.cpp:23
DataVector.h
escript::DataTypes::DataVectorTaipan::const_reference
const typedef ElementType & const_reference
Definition: DataVectorTaipan.h:102
escript::DataTypes::getRelIndex
vec_size_type getRelIndex(const DataTypes::ShapeType &shape, vec_size_type i)
Compute the offset (in 1D vector) of a given subscript with a shape.
Definition: DataTypes.h:259
DataTypes.h
escript::DataTypes::DataVectorTaipan::value_type
ElementType value_type
Definition: DataVectorTaipan.h:99
escript::DataTypes::DataVectorTaipan::reference
ElementType & reference
Definition: DataVectorTaipan.h:101
escript::DataTypes::DataVectorTaipan::copyFromArrayToOffset
void copyFromArrayToOffset(const escript::WrappedArray &value, size_type offset, size_type copies)
Definition: DataVectorTaipan.cpp:185
escript::WrappedArray::getShape
const DataTypes::ShapeType & getShape() const
Definition: WrappedArray.h:82
ESYS_ASSERT
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false.
Definition: Assert.h:78
escript::Taipan::release_unused_arrays
void release_unused_arrays()
frees all arrays that are currently unused.
Definition: Taipan.cpp:73
DataException.h