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

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

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

revision 148 by jgs, Tue Aug 23 01:24:31 2005 UTC revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC
# Line 481  void Line 481  void
481  Data::fillFromNumArray(const boost::python::numeric::array num_array)  Data::fillFromNumArray(const boost::python::numeric::array num_array)
482  {  {
483    //    //
484    // check rank:    // check rank
485    if (num_array.getrank()<getDataPointRank())    if (num_array.getrank()<getDataPointRank())
486        throw DataException("Rank of numarray does not match Data object rank");        throw DataException("Rank of numarray does not match Data object rank");
487    
488    //    //
489    // check rank of num_array    // check shape of num_array
490    for (int i=0; i<getDataPointRank(); i++) {    for (int i=0; i<getDataPointRank(); i++) {
491      if (extract<int>(num_array.getshape()[i+1])!=getDataPointShape()[i])      if (extract<int>(num_array.getshape()[i+1])!=getDataPointShape()[i])
492         throw DataException("Shape of numarray does not match Data object rank");         throw DataException("Shape of numarray does not match Data object rank");
493    }    }
   //  
   // make sure data is expanded:  
   if (! isExpanded()) expand();  
   //  
   // and copy over:  
   m_data->copyAll(num_array);  
   //  
   // the rank of the returned numeric array will be the rank of  
   // the data points, plus one. Where the rank of the array is n,  
   // the last n-1 dimensions will be equal to the shape of the  
   // data points, whilst the first dimension will be equal to the  
   // total number of data points. Thus the array will consist of  
   // a serial vector of the data points.  
   // int arrayRank = dataPointRank + 1;  
   // DataArrayView::ShapeType arrayShape;  
   // arrayShape.push_back(numDataPoints);  
   // for (int d=0; d<dataPointRank; d++) {  
   //    arrayShape.push_back(dataPointShape[d]);  
   // }  
494    
495    //    //
496    // resize the numeric array to the shape just calculated    // make sure data is expanded:
497    // if (arrayRank==1) {    if (!isExpanded()) {
498    //   numArray.resize(arrayShape[0]);      expand();
499    // }    }
   // if (arrayRank==2) {  
   //   numArray.resize(arrayShape[0],arrayShape[1]);  
   // }  
   // if (arrayRank==3) {  
   //   numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2]);  
   // }  
   // if (arrayRank==4) {  
   //   numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2],arrayShape[3]);  
   // }  
   // if (arrayRank==5) {  
   //   numArray.resize(arrayShape[0],arrayShape[1],arrayShape[2],arrayShape[3],arrayShape[4]);  
   // }  
   
   //  
   // loop through each data point in turn, loading the values for that data point  
   // into the numeric array.  
   // int dataPoint = 0;  
   // for (int sampleNo = 0; sampleNo < numSamples; sampleNo++) {  
   //   for (int dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {  
   //     DataArrayView dataPointView = getDataPoint(sampleNo, dataPointNo);  
   //     if (dataPointRank==0) {  
   //       dataPointView()=numArray[dataPoint];  
   //     }  
   //     if (dataPointRank==1) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         dataPointView(i)=numArray[dataPoint][i];  
   //       }  
   //     }  
   //     if (dataPointRank==2) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         for (int j=0; j<dataPointShape[1]; j++) {  
   //           numArray[dataPoint][i][j] = dataPointView(i,j);  
   //         }  
   //       }  
   //     }  
   //     if (dataPointRank==3) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         for (int j=0; j<dataPointShape[1]; j++) {  
   //           for (int k=0; k<dataPointShape[2]; k++) {  
   //             numArray[dataPoint][i][j][k]=dataPointView(i,j,k);  
   //           }  
   //         }  
   //       }  
   //     }  
   //     if (dataPointRank==4) {  
   //       for (int i=0; i<dataPointShape[0]; i++) {  
   //         for (int j=0; j<dataPointShape[1]; j++) {  
   //           for (int k=0; k<dataPointShape[2]; k++) {  
   //             for (int l=0; l<dataPointShape[3]; l++) {  
   //               numArray[dataPoint][i][j][k][l]=dataPointView(i,j,k,l);  
   //             }  
   //           }  
   //         }  
   //       }  
   //     }  
   //     dataPoint++;  
   //   }  
   // }  
500    
501    //    //
502    // return the loaded array    // and copy over
503    // return numArray;    m_data->copyAll(num_array);
   
504  }  }
505    
506  const  const
# Line 1603  Data::setTaggedValueFromCPP(int tagKey, Line 1526  Data::setTaggedValueFromCPP(int tagKey,
1526    m_data->setTaggedValue(tagKey,value);    m_data->setTaggedValue(tagKey,value);
1527  }  }
1528    
1529    int
1530    Data::getTagNumber(int dpno)
1531    {
1532      return m_data->getTagNumber(dpno);
1533    }
1534    
1535  void  void
1536  Data::setRefValue(int ref,  Data::setRefValue(int ref,
1537                    const boost::python::numeric::array& value)                    const boost::python::numeric::array& value)

Legend:
Removed from v.148  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.26