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

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

  ViewVC Help
Powered by ViewVC 1.1.26