/[escript]/trunk/escript/src/DataExpanded.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataExpanded.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1748 by ksteube, Wed Sep 3 06:10:39 2008 UTC revision 1796 by jfenwick, Wed Sep 17 01:45:46 2008 UTC
# Line 25  Line 25 
25  #endif  #endif
26    
27  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
28    #include "DataMaths.h"
29    
30  using namespace std;  using namespace std;
31  using namespace boost::python;  using namespace boost::python;
32  using namespace boost;  using namespace boost;
33    using namespace escript::DataTypes;
34    
35  namespace escript {  namespace escript {
36    
37  DataExpanded::DataExpanded(const boost::python::numeric::array& value,  DataExpanded::DataExpanded(const boost::python::numeric::array& value,
38                             const FunctionSpace& what)                             const FunctionSpace& what)
39    : DataAbstract(what)    : DataAbstract(what,DataTypes::shapeFromNumArray(value))
40  {  {
41    DataArrayView::ShapeType tempShape;  /*  DataTypes::ShapeType tempShape;
42    //    //
43    // extract the shape of the python numarray    // extract the shape of the python numarray
44    for (int i=0; i<value.getrank(); i++) {    for (int i=0; i<value.getrank(); i++) {
45      tempShape.push_back(extract<int>(value.getshape()[i]));      tempShape.push_back(extract<int>(value.getshape()[i]));
46    }    }*/
47    //    //
48    // initialise the data array for this object    // initialise the data array for this object
49    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());    initialise(what.getNumSamples(),what.getNumDPPSample());
50    //    //
51    // copy the given value to every data point    // copy the given value to every data point
52    copy(value);    copy(value);
53  }  }
54    
55  DataExpanded::DataExpanded(const DataExpanded& other)  DataExpanded::DataExpanded(const DataExpanded& other)
56    : DataAbstract(other.getFunctionSpace()),    : DataAbstract(other.getFunctionSpace(), other.getShape()),
57    m_data(other.m_data)    m_data(other.m_data)
58  {  {
59    /*
60    //    //
61    // create the view for the data    // create the view for the data
62    DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());    DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());
63    setPointDataView(temp);    setPointDataView(temp);
64    
65      // keep local shape in sync
66      setShape(other.getPointDataView().getShape());*/
67  }  }
68    
69  DataExpanded::DataExpanded(const DataConstant& other)  DataExpanded::DataExpanded(const DataConstant& other)
70    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace(), other.getShape())
71  {  {
72    //    //
73    // initialise the data array for this object    // initialise the data array for this object
74    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());    initialise(other.getNumSamples(),other.getNumDPPSample());
75    //    //
76    // DataConstant only has one value, copy this to every data point    // DataConstant only has one value, copy this to every data point
77    copy(other.getPointDataView());    copy(other);
78  }  }
79    
80  DataExpanded::DataExpanded(const DataTagged& other)  DataExpanded::DataExpanded(const DataTagged& other)
81    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace(), other.getShape())
82  {  {
83    //    //
84    // initialise the data array for this object    // initialise the data array for this object
85    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());    initialise(other.getNumSamples(),other.getNumDPPSample());
86    //    //
87    // for each data point in this object, extract and copy the corresponding data    // for each data point in this object, extract and copy the corresponding data
88    // value from the given DataTagged object    // value from the given DataTagged object
89    int i,j;    int i,j;
90    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataTypes::ValueType::size_type numRows=m_data.getNumRows();
91    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataTypes::ValueType::size_type numCols=m_data.getNumCols();
92    #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
93    for (i=0;i<numRows;i++) {    for (i=0;i<numRows;i++) {
94      for (j=0;j<numCols;j++) {      for (j=0;j<numCols;j++) {
95        try {        try {
96          getPointDataView().copy(getPointOffset(i,j),  //         getPointDataView().copy(getPointOffset(i,j),
97                                  other.getPointDataView(),  //                                 other.getPointDataView(),
98    //                                 other.getPointOffset(i,j));
99               DataTypes::copyPoint(getVector(), getPointOffset(i,j), getNoValues(),
100                                    other.getVector(),
101                                  other.getPointOffset(i,j));                                  other.getPointOffset(i,j));
102        }        }
103        catch (std::exception& e) {        catch (std::exception& e) {
# Line 99  DataExpanded::DataExpanded(const DataTag Line 108  DataExpanded::DataExpanded(const DataTag
108  }  }
109    
110  DataExpanded::DataExpanded(const DataExpanded& other,  DataExpanded::DataExpanded(const DataExpanded& other,
111                             const DataArrayView::RegionType& region)                             const DataTypes::RegionType& region)
112    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace(),DataTypes::getResultSliceShape(region))
113  {  {
114    //    //
115    // get the shape of the slice    // get the shape of the slice
116    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));  //   DataTypes::ShapeType shape(DataTypes::getResultSliceShape(region));
117    //    //
118    // initialise this Data object to the shape of the slice    // initialise this Data object to the shape of the slice
119    initialise(shape,other.getNumSamples(),other.getNumDPPSample());    initialise(other.getNumSamples(),other.getNumDPPSample());
120    //    //
121    // copy the data    // copy the data
122    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);    DataTypes::RegionLoopRangeType region_loop_range=DataTypes::getSliceRegionLoopRange(region);
123    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataTypes::ValueType::size_type numRows=m_data.getNumRows();
124    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataTypes::ValueType::size_type numCols=m_data.getNumCols();
125    int i,j;    int i,j;
126    #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
127    for (i=0;i<numRows;i++) {    for (i=0;i<numRows;i++) {
128      for (j=0;j<numCols;j++) {      for (j=0;j<numCols;j++) {
129        try {        try {
130          getPointDataView().copySlice(getPointOffset(i,j),  //         getPointDataView().copySlice(getPointOffset(i,j),
131                                       other.getPointDataView(),  //                                      other.getPointDataView(),
132    //                                      other.getPointOffset(i,j),
133    //                                      region_loop_range);
134            DataTypes::copySlice(getVector(),getShape(),getPointOffset(i,j),
135                                         other.getVector(),
136                         other.getShape(),
137                                       other.getPointOffset(i,j),                                       other.getPointOffset(i,j),
138                                       region_loop_range);                                       region_loop_range);
139        }        }
# Line 130  DataExpanded::DataExpanded(const DataExp Line 144  DataExpanded::DataExpanded(const DataExp
144    }    }
145  }  }
146    
147  DataExpanded::DataExpanded(const DataArrayView& value,  // DataExpanded::DataExpanded(const DataArrayView& value,
148                             const FunctionSpace& what)  //                            const FunctionSpace& what)
149    : DataAbstract(what)  //   : DataAbstract(what)
150  {  // {
151    //  //   //
152    // get the shape of the given data value  //   // get the shape of the given data value
153    DataArrayView::ShapeType tempShape=value.getShape();  //   DataTypes::ShapeType tempShape=value.getShape();
154    //  //   //
155    // initialise this Data object to the shape of the given data value  //   // initialise this Data object to the shape of the given data value
156    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());  //   initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());
157    //  //   //
158    // copy the given value to every data point  //   // copy the given value to every data point
159    copy(value);  //   copy(value);
160  }  // }
161    
162  DataExpanded::DataExpanded(const FunctionSpace& what,  DataExpanded::DataExpanded(const FunctionSpace& what,
163                             const DataArrayView::ShapeType &shape,                             const DataTypes::ShapeType &shape,
164                             const DataArrayView::ValueType &data)                             const DataTypes::ValueType &data)
165    : DataAbstract(what)    : DataAbstract(what,shape)
166  {  {
167    //    EsysAssert(data.size()%getNoValues()==0,
168    // create the view of the data                   "DataExpanded Constructor - size of supplied data is not a multiple of shape size.");
169    initialise(shape,what.getNumSamples(),what.getNumDPPSample());  
170    //    if (data.size()==getNoValues())
171    // copy the data in the correct format    {
172    m_data.getData()=data;       ValueType& vec=m_data.getData();
173         //
174         // create the view of the data
175         initialise(what.getNumSamples(),what.getNumDPPSample());
176         // now we copy this value to all elements
177         for (int i=0;i<getLength();)
178         {
179        for (int j=0;j<getNoValues();++j,++i)
180        {
181            vec[i]=data[j];
182        }
183         }
184      }
185      else
186      {
187         //
188         // copy the data in the correct format
189         m_data.getData()=data;
190      }
191    
192    
193  }  }
194    
195  DataExpanded::~DataExpanded()  DataExpanded::~DataExpanded()
# Line 163  DataExpanded::~DataExpanded() Line 197  DataExpanded::~DataExpanded()
197  }  }
198    
199  DataAbstract*  DataAbstract*
200  DataExpanded::getSlice(const DataArrayView::RegionType& region) const  DataExpanded::getSlice(const DataTypes::RegionType& region) const
201  {  {
202    return new DataExpanded(*this,region);    return new DataExpanded(*this,region);
203  }  }
204    
205  void  void
206  DataExpanded::setSlice(const DataAbstract* value,  DataExpanded::setSlice(const DataAbstract* value,
207                         const DataArrayView::RegionType& region)                         const DataTypes::RegionType& region)
208  {  {
209    const DataExpanded* tempDataExp=dynamic_cast<const DataExpanded*>(value);    const DataExpanded* tempDataExp=dynamic_cast<const DataExpanded*>(value);
210    if (tempDataExp==0) {    if (tempDataExp==0) {
# Line 178  DataExpanded::setSlice(const DataAbstrac Line 212  DataExpanded::setSlice(const DataAbstrac
212    }    }
213    //    //
214    // get shape of slice    // get shape of slice
215    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));    DataTypes::ShapeType shape(DataTypes::getResultSliceShape(region));
216    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);    DataTypes::RegionLoopRangeType region_loop_range=DataTypes::getSliceRegionLoopRange(region);
217    //    //
218    // check shape    // check shape
219    if (getPointDataView().getRank()!=region.size()) {    if (getRank()!=region.size()) {
220      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
221    }    }
222    if (tempDataExp->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {    if (tempDataExp->getRank()>0 && !DataTypes::checkShape(value->getShape(), shape)) {
223      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (DataTypes::createShapeErrorMessage(
224          "Error - Couldn't copy slice due to shape mismatch.",shape));          "Error - Couldn't copy slice due to shape mismatch.",shape, value->getShape()));
225    }    }
226    //    //
227    // copy the data from the slice into this object    // copy the data from the slice into this object
228    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataTypes::ValueType::size_type numRows=m_data.getNumRows();
229    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataTypes::ValueType::size_type numCols=m_data.getNumCols();
230    int i, j;    int i, j;
231      ValueType& vec=getVector();
232      const ShapeType& mshape=getShape();
233      const ValueType& tVec=tempDataExp->getVector();
234      const ShapeType& tShape=tempDataExp->getShape();
235    #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
236    for (i=0;i<numRows;i++) {    for (i=0;i<numRows;i++) {
237      for (j=0;j<numCols;j++) {      for (j=0;j<numCols;j++) {
238        getPointDataView().copySliceFrom(getPointOffset(i,j),  /*      getPointDataView().copySliceFrom(getPointOffset(i,j),
239                                         tempDataExp->getPointDataView(),                                         tempDataExp->getPointDataView(),
240                                         tempDataExp->getPointOffset(i,j),                                         tempDataExp->getPointOffset(i,j),
241                                           region_loop_range);*/
242            DataTypes::copySliceFrom(vec,mshape,getPointOffset(i,j),
243                                           tVec,
244                           tShape,
245                                           tempDataExp->getPointOffset(i,j),
246                                         region_loop_range);                                         region_loop_range);
247    
248      }      }
249    }    }
250  }  }
251    
252  void  void
253  DataExpanded::copy(const DataArrayView& value)  DataExpanded::copy(const DataConstant& value)
254  {  {
255      EsysAssert((checkShape(getShape(), value.getShape())),
256                     createShapeErrorMessage("Error - Couldn't copy due to shape mismatch.",value.getShape(),getShape()));
257    
258    //    //
259    // copy a single value to every data point in this object    // copy a single value to every data point in this object
260    int nRows=m_data.getNumRows();    int nRows=m_data.getNumRows();
# Line 220  DataExpanded::copy(const DataArrayView& Line 267  DataExpanded::copy(const DataArrayView&
267        // DOASSERT is on which of course will play        // DOASSERT is on which of course will play
268        // havoc with the omp threads. Run single threaded        // havoc with the omp threads. Run single threaded
269        // if using DOASSERT.        // if using DOASSERT.
270        getPointDataView().copy(getPointOffset(i,j),value);        //getPointDataView().copy(getPointOffset(i,j),value);
271          DataTypes::copyPoint(getVector(), getPointOffset(i,j), getNoValues(), value.getVector(), 0);
272      }      }
273    }    }
274  }  }
275    
276    
277    // void
278    // DataExpanded::copy(const DataArrayView& value)
279    // {
280    //   //
281    //   // copy a single value to every data point in this object
282    //   int nRows=m_data.getNumRows();
283    //   int nCols=m_data.getNumCols();
284    //   int i,j;
285    //   #pragma omp parallel for private(i,j) schedule(static)
286    //   for (i=0;i<nRows;i++) {
287    //     for (j=0;j<nCols;j++) {
288    //       // NOTE: An exception may be thown from this call if
289    //       // DOASSERT is on which of course will play
290    //       // havoc with the omp threads. Run single threaded
291    //       // if using DOASSERT.
292    //       getPointDataView().copy(getPointOffset(i,j),value);
293    //     }
294    //   }
295    // }
296    
297  void  void
298  DataExpanded::copy(const boost::python::numeric::array& value)  DataExpanded::copy(const boost::python::numeric::array& value)
299  {  {
300    
301    // extract the shape of the numarray    // extract the shape of the numarray
302    DataArrayView::ShapeType tempShape;    DataTypes::ShapeType tempShape;
303    for (int i=0; i < value.getrank(); i++) {    for (int i=0; i < value.getrank(); i++) {
304      tempShape.push_back(extract<int>(value.getshape()[i]));      tempShape.push_back(extract<int>(value.getshape()[i]));
305    }    }
306    
307    // get the space for the data vector    // get the space for the data vector
308    int len = DataArrayView::noValues(tempShape);  //   int len = DataTypes::noValues(tempShape);
309    DataVector temp_data(len, 0.0, len);  //   DataVector temp_data(len, 0.0, len);
310    DataArrayView temp_dataView(temp_data, tempShape);  //   DataArrayView temp_dataView(temp_data, tempShape);
311    temp_dataView.copy(value);  //   temp_dataView.copy(value);
312    
313    //    //
314    // check the input shape matches this shape    // check the input shape matches this shape
315    if (!getPointDataView().checkShape(temp_dataView.getShape())) {    if (!DataTypes::checkShape(getShape(),tempShape)) {
316      throw DataException(getPointDataView().createShapeErrorMessage(      throw DataException(DataTypes::createShapeErrorMessage(
317                          "Error - (DataExpanded) Cannot copy due to shape mismatch.",                          "Error - (DataExpanded) Cannot copy due to shape mismatch.",
318                          temp_dataView.getShape()));                          tempShape,getShape()));
319    }    }
320    //    //
321    // now copy over the data    // now copy over the data
322    copy(temp_dataView);    //copy(temp_dataView);
323      getVector().copyFromNumArray(value);
324  }  }
325    
326    
327  void  void
328  DataExpanded::initialise(const DataArrayView::ShapeType& shape,  DataExpanded::initialise(int noSamples,
                          int noSamples,  
329                           int noDataPointsPerSample)                           int noDataPointsPerSample)
330  {  {
331    //    //
332    // resize data array to the required size    // resize data array to the required size
333    m_data.resize(noSamples,noDataPointsPerSample,DataArrayView::noValues(shape));    m_data.resize(noSamples,noDataPointsPerSample,getNoValues());
334    
335    //    //
336    // create the data view of the data array  //   // create the data view of the data array
337    DataArrayView temp(m_data.getData(),shape);  //   DataArrayView temp(m_data.getData(),shape);
338    setPointDataView(temp);  //   setPointDataView(temp);
339    
340    //   // keep shape in sync
341    //   setShape(shape);
342  }  }
343    
344  string  string
# Line 274  DataExpanded::toString() const Line 348  DataExpanded::toString() const
348    FunctionSpace fs=getFunctionSpace();    FunctionSpace fs=getFunctionSpace();
349    //    //
350    // create a temporary view as the offset will be changed    // create a temporary view as the offset will be changed
351    DataArrayView tempView(getPointDataView().getData(),getPointDataView().getShape(),getPointDataView().getOffset());  //  DataArrayView tempView(getPointDataView().getData(),getPointDataView().getShape(),getPointDataView().getOffset());
352    
353      int offset=0;
354    for (int i=0;i<m_data.getNumRows();i++) {    for (int i=0;i<m_data.getNumRows();i++) {
355      for (int j=0;j<m_data.getNumCols();j++) {      for (int j=0;j<m_data.getNumCols();j++) {
356        tempView.setOffset(getPointOffset(i,j));        offset=getPointOffset(i,j);
357        stringstream suffix;        stringstream suffix;
358        suffix << "( id: " << i << ", ref: " << fs.getReferenceIDOfSample(i) << ", pnt: " << j << ")";        suffix << "( id: " << i << ", ref: " << fs.getReferenceIDOfSample(i) << ", pnt: " << j << ")";
359        temp << tempView.toString(suffix.str());        temp << DataTypes::pointToString(getVector(),getShape(),offset,suffix.str());
360        if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {        if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {
361          temp << endl;          temp << endl;
362        }        }
# Line 289  DataExpanded::toString() const Line 365  DataExpanded::toString() const
365    return temp.str();    return temp.str();
366  }  }
367    
368  DataArrayView::ValueType::size_type  DataTypes::ValueType::size_type
369  DataExpanded::getPointOffset(int sampleNo,  DataExpanded::getPointOffset(int sampleNo,
370                               int dataPointNo) const                               int dataPointNo) const
371  {  {
372    return m_data.index(sampleNo,dataPointNo);    return m_data.index(sampleNo,dataPointNo);
373  }  }
374    
375  DataArrayView  // DataArrayView
376  DataExpanded::getDataPoint(int sampleNo,  // DataExpanded::getDataPoint(int sampleNo,
377                             int dataPointNo)  //                            int dataPointNo)
378  {  // {
379    DataArrayView temp(m_data.getData(),getPointDataView().getShape(),getPointOffset(sampleNo,dataPointNo));  //   DataArrayView temp(m_data.getData(),getPointDataView().getShape(),getPointOffset(sampleNo,dataPointNo));
380    return temp;  //   return temp;
381  }  // }
382    
383  DataArrayView::ValueType::size_type  DataTypes::ValueType::size_type
384  DataExpanded::getLength() const  DataExpanded::getLength() const
385  {  {
386    return m_data.size();    return m_data.size();
387  }  }
388    
 int  
 DataExpanded::archiveData(ofstream& archiveFile,  
                           const DataArrayView::ValueType::size_type noValues) const  
 {  
   return(m_data.archiveData(archiveFile, noValues));  
 }  
389    
 int  
 DataExpanded::extractData(ifstream& archiveFile,  
                           const DataArrayView::ValueType::size_type noValues)  
 {  
   return(m_data.extractData(archiveFile, noValues));  
 }  
390    
391  void  void
392  DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value) {  DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value) {
# Line 330  DataExpanded::copyToDataPoint(const int Line 394  DataExpanded::copyToDataPoint(const int
394    // Get the number of samples and data-points per sample.    // Get the number of samples and data-points per sample.
395    int numSamples = getNumSamples();    int numSamples = getNumSamples();
396    int numDataPointsPerSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
397    int dataPointRank = getPointDataView().getRank();    int dataPointRank = getRank();
398    ShapeType dataPointShape = getPointDataView().getShape();    ShapeType dataPointShape = getShape();
399    if (numSamples*numDataPointsPerSample > 0) {    if (numSamples*numDataPointsPerSample > 0) {
400       //TODO: global error handling       //TODO: global error handling
401       if ((sampleNo >= numSamples) || (sampleNo < 0 )) {       if ((sampleNo >= numSamples) || (sampleNo < 0 )) {
# Line 340  DataExpanded::copyToDataPoint(const int Line 404  DataExpanded::copyToDataPoint(const int
404       if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {       if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {
405             throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");             throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
406       }       }
407       DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);       ValueType::size_type offset = getPointOffset(sampleNo, dataPointNo);
408         ValueType& vec=getVector();
409       if (dataPointRank==0) {       if (dataPointRank==0) {
410           dataPointView()=value;           vec[0]=value;
411       } else if (dataPointRank==1) {       } else if (dataPointRank==1) {
412          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<dataPointShape[0]; i++) {
413              dataPointView(i)=value;              vec[offset+i]=value;
414          }          }
415       } else if (dataPointRank==2) {       } else if (dataPointRank==2) {
416          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<dataPointShape[0]; i++) {
417             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
418                dataPointView(i,j)=value;                vec[offset+getRelIndex(dataPointShape,i,j)]=value;
419             }             }
420          }          }
421       } else if (dataPointRank==3) {       } else if (dataPointRank==3) {
422          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<dataPointShape[0]; i++) {
423             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
424                for (int k=0; k<dataPointShape[2]; k++) {                for (int k=0; k<dataPointShape[2]; k++) {
425                   dataPointView(i,j,k)=value;                   vec[offset+getRelIndex(dataPointShape,i,j,k)]=value;
426                }                }
427             }             }
428          }          }
# Line 366  DataExpanded::copyToDataPoint(const int Line 431  DataExpanded::copyToDataPoint(const int
431             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
432               for (int k=0; k<dataPointShape[2]; k++) {               for (int k=0; k<dataPointShape[2]; k++) {
433                 for (int l=0; l<dataPointShape[3]; l++) {                 for (int l=0; l<dataPointShape[3]; l++) {
434                    dataPointView(i,j,k,l)=value;                    vec[offset+getRelIndex(dataPointShape,i,j,k,l)]=value;
435                 }                 }
436               }               }
437             }             }
# Line 380  DataExpanded::copyToDataPoint(const int Line 445  DataExpanded::copyToDataPoint(const int
445    // Get the number of samples and data-points per sample.    // Get the number of samples and data-points per sample.
446    int numSamples = getNumSamples();    int numSamples = getNumSamples();
447    int numDataPointsPerSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
448    int dataPointRank = getPointDataView().getRank();    int dataPointRank = getRank();
449    ShapeType dataPointShape = getPointDataView().getShape();    const ShapeType& shape = getShape();
450    //    //
451    // check rank:    // check rank:
452    if (value.getrank()!=dataPointRank)    if (value.getrank()!=dataPointRank)
# Line 394  DataExpanded::copyToDataPoint(const int Line 459  DataExpanded::copyToDataPoint(const int
459       if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {       if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {
460             throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");             throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
461       }       }
462       DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);   //    DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
463         ValueType& vec=getVector();
464       if (dataPointRank==0) {       if (dataPointRank==0) {
465           dataPointView()=extract<double>(value[0]);           vec[0]=extract<double>(value[0]);
466       } else if (dataPointRank==1) {       } else if (dataPointRank==1) {
467          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<shape[0]; i++) {
468              dataPointView(i)=extract<double>(value[i]);              vec[i]=extract<double>(value[i]);
469          }          }
470       } else if (dataPointRank==2) {       } else if (dataPointRank==2) {
471          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<shape[0]; i++) {
472             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<shape[1]; j++) {
473                dataPointView(i,j)=extract<double>(value[i][j]);                vec[getRelIndex(shape,i,j)]=extract<double>(value[i][j]);
474             }             }
475          }          }
476       } else if (dataPointRank==3) {       } else if (dataPointRank==3) {
477          for (int i=0; i<dataPointShape[0]; i++) {          for (int i=0; i<shape[0]; i++) {
478             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<shape[1]; j++) {
479                for (int k=0; k<dataPointShape[2]; k++) {                for (int k=0; k<shape[2]; k++) {
480                   dataPointView(i,j,k)=extract<double>(value[i][j][k]);                   vec[getRelIndex(shape,i,j,k)]=extract<double>(value[i][j][k]);
481                }                }
482             }             }
483          }          }
484       } else if (dataPointRank==4) {       } else if (dataPointRank==4) {
485           for (int i=0; i<dataPointShape[0]; i++) {           for (int i=0; i<shape[0]; i++) {
486             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<shape[1]; j++) {
487               for (int k=0; k<dataPointShape[2]; k++) {               for (int k=0; k<shape[2]; k++) {
488                 for (int l=0; l<dataPointShape[3]; l++) {                 for (int l=0; l<shape[3]; l++) {
489                    dataPointView(i,j,k,l)=extract<double>(value[i][j][k][l]);                    vec[getRelIndex(shape,i,j,k,l)]=extract<double>(value[i][j][k][l]);
490                 }                 }
491               }               }
492             }             }
# Line 434  DataExpanded::copyAll(const boost::pytho Line 500  DataExpanded::copyAll(const boost::pytho
500    // Get the number of samples and data-points per sample.    // Get the number of samples and data-points per sample.
501    int numSamples = getNumSamples();    int numSamples = getNumSamples();
502    int numDataPointsPerSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
503    int dataPointRank = getPointDataView().getRank();    int dataPointRank = getRank();
504    ShapeType dataPointShape = getPointDataView().getShape();    const ShapeType& dataPointShape = getShape();
505    //    //
506    // check rank:    // check rank:
507    if (value.getrank()!=dataPointRank+1)    if (value.getrank()!=dataPointRank+1)
# Line 443  DataExpanded::copyAll(const boost::pytho Line 509  DataExpanded::copyAll(const boost::pytho
509    if (value.getshape()[0]!=numSamples*numDataPointsPerSample)    if (value.getshape()[0]!=numSamples*numDataPointsPerSample)
510         throw DataException("leading dimension of numarray is too small");         throw DataException("leading dimension of numarray is too small");
511    //    //
512      ValueType& vec=getVector();
513    int dataPoint = 0;    int dataPoint = 0;
514    for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {
515      for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
516        DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);  //       DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
517          ValueType::size_type offset=getPointOffset(sampleNo, dataPointNo);
518        if (dataPointRank==0) {        if (dataPointRank==0) {
519           dataPointView()=extract<double>(value[dataPoint]);           vec[offset]=extract<double>(value[dataPoint]);
520        } else if (dataPointRank==1) {        } else if (dataPointRank==1) {
521           for (int i=0; i<dataPointShape[0]; i++) {           for (int i=0; i<dataPointShape[0]; i++) {
522              dataPointView(i)=extract<double>(value[dataPoint][i]);              vec[offset+i]=extract<double>(value[dataPoint][i]);
523           }           }
524        } else if (dataPointRank==2) {        } else if (dataPointRank==2) {
525           for (int i=0; i<dataPointShape[0]; i++) {           for (int i=0; i<dataPointShape[0]; i++) {
526             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
527               dataPointView(i,j)=extract<double>(value[dataPoint][i][j]);           vec[offset+getRelIndex(dataPointShape,i,j)]=extract<double>(value[dataPoint][i][j]);
528    //             dataPointView(i,j)=extract<double>(value[dataPoint][i][j]);
529             }             }
530           }           }
531         } else if (dataPointRank==3) {         } else if (dataPointRank==3) {
532           for (int i=0; i<dataPointShape[0]; i++) {           for (int i=0; i<dataPointShape[0]; i++) {
533             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
534               for (int k=0; k<dataPointShape[2]; k++) {               for (int k=0; k<dataPointShape[2]; k++) {
535                   dataPointView(i,j,k)=extract<double>(value[dataPoint][i][j][k]);           vec[offset+getRelIndex(dataPointShape,i,j,k)]=extract<double>(value[dataPoint][i][j][k]);
536               }               }
537             }             }
538           }           }
# Line 472  DataExpanded::copyAll(const boost::pytho Line 541  DataExpanded::copyAll(const boost::pytho
541             for (int j=0; j<dataPointShape[1]; j++) {             for (int j=0; j<dataPointShape[1]; j++) {
542               for (int k=0; k<dataPointShape[2]; k++) {               for (int k=0; k<dataPointShape[2]; k++) {
543                 for (int l=0; l<dataPointShape[3]; l++) {                 for (int l=0; l<dataPointShape[3]; l++) {
544                   dataPointView(i,j,k,l)=extract<double>(value[dataPoint][i][j][k][l]);                   vec[offset+getRelIndex(dataPointShape,i,j,k,l)]=extract<double>(value[dataPoint][i][j][k][l]);
545                 }                 }
546               }               }
547             }             }
# Line 492  DataExpanded::symmetric(DataAbstract* ev Line 561  DataExpanded::symmetric(DataAbstract* ev
561    if (temp_ev==0) {    if (temp_ev==0) {
562      throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
563    }    }
564    DataArrayView& thisView=getPointDataView();  //  DataArrayView& thisView=getPointDataView();
565    DataArrayView& evView=ev->getPointDataView();  //  DataArrayView& evView=ev->getPointDataView();
566      ValueType& vec=getVector();
567      const ShapeType& shape=getShape();
568      ValueType& evVec=temp_ev->getVector();
569      const ShapeType& evShape=temp_ev->getShape();
570    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
571    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
572      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
573           DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),           DataMaths::symmetric(vec,shape,getPointOffset(sampleNo,dataPointNo),
574                                      evView,ev->getPointOffset(sampleNo,dataPointNo));                                      evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo));
575      }      }
576    }    }
577  }  }
# Line 512  DataExpanded::nonsymmetric(DataAbstract* Line 585  DataExpanded::nonsymmetric(DataAbstract*
585    if (temp_ev==0) {    if (temp_ev==0) {
586      throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
587    }    }
588    DataArrayView& thisView=getPointDataView();  //   DataArrayView& thisView=getPointDataView();
589    DataArrayView& evView=ev->getPointDataView();  //   DataArrayView& evView=ev->getPointDataView();
590      ValueType& vec=getVector();
591      const ShapeType& shape=getShape();
592      ValueType& evVec=temp_ev->getVector();
593      const ShapeType& evShape=temp_ev->getShape();
594    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
595    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
596      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
597           DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),  //          DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
598                                      evView,ev->getPointOffset(sampleNo,dataPointNo));  //                                     evView,ev->getPointOffset(sampleNo,dataPointNo));
599             DataMaths::nonsymmetric(vec,shape,getPointOffset(sampleNo,dataPointNo),
600                                        evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo));
601      }      }
602    }    }
603  }  }
# Line 532  DataExpanded::trace(DataAbstract* ev, in Line 611  DataExpanded::trace(DataAbstract* ev, in
611    if (temp_ev==0) {    if (temp_ev==0) {
612      throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");
613    }    }
614    DataArrayView& thisView=getPointDataView();    ValueType& vec=getVector();
615    DataArrayView& evView=ev->getPointDataView();    const ShapeType& shape=getShape();
616      ValueType& evVec=temp_ev->getVector();
617      const ShapeType& evShape=temp_ev->getShape();
618    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
619    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
620      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
621           DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),  /*         DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),
622                                      evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);                                      evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);*/
623             DataMaths::trace(vec,shape,getPointOffset(sampleNo,dataPointNo),
624                                        evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
625      }      }
626    }    }
627  }  }
# Line 553  DataExpanded::transpose(DataAbstract* ev Line 636  DataExpanded::transpose(DataAbstract* ev
636    if (temp_ev==0) {    if (temp_ev==0) {
637      throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
638    }    }
639    DataArrayView& thisView=getPointDataView();    ValueType& vec=getVector();
640    DataArrayView& evView=ev->getPointDataView();    const ShapeType& shape=getShape();
641      ValueType& evVec=temp_ev->getVector();
642      const ShapeType& evShape=temp_ev->getShape();
643    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
644    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
645      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
646           DataArrayView::transpose(thisView,getPointOffset(sampleNo,dataPointNo),           DataMaths::transpose(vec,shape,getPointOffset(sampleNo,dataPointNo),
647                                      evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);                                      evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
648      }      }
649    }    }
650  }  }
# Line 574  DataExpanded::swapaxes(DataAbstract* ev, Line 659  DataExpanded::swapaxes(DataAbstract* ev,
659    if (temp_ev==0) {    if (temp_ev==0) {
660      throw DataException("Error - DataExpanded::swapaxes: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::swapaxes: casting to DataExpanded failed (propably a programming error).");
661    }    }
662    DataArrayView& thisView=getPointDataView();    ValueType& vec=getVector();
663    DataArrayView& evView=ev->getPointDataView();    const ShapeType& shape=getShape();
664      ValueType& evVec=temp_ev->getVector();
665      const ShapeType& evShape=temp_ev->getShape();
666    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
667    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
668      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
669           DataArrayView::swapaxes(thisView,getPointOffset(sampleNo,dataPointNo),           DataMaths::swapaxes(vec,shape,getPointOffset(sampleNo,dataPointNo),
670                                      evView,ev->getPointOffset(sampleNo,dataPointNo),axis0,axis1);                                      evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo),axis0,axis1);
671      }      }
672    }    }
673  }  }
# Line 594  DataExpanded::eigenvalues(DataAbstract* Line 681  DataExpanded::eigenvalues(DataAbstract*
681    if (temp_ev==0) {    if (temp_ev==0) {
682      throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");
683    }    }
684    DataArrayView& thisView=getPointDataView();    ValueType& vec=getVector();
685    DataArrayView& evView=ev->getPointDataView();    const ShapeType& shape=getShape();
686      ValueType& evVec=temp_ev->getVector();
687      const ShapeType& evShape=temp_ev->getShape();
688    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
689    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
690      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
691           DataArrayView::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),           DataMaths::eigenvalues(vec,shape,getPointOffset(sampleNo,dataPointNo),
692                                      evView,ev->getPointOffset(sampleNo,dataPointNo));                                      evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo));
693      }      }
694    }    }
695  }  }
# Line 618  DataExpanded::eigenvalues_and_eigenvecto Line 707  DataExpanded::eigenvalues_and_eigenvecto
707    if (temp_V==0) {    if (temp_V==0) {
708      throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");      throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
709    }    }
710    DataArrayView& thisView=getPointDataView();    ValueType& vec=getVector();
711    DataArrayView& evView=ev->getPointDataView();    const ShapeType& shape=getShape();
712    DataArrayView& VView=V->getPointDataView();    ValueType& evVec=temp_ev->getVector();
713      const ShapeType& evShape=temp_ev->getShape();
714      ValueType& VVec=temp_V->getVector();
715      const ShapeType& VShape=temp_V->getShape();
716    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
717    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
718      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {      for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
719           DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),           DataMaths::eigenvalues_and_eigenvectors(vec,shape,getPointOffset(sampleNo,dataPointNo),
720                                                       evView,ev->getPointOffset(sampleNo,dataPointNo),                                      evVec,evShape,ev->getPointOffset(sampleNo,dataPointNo),
721                                                       VView,V->getPointOffset(sampleNo,dataPointNo),                                      VVec, VShape,V->getPointOffset(sampleNo,dataPointNo),tol);
                                                      tol);  
