/[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 117 by jgs, Fri Apr 1 05:48:57 2005 UTC trunk/escript/src/DataExpanded.cpp revision 966 by gross, Tue Feb 13 05:45:18 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 72  DataExpanded::DataExpanded(const DataTag Line 67  DataExpanded::DataExpanded(const DataTag
67    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace())
68  {  {
69    //    //
70    // initialise the data for this object    // 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    // for each data point in this object, extract and copy the corresponding data
# Line 80  DataExpanded::DataExpanded(const DataTag Line 75  DataExpanded::DataExpanded(const DataTag
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 109  DataExpanded::DataExpanded(const DataExp Line 106  DataExpanded::DataExpanded(const DataExp
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_loop_range);          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 137  DataExpanded::DataExpanded(const DataArr Line 137  DataExpanded::DataExpanded(const DataArr
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  {  {
   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());  
   }  
   //  
   // create the new DataBlocks2D data array, and a corresponding DataArrayView  
   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++) {  
       // 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(i,j));  
     }  
   }  
   // swap the new data array for the original  
   m_data.Swap(newData);  
   // set the corresponding DataArrayView  
   DataArrayView temp(m_data.getData(),shape);  
   setPointDataView(temp);  
155  }  }
156    
157  DataAbstract*  DataAbstract*
# Line 200  DataExpanded::setSlice(const DataAbstrac Line 177  DataExpanded::setSlice(const DataAbstrac
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 (tempDataExp->getPointDataView().getRank()>0 and !value->getPointDataView().checkShape(shape)) {    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.",shape));          "Error - Couldn't copy slice due to shape mismatch.",shape));
183    }    }
# Line 209  DataExpanded::setSlice(const DataAbstrac Line 186  DataExpanded::setSlice(const DataAbstrac
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_loop_range);        getPointDataView().copySliceFrom(getPointOffset(i,j),
193                                           tempDataExp->getPointDataView(),
194                                           tempDataExp->getPointOffset(i,j),
195                                           region_loop_range);
196      }      }
197    }    }
198  }  }
# Line 225  DataExpanded::copy(const DataArrayView& Line 205  DataExpanded::copy(const DataArrayView&
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++) {
211        // NOTE: An exception may be thown from this call if        // NOTE: An exception may be thown from this call if
# Line 273  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());
# Line 280  DataExpanded::toString() const Line 261  DataExpanded::toString() const
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.getReferenceIDOfSample(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 311  DataExpanded::getLength() const Line 292  DataExpanded::getLength() const
292    return m_data.size();    return m_data.size();
293  }  }
294    
295  void  int
296  DataExpanded::setRefValue(int ref,  DataExpanded::archiveData(ofstream& archiveFile,
297                            const DataArray& value)                            const DataArrayView::ValueType::size_type noValues) const
298    {
299      return(m_data.archiveData(archiveFile, noValues));
300    }
301    
302    int
303    DataExpanded::extractData(ifstream& archiveFile,
304                              const DataArrayView::ValueType::size_type noValues)
305  {  {
306      return(m_data.extractData(archiveFile, noValues));
307    }
308    
309    void
310    DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const double value) {
311    //    //
312    // Get the number of samples and data-points per sample.    // Get the number of samples and data-points per sample.
313    int numSamples = getNumSamples();    int numSamples = getNumSamples();
314    int numDPPSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
315      int dataPointRank = getPointDataView().getRank();
316      ShapeType dataPointShape = getPointDataView().getShape();
317      if (numSamples*numDataPointsPerSample > 0) {
318         //TODO: global error handling
319         if ((sampleNo >= numSamples) || (sampleNo < 0 )) {
320              throw DataException("Error - DataExpanded::copyDataPoint invalid sampleNo.");
321         }
322         if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {
323               throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
324         }
325         DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
326         if (dataPointRank==0) {
327             dataPointView()=value;
328         } else if (dataPointRank==1) {
329            for (int i=0; i<dataPointShape[0]; i++) {
330                dataPointView(i)=value;
331            }
332         } else if (dataPointRank==2) {
333            for (int i=0; i<dataPointShape[0]; i++) {
334               for (int j=0; j<dataPointShape[1]; j++) {
335                  dataPointView(i,j)=value;
336               }
337            }
338         } else if (dataPointRank==3) {
339            for (int i=0; i<dataPointShape[0]; i++) {
340               for (int j=0; j<dataPointShape[1]; j++) {
341                  for (int k=0; k<dataPointShape[2]; k++) {
342                     dataPointView(i,j,k)=value;
343                  }
344               }
345            }
346         } else if (dataPointRank==4) {
347             for (int i=0; i<dataPointShape[0]; i++) {
348               for (int j=0; j<dataPointShape[1]; j++) {
349                 for (int k=0; k<dataPointShape[2]; k++) {
350                   for (int l=0; l<dataPointShape[3]; l++) {
351                      dataPointView(i,j,k,l)=value;
352                   }
353                 }
354               }
355             }
356         }
357      }
358    }
359    void
360    DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value) {
361    //    //
362    // Determine the sample number which corresponds to this reference number.    // Get the number of samples and data-points per sample.
363    int sampleNo = -1;    int numSamples = getNumSamples();
364    int tempRef = -1;    int numDataPointsPerSample = getNumDPPSample();
365    for (int n=0; n<numSamples; n++) {    int dataPointRank = getPointDataView().getRank();
366      tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);    ShapeType dataPointShape = getPointDataView().getShape();
367      if (tempRef == ref) {    //
368        sampleNo = n;    // check rank:
369        break;    if (value.getrank()!=dataPointRank)
370           throw DataException("Rank of numarray does not match Data object rank");
371      if (numSamples*numDataPointsPerSample > 0) {
372         //TODO: global error handling
373         if ((sampleNo >= numSamples) || (sampleNo < 0 )) {
374              throw DataException("Error - DataExpanded::copyDataPoint invalid sampleNo.");
375         }
376         if ((dataPointNo >= numDataPointsPerSample) || (dataPointNo < 0)) {
377               throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
378         }
379         DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
380         if (dataPointRank==0) {
381             dataPointView()=extract<double>(value[0]);
382         } else if (dataPointRank==1) {
383            for (int i=0; i<dataPointShape[0]; i++) {
384                dataPointView(i)=extract<double>(value[i]);
385            }
386         } else if (dataPointRank==2) {
387            for (int i=0; i<dataPointShape[0]; i++) {
388               for (int j=0; j<dataPointShape[1]; j++) {
389                  dataPointView(i,j)=extract<double>(value[i][j]);
390               }
391            }
392         } else if (dataPointRank==3) {
393            for (int i=0; i<dataPointShape[0]; i++) {
394               for (int j=0; j<dataPointShape[1]; j++) {
395                  for (int k=0; k<dataPointShape[2]; k++) {
396                     dataPointView(i,j,k)=extract<double>(value[i][j][k]);
397                  }
398               }
399            }
400         } else if (dataPointRank==4) {
401             for (int i=0; i<dataPointShape[0]; i++) {
402               for (int j=0; j<dataPointShape[1]; j++) {
403                 for (int k=0; k<dataPointShape[2]; k++) {
404                   for (int l=0; l<dataPointShape[3]; l++) {
405                      dataPointView(i,j,k,l)=extract<double>(value[i][j][k][l]);
406                   }
407                 }
408               }
409             }
410         }
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        }
465      }
466    }
467    void
468    DataExpanded::symmetric(DataAbstract* ev)
469    {
470      int sampleNo,dataPointNo;
471      int numSamples = getNumSamples();
472      int numDataPointsPerSample = getNumDPPSample();
473      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
474      if (temp_ev==0) {
475        throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
476      }
477      DataArrayView& thisView=getPointDataView();
478      DataArrayView& evView=ev->getPointDataView();
479      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
480      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
481        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
482             DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),
483                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
484      }      }
485    }    }
486    if (sampleNo == -1) {  }
487      throw DataException("DataExpanded::setRefValue error: invalid ref number supplied.");  void
488    DataExpanded::nonsymmetric(DataAbstract* ev)
489    {
490      int sampleNo,dataPointNo;
491      int numSamples = getNumSamples();
492      int numDataPointsPerSample = getNumDPPSample();
493      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
494      if (temp_ev==0) {
495        throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
496      }
497      DataArrayView& thisView=getPointDataView();
498      DataArrayView& evView=ev->getPointDataView();
499      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
500      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
501        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
502             DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
503                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
504        }
505    }    }
506    }
507    for (int n=0; n<numDPPSample; n++) {  void
508      //  DataExpanded::trace(DataAbstract* ev, int axis_offset)
509      // Get each data-point in the sample in turn.  {
510      DataArrayView pointView = getDataPoint(sampleNo, n);    int sampleNo,dataPointNo;
511      //    int numSamples = getNumSamples();
512      // Assign the values in the DataArray to this data-point.    int numDataPointsPerSample = getNumDPPSample();
513      pointView.copy(value.getView());    DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
514      if (temp_ev==0) {
515        throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");
516      }
517      DataArrayView& thisView=getPointDataView();
518      DataArrayView& evView=ev->getPointDataView();
519      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
520      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
521        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
522             DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),
523                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
524        }
525    }    }
526  }  }
527    
528  void  void
529  DataExpanded::getRefValue(int ref,  DataExpanded::transpose(DataAbstract* ev, int axis_offset)
                           DataArray& value)  
