/[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/escript/src/Data/DataExpanded.cpp revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/escript/src/DataExpanded.cpp revision 775 by ksteube, Mon Jul 10 04:00:08 2006 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 148  DataExpanded::DataExpanded(const Functio Line 143  DataExpanded::DataExpanded(const Functio
143    : DataAbstract(what)    : 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    // copy the data in the correct format
150    m_data.getData()=data;    m_data.getData()=data;
   //  
   // create the view of the data  
   DataArrayView tempView(m_data.getData(),shape);  
   setPointDataView(tempView);  
151  }  }
152    
153  DataExpanded::~DataExpanded()  DataExpanded::~DataExpanded()
# Line 219  DataExpanded::setSlice(const DataAbstrac Line 213  DataExpanded::setSlice(const DataAbstrac
213    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
214      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
215    }    }
216    if (tempDataExp->getPointDataView().getRank()>0 and !value->getPointDataView().checkShape(shape)) {    if (tempDataExp->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {
217      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (value->getPointDataView().createShapeErrorMessage(
218          "Error - Couldn't copy slice due to shape mismatch.",shape));          "Error - Couldn't copy slice due to shape mismatch.",shape));
219    }    }
# Line 468  DataExpanded::copyAll(const boost::pytho Line 462  DataExpanded::copyAll(const boost::pytho
462      }      }
463    }    }
464  }  }
465    void
466    DataExpanded::symmetric(DataAbstract* ev)
467    {
468      int sampleNo,dataPointNo;
469      int numSamples = getNumSamples();
470      int numDataPointsPerSample = getNumDPPSample();
471      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
472      if (temp_ev==0) {
473        throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
474      }
475      DataArrayView& thisView=getPointDataView();
476      DataArrayView& evView=ev->getPointDataView();
477      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
478      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
479        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
480             DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),
481                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
482        }
483      }
484    }
485    void
486    DataExpanded::nonsymmetric(DataAbstract* ev)
487    {
488      int sampleNo,dataPointNo;
489      int numSamples = getNumSamples();
490      int numDataPointsPerSample = getNumDPPSample();
491      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
492      if (temp_ev==0) {
493        throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
494      }
495      DataArrayView& thisView=getPointDataView();
496      DataArrayView& evView=ev->getPointDataView();
497      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
498      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
499        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
500             DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
501                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
502        }
503      }
504    }
505    void
506    DataExpanded::matrixtrace(DataAbstract* ev, int axis_offset)
507    {
508      int sampleNo,dataPointNo;
509      int numSamples = getNumSamples();
510      int numDataPointsPerSample = getNumDPPSample();
511      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
512      if (temp_ev==0) {
513        throw DataException("Error - DataExpanded::matrixtrace: casting to DataExpanded failed (propably a programming error).");
514      }
515      DataArrayView& thisView=getPointDataView();
516      DataArrayView& evView=ev->getPointDataView();
517      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
518      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
519        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
520             DataArrayView::matrixtrace(thisView,getPointOffset(sampleNo,dataPointNo),
521                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
522        }
523      }
524    }
525    void
526    DataExpanded::transpose(DataAbstract* ev, int axis_offset)
527    {
528      int sampleNo,dataPointNo;
529      int numSamples = getNumSamples();
530      int numDataPointsPerSample = getNumDPPSample();
531      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
532      if (temp_ev==0) {
533        throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
534      }
535      DataArrayView& thisView=getPointDataView();
536      DataArrayView& evView=ev->getPointDataView();
537      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
538      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
539        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
540             DataArrayView::transpose(thisView,getPointOffset(sampleNo,dataPointNo),
541                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
542        }
543      }
544    }
545    void
546    DataExpanded::eigenvalues(DataAbstract* ev)
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::eigenvalues: 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::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),
561                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
562        }
563      }
564    }
565    void
566    DataExpanded::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
567    {
568      int numSamples = getNumSamples();
569      int numDataPointsPerSample = getNumDPPSample();
570      int sampleNo,dataPointNo;
571      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
572      if (temp_ev==0) {
573        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
574      }
575      DataExpanded* temp_V=dynamic_cast<DataExpanded*>(V);
576      if (temp_V==0) {
577        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
578      }
579      DataArrayView& thisView=getPointDataView();
580      DataArrayView& evView=ev->getPointDataView();
581      DataArrayView& VView=V->getPointDataView();
582      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
583      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
584        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
585             DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),
586                                                         evView,ev->getPointOffset(sampleNo,dataPointNo),
587                                                         VView,V->getPointOffset(sampleNo,dataPointNo),
588                                                         tol);
589        }
590      }
591    }
592    
593  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.155  
changed lines
  Added in v.775

  ViewVC Help
Powered by ViewVC 1.1.26