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

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

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

revision 107 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 108 by jgs, Thu Jan 27 06:21:59 2005 UTC
# Line 24  namespace escript { Line 24  namespace escript {
24    
25  DataArray::DataArray(double value)  DataArray::DataArray(double value)
26  {  {
     //  
     // The default is a scalar, an empty shape vector is interpreted  
     // as a scalar.  
27      m_data.push_back(value);      m_data.push_back(value);
28      //      // create a view with an empty shape, a scalar.
     // create a view with an empty shape type  
29      m_dataView.reset(new DataArrayView(m_data,DataArrayView::ShapeType()));      m_dataView.reset(new DataArrayView(m_data,DataArrayView::ShapeType()));
30  }  }
31    
# Line 52  DataArray::DataArray(const DataArrayView Line 48  DataArray::DataArray(const DataArrayView
48      m_dataView.reset(new DataArrayView(m_data,value.getShape()));      m_dataView.reset(new DataArrayView(m_data,value.getShape()));
49  }  }
50    
51  DataArray::DataArray(const object& value)  DataArray::DataArray(const object& value)
52  {  {
     //  
53      // this will throw if the value cannot be represented      // this will throw if the value cannot be represented
54      numeric::array asNumArray(value);      numeric::array asNumArray(value);
55      initialise(asNumArray);      initialise(asNumArray);
# Line 68  DataArray::DataArray(const boost::python Line 63  DataArray::DataArray(const boost::python
63  void  void
64  DataArray::initialise(const boost::python::numeric::array& value)  DataArray::initialise(const boost::python::numeric::array& value)
65  {  {
66      //      // extract the shape of the numarray
     // extract the shape from the numarray  
67      DataArrayView::ShapeType tempShape;        DataArrayView::ShapeType tempShape;  
68      for (int i=0; i<value.getrank(); ++i) {      for (int i=0; i<value.getrank(); i++) {
69        tempShape.push_back(extract<int>(value.getshape()[i]));        tempShape.push_back(extract<int>(value.getshape()[i]));
70      }      }
71      //      // allocate the space for the data vector
     // allocate the space  
72      m_data.resize(DataArrayView::noValues(tempShape));      m_data.resize(DataArrayView::noValues(tempShape));
73        // create a view with the same shape
74      m_dataView.reset(new DataArrayView(m_data,tempShape));      m_dataView.reset(new DataArrayView(m_data,tempShape));
75        // fill the data vector with the values from the numarray
76      m_dataView->copy(value);      m_dataView->copy(value);
77  }  }
78    

Legend:
Removed from v.107  
changed lines
  Added in v.108

  ViewVC Help
Powered by ViewVC 1.1.26