/[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 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/escript/src/DataExpanded.cpp revision 921 by gross, Fri Jan 5 00:54:37 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $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;
# Line 35  DataExpanded::DataExpanded(const boost:: Line 30  DataExpanded::DataExpanded(const boost::
30  {  {
31    DataArrayView::ShapeType tempShape;    DataArrayView::ShapeType tempShape;
32    //    //
33    // extract the shape from the python array    // extract the shape of the python numarray
34    for (int i=0; i<value.getrank(); ++i) {    for (int i=0; i<value.getrank(); i++) {
     //cout << extract<int>(value.getshape()[i]) << endl;  
35      tempShape.push_back(extract<int>(value.getshape()[i]));      tempShape.push_back(extract<int>(value.getshape()[i]));
36    }    }
37      //
38      // initialise the data array for this object
39    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());
40    //    //
41    // copy the given value to every data point    // copy the given value to every data point
# Line 49  DataExpanded::DataExpanded(const boost:: Line 45  DataExpanded::DataExpanded(const boost::
45  DataExpanded::DataExpanded(const DataExpanded& other)  DataExpanded::DataExpanded(const DataExpanded& other)
46    : DataAbstract(other.getFunctionSpace()),    : DataAbstract(other.getFunctionSpace()),
47    m_data(other.m_data)    m_data(other.m_data)
48  {      {
49    //    //
50    // create the view for the data    // create the view for the data
51    DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());    DataArrayView temp(m_data.getData(),other.getPointDataView().getShape());
# Line 58  DataExpanded::DataExpanded(const DataExp Line 54  DataExpanded::DataExpanded(const DataExp
54    
55  DataExpanded::DataExpanded(const DataConstant& other)  DataExpanded::DataExpanded(const DataConstant& other)
56    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace())
57  {      {
58      //
59      // initialise the data array for this object
60    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());
61    //    //
62    // DataConstant only has one value    // DataConstant only has one value, copy this to every data point
63    copy(other.getPointDataView());    copy(other.getPointDataView());
64  }  }
65    
66  DataExpanded::DataExpanded(const DataTagged& other)  DataExpanded::DataExpanded(const DataTagged& other)
67    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace())
68  {      {
69      //
70      // initialise the data array for this object
71    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());    initialise(other.getPointDataView().getShape(),other.getNumSamples(),other.getNumDPPSample());
72      //
73      // for each data point in this object, extract and copy the corresponding data
74      // value from the given DataTagged object
75    int i,j;    int i,j;
76    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
77    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
78  #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
79    for (i=0;i<numRows;++i) {    for (i=0;i<numRows;i++) {
80      for (j=0;j<numCols;++j) {      for (j=0;j<numCols;j++) {
81        try {        try {
82          getPointDataView().copy(getPointOffset(i,j), other.getPointDataView(), other.getPointOffset(i,j));          getPointDataView().copy(getPointOffset(i,j),
83                                    other.getPointDataView(),
84                                    other.getPointOffset(i,j));
85        }        }
86        catch (std::exception& e) {        catch (std::exception& e) {
87          cout << e.what() << endl;          cout << e.what() << endl;
# Line 97  DataExpanded::DataExpanded(const DataExp Line 102  DataExpanded::DataExpanded(const DataExp
102    initialise(shape,other.getNumSamples(),other.getNumDPPSample());    initialise(shape,other.getNumSamples(),other.getNumDPPSample());
103    //    //
104    // copy the data    // copy the data
105      DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
106    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
107    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
108    int i,j;    int i,j;
109  #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
110    for (i=0;i<numRows;++i) {    for (i=0;i<numRows;i++) {
111      for (j=0;j<numCols;++j) {      for (j=0;j<numCols;j++) {
112        try {        try {
113          getPointDataView().copySlice(getPointOffset(i,j),other.getPointDataView(),other.getPointOffset(i,j),region);          getPointDataView().copySlice(getPointOffset(i,j),
114                                         other.getPointDataView(),
115                                         other.getPointOffset(i,j),
116                                         region_loop_range);
117        }        }
118        catch (std::exception& e) {        catch (std::exception& e) {
119          cout << e.what() << endl;          cout << e.what() << endl;
# Line 117  DataExpanded::DataExpanded(const DataArr Line 126  DataExpanded::DataExpanded(const DataArr
126                             const FunctionSpace& what)                             const FunctionSpace& what)
127    : DataAbstract(what)    : DataAbstract(what)
128  {  {
129      //
130      // get the shape of the given data value
131    DataArrayView::ShapeType tempShape=value.getShape();    DataArrayView::ShapeType tempShape=value.getShape();
132      //
133      // initialise this Data object to the shape of the given data value
134    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());    initialise(tempShape,what.getNumSamples(),what.getNumDPPSample());
135      //
136      // copy the given value to every data point
137    copy(value);    copy(value);
138  }  }
139    
140  DataExpanded::~DataExpanded()  DataExpanded::DataExpanded(const FunctionSpace& what,
141                               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  void  DataExpanded::~DataExpanded()
 DataExpanded::reshapeDataPoint(const DataArrayView::ShapeType& shape)  
154  {  {
   //  
   // reshape a rank zero data point  
   if (getPointDataView().getRank()!=0) {  
     stringstream temp;  
     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)]);  
     }  
   }  
   m_data.Swap(newData);  
   DataArrayView temp(m_data.getData(),shape);  
   setPointDataView(temp);  
155  }  }
156    
157  DataAbstract*  DataAbstract*
# Line 176  DataExpanded::setSlice(const DataAbstrac Line 168  DataExpanded::setSlice(const DataAbstrac
168    if (tempDataExp==0) {    if (tempDataExp==0) {
169      throw DataException("Programming error - casting to DataExpanded.");      throw DataException("Programming error - casting to DataExpanded.");
170    }    }
171      //
172      // get shape of slice
173      DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
174      DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);
175      //
176      // check shape
177    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
178      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
179    }    }
180    if (!value->getPointDataView().checkShape(DataArrayView::getResultSliceShape(region))) {    if (tempDataExp->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {
181      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (value->getPointDataView().createShapeErrorMessage(
182          "Error - Couldn't copy slice due to shape mismatch.",DataArrayView::getResultSliceShape(region)));          "Error - Couldn't copy slice due to shape mismatch.",shape));
183    }    }
184    //    //
185    // copy the data    // copy the data from the slice into this object
186    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();    DataArrayView::ValueType::size_type numRows=m_data.getNumRows();
187    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();    DataArrayView::ValueType::size_type numCols=m_data.getNumCols();
188    int i, j;    int i, j;
189  #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
190    for (i=0;i<numRows;i++) {    for (i=0;i<numRows;i++) {
191      for (j=0;j<numCols;j++) {      for (j=0;j<numCols;j++) {
192        getPointDataView().copySliceFrom(getPointOffset(i,j),tempDataExp->getPointDataView(),tempDataExp->getPointOffset(i,j),region);        getPointDataView().copySliceFrom(getPointOffset(i,j),
193                                           tempDataExp->getPointDataView(),
194                                           tempDataExp->getPointOffset(i,j),
195                                           region_loop_range);
196      }      }
197    }    }
198  }  }
# Line 200  void Line 201  void
201  DataExpanded::copy(const DataArrayView& value)  DataExpanded::copy(const DataArrayView& value)
202  {  {
203    //    //
204    // Copy a single value to every data point    // copy a single value to every data point in this object
205    int nRows=m_data.getNumRows();    int nRows=m_data.getNumRows();
206    int nCols=m_data.getNumCols();    int nCols=m_data.getNumCols();
207    int i, j;    int i,j;
208  #pragma omp parallel for private(i,j) schedule(static)    #pragma omp parallel for private(i,j) schedule(static)
209    for (i=0;i<nRows;++i) {    for (i=0;i<nRows;i++) {
210      for (j=0;j<nCols;++j) {      for (j=0;j<nCols;j++) {
       //  
       // Copy the data into the specified offset  
211        // NOTE: An exception may be thown from this call if        // NOTE: An exception may be thown from this call if
212        // DOASSERT is on which of course will play        // DOASSERT is on which of course will play
213        // havoc with the omp threads. Run single threaded        // havoc with the omp threads. Run single threaded
# Line 222  void Line 221  void
221  DataExpanded::copy(const boost::python::numeric::array& value)  DataExpanded::copy(const boost::python::numeric::array& value)
222  {  {
223    //    //
224    // first convert the numarray into a DataArrayView format    // first convert the numarray into a DataArray object
225    DataArray temp(value);    DataArray temp(value);
226    //    //
227    // check the input shape matches this shape, this will throw an exception    // check the input shape matches this shape
228    if (!getPointDataView().checkShape(temp.getView().getShape())) {    if (!getPointDataView().checkShape(temp.getView().getShape())) {
229      throw DataException(getPointDataView().createShapeErrorMessage(      throw DataException(getPointDataView().createShapeErrorMessage(
230                          "Error - (DataExpanded) Cannot copy due to shape mismatch.",                          "Error - (DataExpanded) Cannot copy due to shape mismatch.",
231                          temp.getView().getShape()));                          temp.getView().getShape()));
232    }    }
233    //    //
234    // now copy over the entire data structure    // now copy over the data
235    copy(temp.getView());    copy(temp.getView());
236  }  }
237    
# Line 242  DataExpanded::initialise(const DataArray Line 241  DataExpanded::initialise(const DataArray
241                           int noDataPointsPerSample)                           int noDataPointsPerSample)
242  {  {
243    //    //
244    // resize data to the required size    // resize data array to the required size
245    m_data.resize(noSamples,noDataPointsPerSample,DataArrayView::noValues(shape));    m_data.resize(noSamples,noDataPointsPerSample,DataArrayView::noValues(shape));
246    //    //
247    // create a point data viewer of the data    // create the data view of the data array
248    DataArrayView temp(m_data.getData(),shape);    DataArrayView temp(m_data.getData(),shape);
249    setPointDataView(temp);    setPointDataView(temp);
250  }  }
# Line 254  string Line 253  string
253  DataExpanded::toString() const  DataExpanded::toString() const
254  {  {
255    stringstream temp;    stringstream temp;
256      FunctionSpace fs=getFunctionSpace();
257    //    //
258    // create a temporary view as the offset will be changed    // create a temporary view as the offset will be changed
259    DataArrayView tempView(getPointDataView().getData(),getPointDataView().getShape(),getPointDataView().getOffset());    DataArrayView tempView(getPointDataView().getData(),getPointDataView().getShape(),getPointDataView().getOffset());
260    for (int i=0;i<m_data.getNumRows();++i) {    for (int i=0;i<m_data.getNumRows();i++) {
261      for (int j=0;j<m_data.getNumCols();++j) {      for (int j=0;j<m_data.getNumCols();j++) {
262        tempView.setOffset(m_data.index(i,j));        tempView.setOffset(m_data.index(i,j));
263        stringstream suffix;        stringstream suffix;
264        suffix << "(" << i << "," << j << ")";        suffix << "( id: " << i << ", ref: " << fs.getReferenceNoFromSampleNo(i) << ", pnt: " << j << ")";
265        temp << tempView.toString(suffix.str());        temp << tempView.toString(suffix.str());
266        if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {        if (!(i==(m_data.getNumRows()-1) && j==(m_data.getNumCols()-1))) {
267          temp << endl;          temp << endl;
# Line 289  DataExpanded::getDataPoint(int sampleNo, Line 289  DataExpanded::getDataPoint(int sampleNo,
289  DataArrayView::ValueType::size_type  DataArrayView::ValueType::size_type
290  DataExpanded::getLength() const  DataExpanded::getLength() const
291  {  {
292    return m_data.getData().size();    return m_data.size();
293    }
294    
295    void
296    DataExpanded::setRefValue(int ref,
297                              const DataArray& value)
298    {
299      //
300      // Get the number of samples and data-points per sample.
301      int numSamples = getNumSamples();
302      int numDPPSample = getNumDPPSample();
303    
304      //
305      // Determine the sample number which corresponds to this reference number.
306      int sampleNo = -1;
307      int tempRef = -1;
308      for (int n=0; n<numSamples; n++) {
309        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
310        if (tempRef == ref) {
311          sampleNo = n;
312          break;
313        }
314      }
315      if (sampleNo == -1) {
316        throw DataException("DataExpanded::setRefValue error: invalid ref number supplied.");
317      }
318    
319      for (int n=0; n<numDPPSample; n++) {
320        //
321        // Get *each* data-point in the sample in turn.
322        DataArrayView pointView = getDataPoint(sampleNo, n);
323        //
324        // Assign the values in the DataArray to this data-point.
325        pointView.copy(value.getView());
326      }
327    }
328    
329    void
330    DataExpanded::getRefValue(int ref,
331                              DataArray& value)
332    {
333      //
334      // Get the number of samples and data-points per sample.
335      int numSamples = getNumSamples();
336      int numDPPSample = getNumDPPSample();
337    
338      //
339      // Determine the sample number which corresponds to this reference number
340      int sampleNo = -1;
341      int tempRef = -1;
342      for (int n=0; n<numSamples; n++) {
343        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
344        if (tempRef == ref) {
345          sampleNo = n;
346          break;
347        }
348      }
349      if (sampleNo == -1) {
350        throw DataException("DataExpanded::getRefValue error: invalid ref number supplied.");
351      }
352    
353      //
354      // Get the *first* data-point associated with this sample number.
355      DataArrayView pointView = getDataPoint(sampleNo, 0);
356    
357      //
358      // Load the values from this data-point into the DataArray
359      value.getView().copy(pointView);
360    }
361    
362    int
363    DataExpanded::archiveData(ofstream& archiveFile,
364                              const DataArrayView::ValueType::size_type noValues) const
365    {
366      return(m_data.archiveData(archiveFile, noValues));
367    }
368    
369    int
370    DataExpanded::extractData(ifstream& archiveFile,
371                              const DataArrayView::ValueType::size_type noValues)
372    {
373      return(m_data.extractData(archiveFile, noValues));
374    }
375    
376    void
377    DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value) {
378      //
379      // Get the number of samples and data-points per sample.
380      int numSamples = getNumSamples();
381      int numDataPointsPerSample = getNumDPPSample();
382      int dataPointRank = getPointDataView().getRank();
383      ShapeType dataPointShape = getPointDataView().getShape();
384      //
385      // check rank:
386      if (value.getrank()!=dataPointRank)
387           throw DataException("Rank of numarray does not match Data object rank");
388      if (numSamples*numDataPointsPerSample > 0) {
389         //TODO: global error handling
390         if (sampleNo >= numSamples or sampleNo < 0 ) {
391              throw DataException("Error - DataExpanded::copyDataPoint invalid sampleNo.");
392         }
393         if (dataPointNo >= numDataPointsPerSample or dataPointNo < 0) {
394               throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
395         }
396         DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
397         if (dataPointRank==0) {
398             dataPointView()=extract<double>(value[0]);
399         } else if (dataPointRank==1) {
400            for (int i=0; i<dataPointShape[0]; i++) {
401                dataPointView(i)=extract<double>(value[i]);
402            }
403         } else if (dataPointRank==2) {
404            for (int i=0; i<dataPointShape[0]; i++) {
405               for (int j=0; j<dataPointShape[1]; j++) {
406                  dataPointView(i,j)=extract<double>(value[i][j]);
407               }
408            }
409         } else if (dataPointRank==3) {
410            for (int i=0; i<dataPointShape[0]; i++) {
411               for (int j=0; j<dataPointShape[1]; j++) {
412                  for (int k=0; k<dataPointShape[2]; k++) {
413                     dataPointView(i,j,k)=extract<double>(value[i][j][k]);
414                  }
415               }
416            }
417         } else if (dataPointRank==4) {
418             for (int i=0; i<dataPointShape[0]; i++) {
419               for (int j=0; j<dataPointShape[1]; j++) {
420                 for (int k=0; k<dataPointShape[2]; k++) {
421                   for (int l=0; l<dataPointShape[3]; l++) {
422                      dataPointView(i,j,k,l)=extract<double>(value[i][j][k][l]);
423                   }
424                 }
425               }
426             }
427         }
428      }
429    }
430    void
431    DataExpanded::copyAll(const boost::python::numeric::array& value) {
432      //
433      // Get the number of samples and data-points per sample.
434      int numSamples = getNumSamples();
435      int numDataPointsPerSample = getNumDPPSample();
436      int dataPointRank = getPointDataView().getRank();
437      ShapeType dataPointShape = getPointDataView().getShape();
438      //
439      // check rank:
440      if (value.getrank()!=dataPointRank+1)
441           throw DataException("Rank of numarray does not match Data object rank");
442      if (value.getshape()[0]!=numSamples*numDataPointsPerSample)
443           throw DataException("leading dimension of numarray is too small");
444      //
445      int dataPoint = 0;
446      for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {
447        for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
448          DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
449          if (dataPointRank==0) {
450             dataPointView()=extract<double>(value[dataPoint]);
451          } else if (dataPointRank==1) {
452             for (int i=0; i<dataPointShape[0]; i++) {
453                dataPointView(i)=extract<double>(value[dataPoint][i]);
454             }
455          } else if (dataPointRank==2) {
456             for (int i=0; i<dataPointShape[0]; i++) {
457               for (int j=0; j<dataPointShape[1]; j++) {
458                 dataPointView(i,j)=extract<double>(value[dataPoint][i][j]);
459               }
460             }
461           } else if (dataPointRank==3) {
462             for (int i=0; i<dataPointShape[0]; i++) {
463               for (int j=0; j<dataPointShape[1]; j++) {
464                 for (int k=0; k<dataPointShape[2]; k++) {
465                     dataPointView(i,j,k)=extract<double>(value[dataPoint][i][j][k]);
466                 }
467               }
468             }
469           } else if (dataPointRank==4) {
470             for (int i=0; i<dataPointShape[0]; i++) {
471               for (int j=0; j<dataPointShape[1]; j++) {
472                 for (int k=0; k<dataPointShape[2]; k++) {
473                   for (int l=0; l<dataPointShape[3]; l++) {
474                     dataPointView(i,j,k,l)=extract<double>(value[dataPoint][i][j][k][l]);
475                   }
476                 }
477               }
478             }
479          }
480          dataPoint++;
481        }
482      }
483    }
484    void
485    DataExpanded::symmetric(DataAbstract* ev)
486    {
487      int sampleNo,dataPointNo;
488      int numSamples = getNumSamples();
489      int numDataPointsPerSample = getNumDPPSample();
490      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
491      if (temp_ev==0) {
492        throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
493      }
494      DataArrayView& thisView=getPointDataView();
495      DataArrayView& evView=ev->getPointDataView();
496      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
497      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
498        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
499             DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),
500                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
501        }
502      }
503    }
504    void
505    DataExpanded::nonsymmetric(DataAbstract* ev)
506    {
507      int sampleNo,dataPointNo;
508      int numSamples = getNumSamples();
509      int numDataPointsPerSample = getNumDPPSample();
510      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
511      if (temp_ev==0) {
512        throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
513      }
514      DataArrayView& thisView=getPointDataView();
515      DataArrayView& evView=ev->getPointDataView();
516      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
517      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
518        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
519             DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
520                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
521        }
522      }
523    }
524    void
525    DataExpanded::trace(DataAbstract* ev, int axis_offset)
526    {
527      int sampleNo,dataPointNo;
528      int numSamples = getNumSamples();
529      int numDataPointsPerSample = getNumDPPSample();
530      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
531      if (temp_ev==0) {
532        throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");
533      }
534      DataArrayView& thisView=getPointDataView();
535      DataArrayView& evView=ev->getPointDataView();
536      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
537      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
538        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
539             DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),
540                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
541        }
542      }
543    }
544    
545    void
546    DataExpanded::transpose(DataAbstract* ev, int axis_offset)
547    {
548      int sampleNo,dataPointNo;
549      int numSamples = getNumSamples();
550      int numDataPointsPerSample = getNumDPPSample();
551      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
552      if (temp_ev==0) {
553        throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
554      }
555      DataArrayView& thisView=getPointDataView();
556      DataArrayView& evView=ev->getPointDataView();
557      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
558      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
559        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
560             DataArrayView::transpose(thisView,getPointOffset(sampleNo,dataPointNo),
561                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
562        }
563      }
564    }
565    
566    void
567    DataExpanded::swapaxes(DataAbstract* ev, int axis0, int axis1)
568    {
569      int sampleNo,dataPointNo;
570      int numSamples = getNumSamples();
571      int numDataPointsPerSample = getNumDPPSample();
572      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
573      if (temp_ev==0) {
574        throw DataException("Error - DataExpanded::swapaxes: casting to DataExpanded failed (propably a programming error).");
575      }
576      DataArrayView& thisView=getPointDataView();
577      DataArrayView& evView=ev->getPointDataView();
578      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
579      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
580        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
581             DataArrayView::swapaxes(thisView,getPointOffset(sampleNo,dataPointNo),
582                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis0,axis1);
583        }
584      }
585    }
586    void
587    DataExpanded::eigenvalues(DataAbstract* ev)
588    {
589      int sampleNo,dataPointNo;
590      int numSamples = getNumSamples();
591      int numDataPointsPerSample = getNumDPPSample();
592      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
593      if (temp_ev==0) {
594        throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");
595      }
596      DataArrayView& thisView=getPointDataView();
597      DataArrayView& evView=ev->getPointDataView();
598      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
599      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
600        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
601             DataArrayView::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),
602                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
603        }
604      }
605    }
606    void
607    DataExpanded::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
608    {
609      int numSamples = getNumSamples();
610      int numDataPointsPerSample = getNumDPPSample();
611      int sampleNo,dataPointNo;
612      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
613      if (temp_ev==0) {
614        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
615      }
616      DataExpanded* temp_V=dynamic_cast<DataExpanded*>(V);
617      if (temp_V==0) {
618        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
619      }
620      DataArrayView& thisView=getPointDataView();
621      DataArrayView& evView=ev->getPointDataView();
622      DataArrayView& VView=V->getPointDataView();
623      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
624      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
625        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
626             DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),
627                                                         evView,ev->getPointOffset(sampleNo,dataPointNo),
628                                                         VView,V->getPointOffset(sampleNo,dataPointNo),
629                                                         tol);
630        }
631      }
632  }  }
633    
634  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.97  
changed lines
  Added in v.921

  ViewVC Help
Powered by ViewVC 1.1.26