00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #if !defined escript_DataVector_20050324_H
00016 #define escript_DataVector_20050324_H
00017 #include "system_dep.h"
00018
00019 #include "esysUtils/EsysAssert.h"
00020
00021 #include <vector>
00022 #include <iostream>
00023 #include <fstream>
00024 #include <boost/python/numeric.hpp>
00025
00026 namespace escript {
00027
00028 class WrappedArray;
00029
00042 class ESCRIPT_DLL_API DataVector {
00043
00044 public:
00045
00046
00047
00048 typedef double ElementType;
00049
00050
00051
00052 typedef ElementType * ValueType;
00053
00054
00055
00056 typedef ElementType value_type;
00057 typedef long size_type;
00058 typedef ElementType & reference;
00059 typedef const ElementType & const_reference;
00060
00068 DataVector();
00069
00078 DataVector(const DataVector& other);
00079
00098 DataVector(const size_type size,
00099 const value_type val=0.0,
00100 const size_type blockSize=1);
00101
00109 ~DataVector();
00110
00121 void
00122 resize(const size_type newSize,
00123 const value_type newVal=0.0,
00124 const size_type newBlockSize=1);
00125
00132 void
00133 copyFromArray(const escript::WrappedArray& value, size_type copies);
00134
00135 void
00136 copyFromArrayToOffset(const WrappedArray& value, size_type offset, size_type copies);
00137
00138
00143 inline
00144 size_type
00145 size() const;
00146
00152 DataVector&
00153 operator=(const DataVector& other);
00154
00160 bool
00161 operator==(const DataVector& other) const;
00162
00168 bool
00169 operator!=(const DataVector& other) const;
00170
00179 inline
00180 reference
00181 operator[](const size_type i);
00182
00183 inline
00184 const_reference
00185 operator[](const size_type i) const;
00186
00187
00188 protected:
00189
00190 private:
00191
00192 size_type m_size;
00193 size_type m_dim;
00194 size_type m_N;
00195
00196
00197
00198 ValueType m_array_data;
00199 };
00200
00206 ESCRIPT_DLL_API void releaseUnusedMemory();
00207
00208
00209
00210 inline
00211 DataVector::size_type
00212 DataVector::size() const
00213 {
00214 return m_size;
00215 }
00216
00217 inline
00218 DataVector::reference
00219 DataVector::operator[](const DataVector::size_type i)
00220 {
00221 EsysAssert(i<size(),"DataVector: invalid index specified. " << i << " of " << size());
00222 return m_array_data[i];
00223 }
00224
00225 inline
00226 DataVector::const_reference
00227 DataVector::operator[](const DataVector::size_type i) const
00228 {
00229 EsysAssert(i<size(),"DataVector: invalid index specified. " << i << " of " << size());
00230 return m_array_data[i];
00231 }
00232
00233 }
00234
00235 #endif