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

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

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

revision 615 by elspeth, Wed Mar 22 02:12:00 2006 UTC revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC
# Line 154  DataExpanded::~DataExpanded() Line 154  DataExpanded::~DataExpanded()
154  {  {
155  }  }
156    
 void  
 DataExpanded::reshapeDataPoint(const DataArrayView::ShapeType& shape)  
 {  
   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);  
 }  
   
157  DataAbstract*  DataAbstract*
158  DataExpanded::getSlice(const DataArrayView::RegionType& region) const  DataExpanded::getSlice(const DataArrayView::RegionType& region) const
159  {  {
# Line 213  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 462  DataExpanded::copyAll(const boost::pytho Line 426  DataExpanded::copyAll(const boost::pytho
426      }      }
427    }    }
428  }  }
429    void
430    DataExpanded::symmetric(DataAbstract* ev)
431    {
432      int sampleNo,dataPointNo;
433      int numSamples = getNumSamples();
434      int numDataPointsPerSample = getNumDPPSample();
435      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
436      if (temp_ev==0) {
437        throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
438      }
439      DataArrayView& thisView=getPointDataView();
440      DataArrayView& evView=ev->getPointDataView();
441      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
442      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
443        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
444             DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),
445                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
446        }
447      }
448    }
449    void
450    DataExpanded::nonsymmetric(DataAbstract* ev)
451    {
452      int sampleNo,dataPointNo;
453      int numSamples = getNumSamples();
454      int numDataPointsPerSample = getNumDPPSample();
455      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
456      if (temp_ev==0) {
457        throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
458      }
459      DataArrayView& thisView=getPointDataView();
460      DataArrayView& evView=ev->getPointDataView();
461      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
462      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
463        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
464             DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
465                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
466        }
467      }
468    }
469    void
470    DataExpanded::trace(DataAbstract* ev, int axis_offset)
471    {
472      int sampleNo,dataPointNo;
473      int numSamples = getNumSamples();
474      int numDataPointsPerSample = getNumDPPSample();
475      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
476      if (temp_ev==0) {
477        throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");
478      }
479      DataArrayView& thisView=getPointDataView();
480      DataArrayView& evView=ev->getPointDataView();
481      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
482      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
483        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
484             DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),
485                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
486        }
487      }
488    }
489    
490    void
491    DataExpanded::transpose(DataAbstract* ev, int axis_offset)
492    {
493      int sampleNo,dataPointNo;
494      int numSamples = getNumSamples();
495      int numDataPointsPerSample = getNumDPPSample();
496      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
497      if (temp_ev==0) {
498        throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
499      }
500      DataArrayView& thisView=getPointDataView();
501      DataArrayView& evView=ev->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::transpose(thisView,getPointOffset(sampleNo,dataPointNo),
506                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
507        }
508      }
509    }
510    
511    void
512    DataExpanded::swapaxes(DataAbstract* ev, int axis0, int axis1)
513    {
514      int sampleNo,dataPointNo;
515      int numSamples = getNumSamples();
516      int numDataPointsPerSample = getNumDPPSample();
517      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
518      if (temp_ev==0) {
519        throw DataException("Error - DataExpanded::swapaxes: casting to DataExpanded failed (propably a programming error).");
520      }
521      DataArrayView& thisView=getPointDataView();
522      DataArrayView& evView=ev->getPointDataView();
523      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
524      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
525        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
526             DataArrayView::swapaxes(thisView,getPointOffset(sampleNo,dataPointNo),
527                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis0,axis1);
528        }
529      }
530    }
531  void  void
532  DataExpanded::eigenvalues(DataAbstract* ev)  DataExpanded::eigenvalues(DataAbstract* ev)
533  {  {

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

  ViewVC Help
Powered by ViewVC 1.1.26