/[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 921 by gross, Fri Jan 5 00:54:37 2007 UTC revision 922 by gross, Fri Jan 5 04:23:05 2007 UTC
# Line 374  DataExpanded::extractData(ifstream& arch Line 374  DataExpanded::extractData(ifstream& arch
374  }  }
375    
376  void  void
377    DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const double 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      if (numSamples*numDataPointsPerSample > 0) {
385         //TODO: global error handling
386         if (sampleNo >= numSamples or sampleNo < 0 ) {
387              throw DataException("Error - DataExpanded::copyDataPoint invalid sampleNo.");
388         }
389         if (dataPointNo >= numDataPointsPerSample or dataPointNo < 0) {
390               throw DataException("Error - DataExpanded::copyDataPoint invalid dataPointNoInSample.");
391         }
392         DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
393         if (dataPointRank==0) {
394             dataPointView()=value;
395         } else if (dataPointRank==1) {
396            for (int i=0; i<dataPointShape[0]; i++) {
397                dataPointView(i)=value;
398            }
399         } else if (dataPointRank==2) {
400            for (int i=0; i<dataPointShape[0]; i++) {
401               for (int j=0; j<dataPointShape[1]; j++) {
402                  dataPointView(i,j)=value;
403               }
404            }
405         } else if (dataPointRank==3) {
406            for (int i=0; i<dataPointShape[0]; i++) {
407               for (int j=0; j<dataPointShape[1]; j++) {
408                  for (int k=0; k<dataPointShape[2]; k++) {
409                     dataPointView(i,j,k)=value;
410                  }
411               }
412            }
413         } else if (dataPointRank==4) {
414             for (int i=0; i<dataPointShape[0]; i++) {
415               for (int j=0; j<dataPointShape[1]; j++) {
416                 for (int k=0; k<dataPointShape[2]; k++) {
417                   for (int l=0; l<dataPointShape[3]; l++) {
418                      dataPointView(i,j,k,l)=value;
419                   }
420                 }
421               }
422             }
423         }
424      }
425    }
426    void
427  DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value) {  DataExpanded::copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value) {
428    //    //
429    // Get the number of samples and data-points per sample.    // Get the number of samples and data-points per sample.

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

  ViewVC Help
Powered by ViewVC 1.1.26