722      }      }
723    }    }
724  }  }
725    
726  void  void
727  DataExpanded::setToZero(){  DataExpanded::setToZero(){
728    // TODO: Surely there is a more efficient way to do this????
729    // Why is there no memset here? Parallel issues?
730    int numSamples = getNumSamples();    int numSamples = getNumSamples();
731    int numDataPointsPerSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
732    DataArrayView& thisView=getPointDataView();    DataTypes::ValueType::size_type n = getNoValues();
   DataArrayView::ValueType::size_type n = thisView.noValues();  
733    double* p;    double* p;
734    int  sampleNo,dataPointNo, i;    int  sampleNo,dataPointNo, i;
735    #pragma omp parallel for private(sampleNo,dataPointNo,p,i) schedule(static)    #pragma omp parallel for private(sampleNo,dataPointNo,p,i) schedule(static)
# Line 662  void Line 754  void
754  DataExpanded::dump(const std::string fileName) const  DataExpanded::dump(const std::string fileName) const
755  {  {
756     #ifdef USE_NETCDF     #ifdef USE_NETCDF
757     const int ldims=2+DataArrayView::maxRank;     const int ldims=2+DataTypes::maxRank;
758     const NcDim* ncdims[ldims];     const NcDim* ncdims[ldims];
759     NcVar *var, *ids;     NcVar *var, *ids;
760     int rank = getPointDataView().getRank();     int rank = getRank();
761     int type=  getFunctionSpace().getTypeCode();     int type=  getFunctionSpace().getTypeCode();
762     int ndims =0;     int ndims =0;
763     long dims[ldims];     long dims[ldims];
764     const double* d_ptr=&(m_data[0]);     const double* d_ptr=&(m_data[0]);
765     DataArrayView::ShapeType shape = getPointDataView().getShape();     const DataTypes::ShapeType& shape = getShape();
766     int mpi_iam=0, mpi_num=1;     int mpi_iam=0, mpi_num=1;
767    
768     // netCDF error handler     // netCDF error handler
# Line 734  DataExpanded::dump(const std::string fil Line 826  DataExpanded::dump(const std::string fil
826     #endif     #endif
827  }  }
828    
829  void  // void
830    // DataExpanded::setTaggedValue(int tagKey,
831    //                              const DataArrayView& value)
832    // {
833    //   int numSamples = getNumSamples();
834    //   int numDataPointsPerSample = getNumDPPSample();
835    //   int sampleNo,dataPointNo, i;
836    //   DataTypes::ValueType::size_type n = getNoValues();
837    //   double* p,*in=&(value.getData()[0]);
838    //  
839    //   if (value.noValues() != n) {
840    //     throw DataException("Error - DataExpanded::setTaggedValue: number of input values does not match number of values per data points.");
841    //   }
842    //
843    //   #pragma omp parallel for private(sampleNo,dataPointNo,p,i) schedule(static)
844    //   for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
845    //     if (getFunctionSpace().getTagFromSampleNo(sampleNo) == tagKey ) {
846    //         for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
847    //             p=&(m_data[getPointOffset(sampleNo,dataPointNo)]);
848    //             for (i=0; i<n ;++i) p[i]=in[i];
849    //         }
850    //     }
851    //   }
852    // }
853    
854    void  
855  DataExpanded::setTaggedValue(int tagKey,  DataExpanded::setTaggedValue(int tagKey,
856                               const DataArrayView& value)             const DataTypes::ShapeType& pointshape,
857                   const DataTypes::ValueType& value,
858               int dataOffset)
859  {  {
860    int numSamples = getNumSamples();    int numSamples = getNumSamples();
861    int numDataPointsPerSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
862    int sampleNo,dataPointNo, i;    int sampleNo,dataPointNo, i;
863    DataArrayView& thisView=getPointDataView();    DataTypes::ValueType::size_type n = getNoValues();
864    DataArrayView::ValueType::size_type n = thisView.noValues();    double* p;
865    double* p,*in=&(value.getData()[0]);    const double* in=&value[0+dataOffset];
866        
867    if (value.noValues() != n) {    if (value.size() != n) {
868      throw DataException("Error - DataExpanded::setTaggedValue: number of input values does not match number of values per data points.");      throw DataException("Error - DataExpanded::setTaggedValue: number of input values does not match number of values per data points.");
869    }    }
870    
# Line 760  DataExpanded::setTaggedValue(int tagKey, Line 879  DataExpanded::setTaggedValue(int tagKey,
879    }    }
880  }  }
881    
882    
883  void  void
884  DataExpanded::reorderByReferenceIDs(int *reference_ids)  DataExpanded::reorderByReferenceIDs(int *reference_ids)
885  {  {
886    int numSamples = getNumSamples();    int numSamples = getNumSamples();
887    DataArrayView& thisView=getPointDataView();    DataTypes::ValueType::size_type n = getNoValues() * getNumDPPSample();
   DataArrayView::ValueType::size_type n = thisView.noValues() * getNumDPPSample();  
888    int sampleNo, sampleNo2,i;    int sampleNo, sampleNo2,i;
889    double* p,*p2;    double* p,*p2;
890    register double rtmp;    register double rtmp;
# Line 798  DataExpanded::reorderByReferenceIDs(int Line 917  DataExpanded::reorderByReferenceIDs(int
917     }     }
918  }  }
919    
920    DataTypes::ValueType&
921    DataExpanded::getVector()
922    {
923        return m_data.getData();
924    }
925    
926    const DataTypes::ValueType&
927    DataExpanded::getVector() const
928    {
929        return m_data.getData();
930    }
931    
932  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.1748  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26