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

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

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

revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC revision 126 by jgs, Fri Jul 22 03:53:08 2005 UTC
# Line 359  DataExpanded::setRefValue(int ref, Line 359  DataExpanded::setRefValue(int ref,
359    
360    for (int n=0; n<numDPPSample; n++) {    for (int n=0; n<numDPPSample; n++) {
361      //      //
362      // Get each data-point in the sample in turn.      // Get *each* data-point in the sample in turn.
363      DataArrayView pointView = getDataPoint(sampleNo, n);      DataArrayView pointView = getDataPoint(sampleNo, n);
364      //      //
365      // Assign the values in the DataArray to this data-point.      // Assign the values in the DataArray to this data-point.
# Line 392  DataExpanded::getRefValue(int ref, Line 392  DataExpanded::getRefValue(int ref,
392    }    }
393    
394    //    //
395    // Get the first data-point associated with this sample number.    // Get the *first* data-point associated with this sample number.
396    DataArrayView pointView = getDataPoint(sampleNo, 0);    DataArrayView pointView = getDataPoint(sampleNo, 0);
397    
398    //    //
# Line 414  DataExpanded::extractData(ifstream& arch Line 414  DataExpanded::extractData(ifstream& arch
414    return(m_data.extractData(archiveFile, noValues));    return(m_data.extractData(archiveFile, noValues));
415  }  }
416    
417    void
418    DataExpanded::copyAll(const boost::python::numeric::array& value) {
419      //
420      // Get the number of samples and data-points per sample.
421      int numSamples = getNumSamples();
422      int numDataPointsPerSample = getNumDPPSample();
423      int dataPointRank = getPointDataView().getRank();
424      ShapeType dataPointShape = getPointDataView().getShape();
425      //
426      // check rank:
427      if (value.getrank()!=dataPointRank+1)
428           throw DataException("Rank of numarray does not match Data object rank");
429      if (value.getshape()[0]!=numSamples*numDataPointsPerSample)
430           throw DataException("leading dimension of numarray is too small");
431      //
432      int dataPoint = 0;
433      for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {
434        for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
435          DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);
436          if (dataPointRank==0) {
437             dataPointView()=extract<double>(value[dataPoint]);
438          } else if (dataPointRank==1) {
439             for (int i=0; i<dataPointShape[0]; i++) {
440                dataPointView(i)=extract<double>(value[dataPoint][i]);
441             }
442          } else if (dataPointRank==2) {
443             for (int i=0; i<dataPointShape[0]; i++) {
444               for (int j=0; j<dataPointShape[1]; j++) {
445                 dataPointView(i,j)=extract<double>(value[dataPoint][i][j]);
446               }
447             }
448           } else if (dataPointRank==3) {
449             for (int i=0; i<dataPointShape[0]; i++) {
450               for (int j=0; j<dataPointShape[1]; j++) {
451                 for (int k=0; k<dataPointShape[2]; k++) {
452                     dataPointView(i,j,k)=extract<double>(value[dataPoint][i][j][k]);
453                 }
454               }
455             }
456           } else if (dataPointRank==4) {
457             for (int i=0; i<dataPointShape[0]; i++) {
458               for (int j=0; j<dataPointShape[1]; j++) {
459                 for (int k=0; k<dataPointShape[2]; k++) {
460                   for (int l=0; l<dataPointShape[3]; l++) {
461                     dataPointView(i,j,k,l)=extract<double>(value[dataPoint][i][j][k][l]);
462                   }
463                 }
464               }
465             }
466          }
467          dataPoint++;
468        }
469      }
470    }
471  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.123  
changed lines
  Added in v.126

  ViewVC Help
Powered by ViewVC 1.1.26