530  {  {
531    //    int sampleNo,dataPointNo;
   // Get the number of samples and data-points per sample.  
532    int numSamples = getNumSamples();    int numSamples = getNumSamples();
533    int numDPPSample = getNumDPPSample();    int numDataPointsPerSample = getNumDPPSample();
534      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
535      if (temp_ev==0) {
536        throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
537      }
538      DataArrayView& thisView=getPointDataView();
539      DataArrayView& evView=ev->getPointDataView();
540      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
541      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
542        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
543             DataArrayView::transpose(thisView,getPointOffset(sampleNo,dataPointNo),
544                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
545        }
546      }
547    }
548    
549    //  void
550    // Determine the sample number which corresponds to this reference number  DataExpanded::swapaxes(DataAbstract* ev, int axis0, int axis1)
551    int sampleNo = -1;  {
552    int tempRef = -1;    int sampleNo,dataPointNo;
553    for (int n=0; n<numSamples; n++) {    int numSamples = getNumSamples();
554      tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);    int numDataPointsPerSample = getNumDPPSample();
555      if (tempRef == ref) {    DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
556        sampleNo = n;    if (temp_ev==0) {
557        break;      throw DataException("Error - DataExpanded::swapaxes: casting to DataExpanded failed (propably a programming error).");
558      }
559      DataArrayView& thisView=getPointDataView();
560      DataArrayView& evView=ev->getPointDataView();
561      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
562      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
563        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
564             DataArrayView::swapaxes(thisView,getPointOffset(sampleNo,dataPointNo),
565                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis0,axis1);
566      }      }
567    }    }
568    if (sampleNo == -1) {  }
569      throw DataException("DataExpanded::getRefValue error: invalid ref number supplied.");  void
570    DataExpanded::eigenvalues(DataAbstract* ev)
571    {
572      int sampleNo,dataPointNo;
573      int numSamples = getNumSamples();
574      int numDataPointsPerSample = getNumDPPSample();
575      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
576      if (temp_ev==0) {
577        throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");
578      }
579      DataArrayView& thisView=getPointDataView();
580      DataArrayView& evView=ev->getPointDataView();
581      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
582      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
583        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
584             DataArrayView::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),
585                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
586        }
587    }    }
588    }
589    void
590    DataExpanded::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
591    {
592      int numSamples = getNumSamples();
593      int numDataPointsPerSample = getNumDPPSample();
594      int sampleNo,dataPointNo;
595      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
596      if (temp_ev==0) {
597        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
598      }
599      DataExpanded* temp_V=dynamic_cast<DataExpanded*>(V);
600      if (temp_V==0) {
601        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
602      }
603      DataArrayView& thisView=getPointDataView();
604      DataArrayView& evView=ev->getPointDataView();
605      DataArrayView& VView=V->getPointDataView();
606      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
607      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
608        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
609             DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),
610                                                         evView,ev->getPointOffset(sampleNo,dataPointNo),
611                                                         VView,V->getPointOffset(sampleNo,dataPointNo),
612                                                         tol);
613        }
614      }
615    }
616    
617    //  void
618    // Get the first data-point associated with this sample number.  DataExpanded::dump(const std::string fileName) const
619    DataArrayView pointView = getDataPoint(sampleNo, 0);  {
620    
621    //     throw DataException("Error - DataExpanded:: dump is not implemented yet.");
   // Load the values from this data-point into the DataArray  
   value.getView().copy(pointView);  
622  }  }
623    
624    
625    
626  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.117  
changed lines
  Added in v.966

  ViewVC Help
Powered by ViewVC 1.1.26