/[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

trunk/esys2/escript/src/Data/DataExpanded.cpp revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataExpanded.cpp revision 584 by gross, Thu Mar 9 23:03:38 2006 UTC
# Line 1  Line 1 
1    // $Id$
2  /*  /*
3   ******************************************************************************   ******************************************************************************
4   *                                                                            *   *                                                                            *
# Line 12  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15    
16  #include "escript/Data/DataException.h"  #include "DataExpanded.h"
17  #include "escript/Data/DataExpanded.h"  #include "DataException.h"
18  #include "escript/Data/DataConstant.h"  #include "DataConstant.h"
19  #include "escript/Data/DataTagged.h"  #include "DataTagged.h"
 #include "escript/Data/DataArrayView.h"  
20    
21  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
22    
 #include <iostream>  
   
23  using namespace std;  using namespace std;
24  using namespace boost::python;  using namespace boost::python;
25  using namespace boost;  using namespace boost;
26    
27  namespace escript {  namespace escript {
28    
29    DataExpanded::DataExpanded(const boost::python::numeric::array& value, const FunctionSpace& what) : DataAbstract(what)  DataExpanded::DataExpanded(const boost::python::numeric::array& value,
30    {                             const FunctionSpace& what)
31      //cout << "Calling DataExpanded constructor 1." << endl;    : DataAbstract(what)
32      DataArrayView::ShapeType tempShape;  {
33      //    DataArrayView::ShapeType tempShape;
34      // extract the shape from the python array    //
35      for (int i=0; i<value.getrank(); ++i) {    // extract the shape of the python numarray
36        cout << extract<int>(value.getshape()[i]) << endl;    for (int i=0; i<value.getrank(); i++) {
37        tempShape.push_back(extract<int>(value.getshape()[i]));      tempShape.push_back(extract<int>(value.getshape()[i]));
38      }    }
39      initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());    //
40      //    // initialise the data array for this object
41      // copy the given value to every data point    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());
42      copy(value);    //
43    }    // copy the given value to every data point
44      copy(value);
45    DataExpanded::DataExpanded(const DataExpanded& other) : DataAbstract(other.getFunctionSpace()), m_data(other.m_data)  }
46    {      
47      //cout << "Calling DataExpanded copy constructor." << endl;  DataExpanded::DataExpanded(const DataExpanded& other)
48      //    : DataAbstract(other.getFunctionSpace()),
49      // create the view for the data    m_data(other.m_data)
50      DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());  {
51      setPointDataView(temp);    //
52    }    // create the view for the data
53      DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());
54    DataExpanded::DataExpanded(const DataConstant& other) : DataAbstract(other.getFunctionSpace())    setPointDataView(temp);
55    {      }
56      //cout << "Creating DataExpanded from DataConstant." << endl;  
57      initialise(other.getPointDataView().getShape(),other.getNumSamples(), other.getNumDPPSample());  DataExpanded::DataExpanded(const DataConstant& other)
58      //    : DataAbstract(other.getFunctionSpace())
59      // DataConstant only has one value  {
60      copy(other.getPointDataView());    //
61    }    // initialise the data array for this object
62      initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());
63    DataExpanded::DataExpanded(const DataTagged& other) : DataAbstract(other.getFunctionSpace())    //
64    {        // DataConstant only has one value, copy this to every data point
65      //cout << "Creating DataExpanded from DataTagged." << endl;    copy(other.getPointDataView());
66      initialise(other.getPointDataView().getShape(),other.getNumSamples(), other.getNumDPPSample());  }
67      int i,j;  
68      DataArrayView::ValueType::size_type numRows=m_data.getNumRows();  DataExpanded::DataExpanded(const DataTagged& other)
69      DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    : DataAbstract(other.getFunctionSpace())
70  #pragma omp parallel for private(i,j) schedule(static)  {
71      for (i=0;i<numRows;++i) {    //
72        for (j=0;j<numCols;++j) {    // initialise the data array for this object
73      try {    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());
74        getPointDataView().copy(getPointOffset(i,j), other.getPointDataView(), other.getPointOffset(i,j));    //
75      }    // for each data point in this object, extract and copy the corresponding data
76      catch (std::exception& e) {    // value from the given DataTagged object
77        cout << e.what() << endl;    int i,j;
78      }    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
79      DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
80      #pragma omp parallel for private(i,j) schedule(static)
81      for (i=0;i<numRows;i++) {
82        for (j=0;j<numCols;j++) {
83          try {
84            getPointDataView().copy(getPointOffset(i,j),
85                                    other.getPointDataView(),
86                                    other.getPointOffset(i,j));
87        }        }
88      }        catch (std::exception& e) {
89    }          cout << e.what() << endl;
   
   DataExpanded::DataExpanded(const DataExpanded& other, const DataArrayView::RegionType& region) : DataAbstract(other.getFunctionSpace())  
   {  
     //cout << "Creating DataExpanded by slicing from another DataExpanded." << endl;  
     //  
     // get the shape of the slice  
     DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));  
     initialise(shape,other.getNumSamples(),other.getNumDPPSample());  
     //  
     // copy the data  
     DataArrayView::ValueType::size_type numRows=m_data.getNumRows();  
     DataArrayView::ValueType::size_type numCols=m_data.getNumCols();  
     int i,j;  
 #pragma omp parallel for private(i,j) schedule(static)  
     for (i=0;i<numRows;++i) {  
       for (j=0;j<numCols;++j) {  
     try {  
       getPointDataView().copySlice(getPointOffset(i,j), other.getPointDataView(), other.getPointOffset(i,j), region);  
     }  
     catch (std::exception& e) {  
       cout << e.what() << endl;  
     }  
90        }        }
91      }      }
92    }    }
93    }
94    
95    DataExpanded::DataExpanded(const DataArrayView& value,const FunctionSpace& what): DataAbstract(what)  DataExpanded::DataExpanded(const DataExpanded& other,
96    {                             const DataArrayView::RegionType& region)
97      //cout << "Calling DataExpanded constructor 2." << endl;    : DataAbstract(other.getFunctionSpace())
98      DataArrayView::ShapeType tempShape=value.getShape();  {
99      initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());    //
100      copy(value);    // get the shape of the slice
101    }    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
102      //
103    DataExpanded::~DataExpanded()    // initialise this Data object to the shape of the slice
104    {    initialise(shape,other.getNumSamples(),other.getNumDPPSample());
105      //cout << "Destructing DataExpanded." << endl;    //
106    }    // copy the data
107      DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
108    DataAbstract* DataExpanded::getSlice(const DataArrayView::RegionType& region) const    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
109    {    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
110      return new DataExpanded(*this,region);    int i,j;
111    }    #pragma omp parallel for private(i,j) schedule(static)
112      for (i=0;i<numRows;i++) {
113    void DataExpanded::reshapeDataPoint(const DataArrayView::ShapeType& shape)      for (j=0;j<numCols;j++) {
114    {        try {
115      //          getPointDataView().copySlice(getPointOffset(i,j),
116      // reshape a rank zero data point                                       other.getPointDataView(),
117      if (getPointDataView().getRank()!=0) {                                       other.getPointOffset(i,j),
118        stringstream temp;                                       region_loop_range);
       temp << "Error - Can only reshape Data with data points of rank 0. "  
        << "This Data has data points with rank: "  
        << getPointDataView().getRank();  
       throw DataException(temp.str());  
     }  
     DataBlocks2D newData(getNumSamples(),getNumDPPSample(), DataArrayView::noValues(shape));  
     DataArrayView newView(newData.getData(),shape);  
     //  
     // Copy the original data to every value for the new shape  
     int i,j;  
     int nRows=m_data.getNumRows();  
     int nCols=m_data.getNumCols();  
     #pragma omp parallel for private(i,j) schedule(static)  
     for (i=0;i<nRows;++i) {  
       for (j=0;j<nCols;++j) {  
     //  
     // Copy the data into the specified offset  
     // NOTE: An exception may be thown from this call if  
     // DOASSERT is on which of course will play  
     // havoc with the omp threads. Run single threaded  
     // if using DOASSERT.  
     newView.copy(newData.index(i,j),m_data.getData()[m_data.index(i,j)]);  
119        }        }
120      }        catch (std::exception& e) {
121      m_data.Swap(newData);          cout << e.what() << endl;
     DataArrayView temp(m_data.getData(),shape);  
     setPointDataView(temp);  
   }  
   
   void DataExpanded::setSlice(const DataAbstract* value, const DataArrayView::RegionType& region)  
   {  
     const DataExpanded* tempDataExp=dynamic_cast<const DataExpanded*>(value);  
     if (tempDataExp==0) {  
       throw DataException("Programming error - casting to DataExpanded.");  
     }  
     if (getPointDataView().getRank()!=region.size()) {  
       throw DataException("Error - Invalid slice region.");  
     }  
     if (!value->getPointDataView().checkShape(DataArrayView::getResultSliceShape(region))) {  
       throw DataException (value->getPointDataView().createShapeErrorMessage(  
                 "Error - Couldn't copy slice due to shape mismatch.",DataArrayView::getResultSliceShape(region)));  
     }  
     //  
     // copy the data  
     DataArrayView::ValueType::size_type numRows=m_data.getNumRows();  
     DataArrayView::ValueType::size_type numCols=m_data.getNumCols();  
     int i,j;  
 #pragma omp parallel for private(i,j) schedule(static)  
     for (i=0;i<numRows;++i) {  
       for (j=0;j<numCols;++j) {  
     getPointDataView().copySliceFrom(getPointOffset(i,j), tempDataExp->getPointDataView(), tempDataExp->getPointOffset(i,j), region);  
122        }        }
123      }      }
124    }    }
125    }
126    
127    void DataExpanded::copy(const DataArrayView& value)  DataExpanded::DataExpanded(const DataArrayView& value,
128    {                             const FunctionSpace& what)
129      //    : DataAbstract(what)
130      // Copy a single value to every data point  {
131      int i,j;    //
132      int nRows=m_data.getNumRows();    // get the shape of the given data value
133      int nCols=m_data.getNumCols();    DataArrayView::ShapeType tempShape=value.getShape();
134      #pragma omp parallel for private(i,j) schedule(static)    //
135      for (i=0;i<nRows;++i) {    // initialise this Data object to the shape of the given data value
136        for (j=0;j<nCols;++j) {    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());
137      //    //
138      // Copy the data into the specified offset    // copy the given value to every data point
139      // NOTE: An exception may be thown from this call if    copy(value);
140      // DOASSERT is on which of course will play  }
141      // havoc with the omp threads. Run single threaded  
142      // if using DOASSERT.  DataExpanded::DataExpanded(const FunctionSpace& what,
143      getPointDataView().copy(m_data.index(i,j),value);                             const DataArrayView::ShapeType &shape,
144                               const DataArrayView::ValueType &data)
145      : DataAbstract(what)
146    {
147      //
148      // create the view of the data
149      initialise(shape,what.getNumSamples(),what.getNumDPPSample());
150      //
151      // copy the data in the correct format
152      m_data.getData()=data;
153    }
154    
155    DataExpanded::~DataExpanded()
156    {
157    }
158    
159    void
160    DataExpanded::reshapeDataPoint(const DataArrayView::ShapeType& shape)
161    {
162      if (getPointDataView().getRank()!=0) {
163        stringstream temp;
164        temp << "Error - Can only reshape Data with data points of rank 0. "
165             << "This Data has data points with rank: "
166             << getPointDataView().getRank();
167        throw DataException(temp.str());
168      }
169      //
170      // create the new DataBlocks2D data array, and a corresponding DataArrayView
171      DataBlocks2D newData(getNumSamples(),getNumDPPSample(),DataArrayView::noValues(shape));
172      DataArrayView newView(newData.getData(),shape);
173      //
174      // Copy the original data to every value for the new shape
175      int i,j;
176      int nRows=m_data.getNumRows();
177      int nCols=m_data.getNumCols();
178      #pragma omp parallel for private(i,j) schedule(static)
179      for (i=0;i<nRows;i++) {
180        for (j=0;j<nCols;j++) {
181          // NOTE: An exception may be thown from this call if
182          // DOASSERT is on which of course will play
183          // havoc with the omp threads. Run single threaded
184          // if using DOASSERT.
185          newView.copy(newData.index(i,j),m_data(i,j));
186        }
187      }
188      // swap the new data array for the original
189      m_data.Swap(newData);
190      // set the corresponding DataArrayView
191      DataArrayView temp(m_data.getData(),shape);
192      setPointDataView(temp);
193    }
194    
195    DataAbstract*
196    DataExpanded::getSlice(const DataArrayView::RegionType& region) const
197    {
198      return new DataExpanded(*this,region);
199    }
200    
201    void
202    DataExpanded::setSlice(const DataAbstract* value,
203                           const DataArrayView::RegionType& region)
204    {
205      const DataExpanded* tempDataExp=dynamic_cast<const DataExpanded*>(value);
206      if (tempDataExp==0) {
207        throw DataException("Programming error - casting to DataExpanded.");
208      }
209      //
210      // get shape of slice
211      DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
212      DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
213      //
214      // check shape
215      if (getPointDataView().getRank()!=region.size()) {
216        throw DataException("Error - Invalid slice region.");
217      }
218      if (tempDataExp->getPointDataView().getRank()>0 and !value->getPointDataView().checkShape(shape)) {
219        throw DataException (value->getPointDataView().createShapeErrorMessage(
220            "Error - Couldn't copy slice due to shape mismatch.",shape));
221      }
222      //
223      // copy the data from the slice into this object
224      DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
225      DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
226      int i, j;
227      #pragma omp parallel for private(i,j) schedule(static)
228      for (i=0;i<numRows;i++) {
229        for (j=0;j<numCols;j++) {
230          getPointDataView().copySliceFrom(getPointOffset(i,j),
231                                           tempDataExp->getPointDataView(),
232                                           tempDataExp->getPointOffset(i,j),
233                                           region_loop_range);
234        }
235      }
236    }
237    
238    void
239    DataExpanded::copy(const DataArrayView& value)
240    {
241      //
242      // copy a single value to every data point in this object
243      int nRows=m_data.getNumRows();
244      int nCols=m_data.getNumCols();
245      int i,j;
246      #pragma omp parallel for private(i,j) schedule(static)
247      for (i=0;i<nRows;i++) {
248        for (j=0;j<nCols;j++) {
249          // NOTE: An exception may be thown from this call if
250          // DOASSERT is on which of course will play
251          // havoc with the omp threads. Run single threaded
252          // if using DOASSERT.
253          getPointDataView().copy(m_data.index(i,j),value);
254        }
255      }
256    }
257    
258    void
259    DataExpanded::copy(const boost::python::numeric::array& value)
260    {
261      //
262      // first convert the numarray into a DataArray object
263      DataArray temp(value);
264      //
265      // check the input shape matches this shape
266      if (!getPointDataView().checkShape(temp.getView().getShape())) {
267        throw DataException(getPointDataView().createShapeErrorMessage(
268                            "Error - (DataExpanded) Cannot copy due to shape mismatch.",
269                            temp.getView().getShape()));
270      }
271      //
272      // now copy over the data
273      copy(temp.getView());
274    }
275    
276    void
277    DataExpanded::initialise(const DataArrayView::ShapeType& shape,
278                             int noSamples,
279                             int noDataPointsPerSample)
280    {
281      //
282      // resize data array to the required size
283      m_data.resize(noSamples,noDataPointsPerSample,DataArrayView::noValues(shape));
284      //
285      // create the data view of the data array
286      DataArrayView temp(m_data.getData(),shape);
287      setPointDataView(temp);
288    }
289    
290    string
291    DataExpanded::toString() const
292    {
293      stringstream temp;
294      //
295      // create a temporary view as the offset will be changed
296      DataArrayView tempView(getPointDataView().getData(),getPointDataView().getShape(),getPointDataView().getOffset());
297      for (int i=0;i<m_data.getNumRows();i++) {
298        for (int j=0;j<m_data.getNumCols();j++) {
299          tempView.setOffset(m_data.index(i,j));
300          stringstream suffix;
301          suffix << "(" << i << "," << j << ")";
302          temp << tempView.toString(suffix.str());
303          if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {
304            temp << endl;
305        }        }
306      }      }
307    }    }
308      return temp.str();
309    }
310    
311    void DataExpanded::copy(const boost::python::numeric::array& value)  DataArrayView::ValueType::size_type
312    {  DataExpanded::getPointOffset(int sampleNo,
313      //                               int dataPointNo) const
314      // first convert the numarray into a DataArrayView format  {
315      DataArray temp(value);    return m_data.index(sampleNo,dataPointNo);
316      //  }
317      // check the input shape matches this shape, this will throw an exception  
318      if (!getPointDataView().checkShape(temp.getView().getShape())) {  DataArrayView
319        throw DataException(getPointDataView().createShapeErrorMessage(  DataExpanded::getDataPoint(int sampleNo,
320           "Error - (DataExpanded) Cannot copy due to shape mismatch.",                             int dataPointNo)
321           temp.getView().getShape()));  {
322      }    DataArrayView temp(m_data.getData(),getPointDataView().getShape(),m_data.index(sampleNo,dataPointNo));
323      //    return temp;
324      // now copy over the entire data structure  }
325      copy(temp.getView());  
326    }  DataArrayView::ValueType::size_type
327    DataExpanded::getLength() const
328    void DataExpanded::initialise(const DataArrayView::ShapeType& shape, int noSamples, int noDataPointsPerSample)  {
329    {    return m_data.size();
330      //  }
331      // resize data to the required size  
332      //cout << "noDataPointsPerSample=" << noDataPointsPerSample  void
333      //     << " noSamples=" << noSamples  DataExpanded::setRefValue(int ref,
334      //     << " noValuesPerDataPoint=" << DataArrayView::noValues(shape) << endl;                            const DataArray& value)
335      m_data.resize(noSamples,noDataPointsPerSample, DataArrayView::noValues(shape));  {
336      //    //
337      // create a point data viewer of the data    // Get the number of samples and data-points per sample.
338      DataArrayView temp(m_data.getData(),shape);    int numSamples = getNumSamples();
339      setPointDataView(temp);    int numDPPSample = getNumDPPSample();
340      //cout << "leaving initialise." << endl;  
341    }    //
342      // Determine the sample number which corresponds to this reference number.
343    string DataExpanded::toString() const    int sampleNo = -1;
344    {    int tempRef = -1;
345      stringstream temp;    for (int n=0; n<numSamples; n++) {
346      //      tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
347      // create a temporary view as the offset will be changed      if (tempRef == ref) {
348      DataArrayView tempView(getPointDataView().getData(), getPointDataView().getShape(), getPointDataView().getOffset());        sampleNo = n;
349      for (int i=0;i<m_data.getNumRows();++i) {        break;
350        for (int j=0;j<m_data.getNumCols();++j) {      }
351          tempView.setOffset(m_data.index(i,j));    }
352      stringstream suffix;    if (sampleNo == -1) {
353      suffix << "(" << i << "," << j << ")";      throw DataException("DataExpanded::setRefValue error: invalid ref number supplied.");
354      temp << tempView.toString(suffix.str());    }
355      if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {  
356        temp << endl;    for (int n=0; n<numDPPSample; n++) {
357      }      //
358        // Get *each* data-point in the sample in turn.
359        DataArrayView pointView = getDataPoint(sampleNo, n);
360        //
361        // Assign the values in the DataArray to this data-point.
362        pointView.copy(value.getView());
363      }
364    }
365    
366    void
367    DataExpanded::getRefValue(int ref,
368                              DataArray& value)
369    {
370      //
371      // Get the number of samples and data-points per sample.
372      int numSamples = getNumSamples();
373      int numDPPSample = getNumDPPSample();
374    
375      //
376      // Determine the sample number which corresponds to this reference number
377      int sampleNo = -1;
378      int tempRef = -1;
379      for (int n=0; n<numSamples; n++) {
380        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
381        if (tempRef == ref) {
382          sampleNo = n;
383          break;
384        }
385      }
386      if (sampleNo == -1) {
387        throw DataException("DataExpanded::getRefValue error: invalid ref number supplied.");
388      }
389    
390      //
391      // Get the *first* data-point associated with this sample number.
392      DataArrayView pointView = getDataPoint(sampleNo, 0);
393    
394      //
395      // Load the values from this data-point into the DataArray
396      value.getView().copy(pointView);
397    }
398    
399    int
400    DataExpanded::archiveData(ofstream& archiveFile,
401                              const DataArrayView::ValueType::size_type noValues) const
402    {
403      return(m_data.archiveData(archiveFile, noValues));
404    }
405    
406    int
407    DataExpanded::extractData(ifstream& archiveFile,
408                              const DataArrayView::ValueType::size_type noValues)
409    {
410      return(m_data.extractData(archiveFile, noValues));
411    }
412    
413    void
414    DataExpanded::copyAll(const boost::python::numeric::array& value) {
415      //
416      // Get the number of samples and data-points per sample.
417      int numSamples = getNumSamples();
418      int numDataPointsPerSample = getNumDPPSample();
419      int dataPointRank = getPointDataView().getRank();
420      ShapeType dataPointShape = getPointDataView().getShape();
421      //
422      // check rank:
423      if (value.getrank()!=dataPointRank+1)
424           throw DataException("Rank of numarray does not match Data object rank");
425      if (value.getshape()[0]!=numSamples*numDataPointsPerSample)
426           throw DataException("leading dimension of numarray is too small");
427      //
428      int dataPoint = 0;
429      for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {
430        for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
431          DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
432          if (dataPointRank==0) {
433             dataPointView()=extract<double>(value[dataPoint]);
434          } else if (dataPointRank==1) {
435             for (int i=0; i<dataPointShape[0]; i++) {
436                dataPointView(i)=extract<double>(value[dataPoint][i]);
437             }
438          } else if (dataPointRank==2) {
439             for (int i=0; i<dataPointShape[0]; i++) {
440               for (int j=0; j<dataPointShape[1]; j++) {
441                 dataPointView(i,j)=extract<double>(value[dataPoint][i][j]);
442               }
443             }
444           } else if (dataPointRank==3) {
445             for (int i=0; i<dataPointShape[0]; i++) {
446               for (int j=0; j<dataPointShape[1]; j++) {
447                 for (int k=0; k<dataPointShape[2]; k++) {
448                     dataPointView(i,j,k)=extract<double>(value[dataPoint][i][j][k]);
449                 }
450               }
451             }
452           } else if (dataPointRank==4) {
453             for (int i=0; i<dataPointShape[0]; i++) {
454               for (int j=0; j<dataPointShape[1]; j++) {
455                 for (int k=0; k<dataPointShape[2]; k++) {
456                   for (int l=0; l<dataPointShape[3]; l++) {
457                     dataPointView(i,j,k,l)=extract<double>(value[dataPoint][i][j][k][l]);
458                   }
459                 }
460               }
461             }
462        }        }
463          dataPoint++;
464      }      }
     return temp.str();  
465    }    }
466    }
467    DataArrayView::ValueType::size_type DataExpanded::getPointOffset(int sampleNo, int dataPointNo) const  void
468    {  DataExpanded::eigenvalues(DataAbstract* ev)
469      return m_data.index(sampleNo,dataPointNo);  {
470    }    int sampleNo,dataPointNo;
471      int numSamples = getNumSamples();
472    DataArrayView DataExpanded::getDataPoint(int sampleNo, int dataPointNo)    int numDataPointsPerSample = getNumDPPSample();
473    {    DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
474      DataArrayView temp(m_data.getData(), getPointDataView().getShape(), m_data.index(sampleNo,dataPointNo));    if (temp_ev==0) {
475      return temp;      throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");
476    }    }
477      DataArrayView& thisView=getPointDataView();
478    DataArrayView::ValueType::size_type DataExpanded::getLength() const    DataArrayView& evView=ev->getPointDataView();
479    {    #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
480      return m_data.getData().size();    for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
481        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
482             DataArrayView::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),
483                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
484        }
485      }
486    }
487    void
488    DataExpanded::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
489    {
490      int numSamples = getNumSamples();
491      int numDataPointsPerSample = getNumDPPSample();
492      int sampleNo,dataPointNo;
493      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
494      if (temp_ev==0) {
495        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
496      }
497      DataExpanded* temp_V=dynamic_cast<DataExpanded*>(V);
498      if (temp_V==0) {
499        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
500      }
501      DataArrayView& thisView=getPointDataView();
502      DataArrayView& evView=ev->getPointDataView();
503      DataArrayView& VView=V->getPointDataView();
504      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
505      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
506        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
507             DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),
508                                                         evView,ev->getPointOffset(sampleNo,dataPointNo),
509                                                         VView,V->getPointOffset(sampleNo,dataPointNo),
510                                                         tol);
511        }
512    }    }
513    }
514    
515  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.100  
changed lines
  Added in v.584

  ViewVC Help
Powered by ViewVC 1.1.26