/[escript]/branches/schroedinger/escript/src/Data.h
ViewVC logotype

Diff of /branches/schroedinger/escript/src/Data.h

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

revision 698 by gross, Fri Mar 31 04:52:55 2006 UTC revision 1118 by gross, Tue Apr 24 08:55:04 2007 UTC
# Line 15  Line 15 
15    
16  #ifndef DATA_H  #ifndef DATA_H
17  #define DATA_H  #define DATA_H
18    #include "system_dep.h"
19    
20  #include "DataAbstract.h"  #include "DataAbstract.h"
21  #include "DataAlgorithm.h"  #include "DataAlgorithm.h"
# Line 25  Line 26 
26    
27  extern "C" {  extern "C" {
28  #include "DataC.h"  #include "DataC.h"
29    #include "paso/Paso.h"
30  }  }
31    
32    #ifndef PASO_MPI
33    #define MPI_Comm long
34    #endif
35    
36  #include <string>  #include <string>
37  #include <algorithm>  #include <algorithm>
38    
# Line 64  class Data { Line 70  class Data {
70    typedef double (*UnaryDFunPtr)(double);    typedef double (*UnaryDFunPtr)(double);
71    typedef double (*BinaryDFunPtr)(double,double);    typedef double (*BinaryDFunPtr)(double,double);
72    
73    
74    /**    /**
75       Constructors.       Constructors.
76    */    */
# Line 73  class Data { Line 80  class Data {
80       Default constructor.       Default constructor.
81       Creates a DataEmpty object.       Creates a DataEmpty object.
82    */    */
83      ESCRIPT_DLL_API
84    Data();    Data();
85    
86    /**    /**
# Line 80  class Data { Line 88  class Data {
88       Copy constructor.       Copy constructor.
89       WARNING: Only performs a shallow copy.       WARNING: Only performs a shallow copy.
90    */    */
91      ESCRIPT_DLL_API
92    Data(const Data& inData);    Data(const Data& inData);
93    
94    /**    /**
# Line 88  class Data { Line 97  class Data {
97       function space of inData the inData are tried to be interpolated to what,       function space of inData the inData are tried to be interpolated to what,
98       otherwise a shallow copy of inData is returned.       otherwise a shallow copy of inData is returned.
99    */    */
100      ESCRIPT_DLL_API
101    Data(const Data& inData,    Data(const Data& inData,
102         const FunctionSpace& what);         const FunctionSpace& what);
103    
# Line 101  class Data { Line 111  class Data {
111                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
112                         mechanism will be used.                         mechanism will be used.
113    */    */
114      ESCRIPT_DLL_API
115    Data(const DataArrayView& value,    Data(const DataArrayView& value,
116         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
117         bool expanded=false);         bool expanded=false);
# Line 116  class Data { Line 127  class Data {
127                         the given value. Otherwise a more efficient storage                         the given value. Otherwise a more efficient storage
128                         mechanism will be used.                         mechanism will be used.
129    */    */
130      ESCRIPT_DLL_API
131    Data(double value,    Data(double value,
132         const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(),         const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(),
133         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
# Line 128  class Data { Line 140  class Data {
140       \param inData - Input - Input Data object.       \param inData - Input - Input Data object.
141       \param region - Input - Region to copy.       \param region - Input - Region to copy.
142    */    */
143      ESCRIPT_DLL_API
144    Data(const Data& inData,    Data(const Data& inData,
145         const DataArrayView::RegionType& region);         const DataArrayView::RegionType& region);
146    
# Line 145  class Data { Line 158  class Data {
158                         the appropriate values.                         the appropriate values.
159      ==>*      ==>*
160    */    */
161      ESCRIPT_DLL_API
162    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
163         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
164         const DataArrayView& defaultValue,         const DataArrayView& defaultValue,
# Line 161  class Data { Line 175  class Data {
175                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
176                         mechanism will be used.                         mechanism will be used.
177    */    */
178      ESCRIPT_DLL_API
179    Data(const boost::python::numeric::array& value,    Data(const boost::python::numeric::array& value,
180         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
181         bool expanded=false);         bool expanded=false);
# Line 176  class Data { Line 191  class Data {
191                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
192                         mechanism will be used.                         mechanism will be used.
193    */    */
194      ESCRIPT_DLL_API
195    Data(const boost::python::object& value,    Data(const boost::python::object& value,
196         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
197         bool expanded=false);         bool expanded=false);
# Line 189  class Data { Line 205  class Data {
205       \param value - Input - Input data.       \param value - Input - Input data.
206       \param other - Input - contains all other parameters.       \param other - Input - contains all other parameters.
207    */    */
208      ESCRIPT_DLL_API
209    Data(const boost::python::object& value,    Data(const boost::python::object& value,
210         const Data& other);         const Data& other);
211    
# Line 196  class Data { Line 213  class Data {
213       \brief       \brief
214       Constructor which creates a DataConstant of "shape" with constant value.       Constructor which creates a DataConstant of "shape" with constant value.
215    */    */
216      ESCRIPT_DLL_API
217    Data(double value,    Data(double value,
218         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
219         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
# Line 204  class Data { Line 222  class Data {
222       \brief       \brief
223       Destructor       Destructor
224    */    */
225      ESCRIPT_DLL_API
226    ~Data();    ~Data();
227    
228    /**    /**
229       \brief       \brief
230       Perform a deep copy.       Perform a deep copy.
231    */    */
232      ESCRIPT_DLL_API
233    void    void
234    copy(const Data& other);    copy(const Data& other);
235    
# Line 219  class Data { Line 239  class Data {
239    
240    /**    /**
241       \brief       \brief
242       Return the values of all data-points as a single python numarray object.       switches on update protection
243    
244    */    */
245    const boost::python::numeric::array    ESCRIPT_DLL_API
246    convertToNumArray();    void
247      setProtection();
248    
249    /**    /**
250       \brief       \brief
251       Return the values of all data-points for the given sample as a single python numarray object.       Returns trueif the data object is protected against update
252    
253    */    */
254    const boost::python::numeric::array    ESCRIPT_DLL_API
255    convertToNumArrayFromSampleNo(int sampleNo);    bool
256      isProtected() const;
257    
258    /**    /**
259       \brief       \brief
260       Return the value of the specified data-point as a single python numarray object.       Return the values of a data point on this process
261    */    */
262      ESCRIPT_DLL_API
263    const boost::python::numeric::array    const boost::python::numeric::array
264    convertToNumArrayFromDPNo(int sampleNo,    getValueOfDataPoint(int dataPointNo);
                             int dataPointNo);  
265    
266    /**    /**
267       \brief       \brief
268       Fills the expanded Data object from values of a python numarray object.       sets the values of a data-point from a python object on this process
269    */    */
270      ESCRIPT_DLL_API
271    void    void
272    fillFromNumArray(const boost::python::numeric::array);    setValueOfDataPointToPyObject(int dataPointNo, const boost::python::object& py_object);
273    
274      /**
275         \brief
276         sets the values of a data-point from a numarray object on this process
277      */
278      ESCRIPT_DLL_API
279      void
280      setValueOfDataPointToArray(int dataPointNo, const boost::python::numeric::array&);
281    
282      /**
283         \brief
284         sets the values of a data-point on this process
285      */
286      ESCRIPT_DLL_API
287      void
288      setValueOfDataPoint(int dataPointNo, const double);
289    
290      /**
291         \brief
292         Return the value of the specified data-point across all processors
293      */
294      ESCRIPT_DLL_API
295      const boost::python::numeric::array
296      getValueOfGlobalDataPoint(int procNo, int dataPointNo);
297    
298    /**    /**
299       \brief       \brief
# Line 253  class Data { Line 302  class Data {
302       The data-point number here corresponds to the data-point number in the       The data-point number here corresponds to the data-point number in the
303       numarray returned by convertToNumArray.       numarray returned by convertToNumArray.
304    */    */
305      ESCRIPT_DLL_API
306    int    int
307    getTagNumber(int dpno);    getTagNumber(int dpno);
308    
# Line 260  class Data { Line 310  class Data {
310       \brief       \brief
311       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
312    */    */
313      ESCRIPT_DLL_API
314    escriptDataC    escriptDataC
315    getDataC();    getDataC();
316    
# Line 267  class Data { Line 318  class Data {
318       \brief       \brief
319       Return the C wrapper for the Data object - const version.       Return the C wrapper for the Data object - const version.
320    */    */
321      ESCRIPT_DLL_API
322    escriptDataC    escriptDataC
323    getDataC() const;    getDataC() const;
324    
# Line 274  class Data { Line 326  class Data {
326       \brief       \brief
327       Write the data as a string.       Write the data as a string.
328    */    */
329      ESCRIPT_DLL_API
330    inline    inline
331    std::string    std::string
332    toString() const    toString() const
# Line 287  class Data { Line 340  class Data {
340       the shape information for each data point although it also may be used       the shape information for each data point although it also may be used
341       to manipulate the point data.       to manipulate the point data.
342    */    */
343      ESCRIPT_DLL_API
344    inline    inline
345    const DataArrayView&    const DataArrayView&
346    getPointDataView() const    getPointDataView() const
# Line 298  class Data { Line 352  class Data {
352       \brief       \brief
353       Whatever the current Data type make this into a DataExpanded.       Whatever the current Data type make this into a DataExpanded.
354    */    */
355      ESCRIPT_DLL_API
356    void    void
357    expand();    expand();
358    
# Line 308  class Data { Line 363  class Data {
363       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
364      ==>*      ==>*
365    */    */
366      ESCRIPT_DLL_API
367    void    void
368    tag();    tag();
369    
# Line 315  class Data { Line 371  class Data {
371       \brief       \brief
372       Return true if this Data is expanded.       Return true if this Data is expanded.
373    */    */
374      ESCRIPT_DLL_API
375    bool    bool
376    isExpanded() const;    isExpanded() const;
377    
# Line 322  class Data { Line 379  class Data {
379       \brief       \brief
380       Return true if this Data is tagged.       Return true if this Data is tagged.
381    */    */
382      ESCRIPT_DLL_API
383    bool    bool
384    isTagged() const;    isTagged() const;
385    
# Line 329  class Data { Line 387  class Data {
387       \brief       \brief
388       Return true if this Data is constant.       Return true if this Data is constant.
389    */    */
390      ESCRIPT_DLL_API
391    bool    bool
392    isConstant() const;    isConstant() const;
393    
# Line 336  class Data { Line 395  class Data {
395       \brief       \brief
396       Return true if this Data is empty.       Return true if this Data is empty.
397    */    */
398      ESCRIPT_DLL_API
399    bool    bool
400    isEmpty() const;    isEmpty() const;
401    
# Line 343  class Data { Line 403  class Data {
403       \brief       \brief
404       Return the function space.       Return the function space.
405    */    */
406      ESCRIPT_DLL_API
407    inline    inline
408    const FunctionSpace&    const FunctionSpace&
409    getFunctionSpace() const    getFunctionSpace() const
# Line 354  class Data { Line 415  class Data {
415       \brief       \brief
416       Return a copy of the function space.       Return a copy of the function space.
417    */    */
418      ESCRIPT_DLL_API
419    const FunctionSpace    const FunctionSpace
420    getCopyOfFunctionSpace() const;    getCopyOfFunctionSpace() const;
421    
# Line 361  class Data { Line 423  class Data {
423       \brief       \brief
424       Return the domain.       Return the domain.
425    */    */
426      ESCRIPT_DLL_API
427    inline    inline
428    const AbstractDomain&    const AbstractDomain&
429    getDomain() const    getDomain() const
# Line 372  class Data { Line 435  class Data {
435       \brief       \brief
436       Return a copy of the domain.       Return a copy of the domain.
437    */    */
438      ESCRIPT_DLL_API
439    const AbstractDomain    const AbstractDomain
440    getCopyOfDomain() const;    getCopyOfDomain() const;
441    
# Line 379  class Data { Line 443  class Data {
443       \brief       \brief
444       Return the rank of the point data.       Return the rank of the point data.
445    */    */
446      ESCRIPT_DLL_API
447    inline    inline
448    int    int
449    getDataPointRank() const    getDataPointRank() const
# Line 388  class Data { Line 453  class Data {
453    
454    /**    /**
455       \brief       \brief
456         Return the number of data points
457      */
458      ESCRIPT_DLL_API
459      inline
460      int
461      getNumDataPoints() const
462      {
463        return getNumSamples() * getNumDataPointsPerSample();
464      }
465      /**
466         \brief
467       Return the number of samples.       Return the number of samples.
468    */    */
469      ESCRIPT_DLL_API
470    inline    inline
471    int    int
472    getNumSamples() const    getNumSamples() const
# Line 401  class Data { Line 478  class Data {
478       \brief       \brief
479       Return the number of data points per sample.       Return the number of data points per sample.
480    */    */
481      ESCRIPT_DLL_API
482    inline    inline
483    int    int
484    getNumDataPointsPerSample() const    getNumDataPointsPerSample() const
485    {    {
486      return m_data->getNumDPPSample();      return m_data->getNumDPPSample();
487    }    }
488      /**
489         \brief
490         dumps the object into a netCDF file
491      */
492      ESCRIPT_DLL_API
493      inline
494      void
495      dump(const std::string fileName) const
496      {
497        return m_data->dump(fileName);
498      }
499    
500    /**    /**
501       \brief       \brief
# Line 414  class Data { Line 503  class Data {
503       preferred interface but is provided for use by C code.       preferred interface but is provided for use by C code.
504       \param sampleNo - Input - the given sample no.       \param sampleNo - Input - the given sample no.
505    */    */
506      ESCRIPT_DLL_API
507    inline    inline
508    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
509    getSampleData(DataAbstract::ValueType::size_type sampleNo)    getSampleData(DataAbstract::ValueType::size_type sampleNo)
# Line 427  class Data { Line 517  class Data {
517       access data that isn't tagged an exception will be thrown.       access data that isn't tagged an exception will be thrown.
518       \param tag - Input - the tag key.       \param tag - Input - the tag key.
519    */    */
520      ESCRIPT_DLL_API
521    inline    inline
522    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
523    getSampleDataByTag(int tag)    getSampleDataByTag(int tag)
# Line 436  class Data { Line 527  class Data {
527    
528    /**    /**
529       \brief       \brief
      Assign the given value to the data-points referenced by the given  
      reference number.  
   
      The value supplied is a python numarray object.  The data from this numarray  
      is unpacked into a DataArray, and this is used to set the corresponding  
      data-points in the underlying Data object.  
   
      If the underlying Data object cannot be accessed via reference numbers, an  
      exception will be thrown.  
   
      \param ref - Input - reference number.  
      \param value - Input - value to assign to data-points associated with  
                             the given reference number.  
   */  
   void  
   setRefValue(int ref,  
               const boost::python::numeric::array& value);  
   
   /**  
      \brief  
      Return the values associated with the data-points referenced by the given  
      reference number.  
   
      The value supplied is a python numarray object. The data from the corresponding  
      data-points in this Data object are packed into the given numarray object.  
   
      If the underlying Data object cannot be accessed via reference numbers, an  
      exception will be thrown.  
   
      \param ref - Input - reference number.  
      \param value - Output - object to receive values from data-points  
                              associated with the given reference number.  
   */  
   void  
   getRefValue(int ref,  
               boost::python::numeric::array& value);  
   
   /**  
      \brief  
530       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
531       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
532       operation.       operation.
533       \param sampleNo - Input -       \param sampleNo - Input -
534       \param dataPointNo - Input -       \param dataPointNo - Input -
535    */    */
536      ESCRIPT_DLL_API
537    inline    inline
538    DataArrayView    DataArrayView
539    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
540                 int dataPointNo)                 int dataPointNo)
541    {    {
542      return m_data->getDataPoint(sampleNo,dataPointNo);          return m_data->getDataPoint(sampleNo,dataPointNo);
543    }    }
544    
545    /**    /**
546       \brief       \brief
547       Return a reference to the data point shape.       Return a reference to the data point shape.
548    */    */
549      ESCRIPT_DLL_API
550    const DataArrayView::ShapeType&    const DataArrayView::ShapeType&
551    getDataPointShape() const;    getDataPointShape() const;
552    
# Line 500  class Data { Line 554  class Data {
554       \brief       \brief
555       Return the data point shape as a tuple of integers.       Return the data point shape as a tuple of integers.
556    */    */
557      ESCRIPT_DLL_API
558    const boost::python::tuple    const boost::python::tuple
559    getShapeTuple() const;    getShapeTuple() const;
560    
# Line 508  class Data { Line 563  class Data {
563       Return the size of the data point. It is the product of the       Return the size of the data point. It is the product of the
564       data point shape dimensions.       data point shape dimensions.
565    */    */
566      ESCRIPT_DLL_API
567    int    int
568    getDataPointSize() const;    getDataPointSize() const;
569    
# Line 515  class Data { Line 571  class Data {
571       \brief       \brief
572       Return the number of doubles stored for this Data.       Return the number of doubles stored for this Data.
573    */    */
574      ESCRIPT_DLL_API
575    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
576    getLength() const;    getLength() const;
577    
578    
579    
580      /**
581         \brief
582         Assign the given value to the tag assocciated with name. Implicitly converts this
583         object to type DataTagged. Throws an exception if this object
584         cannot be converted to a DataTagged object or name cannot be mapped onto a tag key.
585         \param tagKey - Input - Integer key.
586         \param value - Input - Value to associate with given key.
587        ==>*
588      */
589      ESCRIPT_DLL_API
590      void
591      setTaggedValueByName(std::string name,
592                           const boost::python::object& value);
593    
594    /**    /**
595       \brief       \brief
596       Assign the given value to the tag. Implicitly converts this       Assign the given value to the tag. Implicitly converts this
# Line 527  class Data { Line 600  class Data {
600       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
601      ==>*      ==>*
602    */    */
603      ESCRIPT_DLL_API
604    void    void
605    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
606                   const boost::python::object& value);                   const boost::python::object& value);
# Line 540  class Data { Line 614  class Data {
614       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
615      ==>*      ==>*
616    */    */
617      ESCRIPT_DLL_API
618    void    void
619    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
620                          const DataArrayView& value);                          const DataArrayView& value);
# Line 548  class Data { Line 623  class Data {
623      \brief      \brief
624      Copy other Data object into this Data object where mask is positive.      Copy other Data object into this Data object where mask is positive.
625    */    */
626      ESCRIPT_DLL_API
627    void    void
628    copyWithMask(const Data& other,    copyWithMask(const Data& other,
629                 const Data& mask);                 const Data& mask);
# Line 558  class Data { Line 634  class Data {
634    
635    /**    /**
636       \brief       \brief
637         set all values to zero
638         *
639      */
640      ESCRIPT_DLL_API
641      void
642      setToZero();
643    
644      /**
645         \brief
646       Interpolates this onto the given functionspace and returns       Interpolates this onto the given functionspace and returns
647       the result as a Data object.       the result as a Data object.
648       *       *
649    */    */
650      ESCRIPT_DLL_API
651    Data    Data
652    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
   
653    /**    /**
654       \brief       \brief
655       Calculates the gradient of the data at the data points of functionspace.       Calculates the gradient of the data at the data points of functionspace.
656       If functionspace is not present the function space of Function(getDomain()) is used.       If functionspace is not present the function space of Function(getDomain()) is used.
657       *       *
658    */    */
659      ESCRIPT_DLL_API
660    Data    Data
661    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
662    
663      ESCRIPT_DLL_API
664    Data    Data
665    grad() const;    grad() const;
666    
# Line 582  class Data { Line 669  class Data {
669       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
670       *       *
671    */    */
672      ESCRIPT_DLL_API
673    boost::python::numeric::array    boost::python::numeric::array
674    integrate() const;    integrate() const;
675    
676    /**    /**
677       \brief       \brief
678         Returns 1./ Data object
679         *
680      */
681      ESCRIPT_DLL_API
682      Data
683      oneOver() const;
684      /**
685         \brief
686       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.
687       *       *
688    */    */
689      ESCRIPT_DLL_API
690    Data    Data
691    wherePositive() const;    wherePositive() const;
692    
# Line 598  class Data { Line 695  class Data {
695       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.
696       *       *
697    */    */
698      ESCRIPT_DLL_API
699    Data    Data
700    whereNegative() const;    whereNegative() const;
701    
# Line 606  class Data { Line 704  class Data {
704       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.
705       *       *
706    */    */
707      ESCRIPT_DLL_API
708    Data    Data
709    whereNonNegative() const;    whereNonNegative() const;
710    
# Line 614  class Data { Line 713  class Data {
713       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.
714       *       *
715    */    */
716      ESCRIPT_DLL_API
717    Data    Data
718    whereNonPositive() const;    whereNonPositive() const;
719    
# Line 622  class Data { Line 722  class Data {
722       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.
723       *       *
724    */    */
725      ESCRIPT_DLL_API
726    Data    Data
727    whereZero(double tol=0.0) const;    whereZero(double tol=0.0) const;
728    
# Line 630  class Data { Line 731  class Data {
731       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.
732       *       *
733    */    */
734      ESCRIPT_DLL_API
735    Data    Data
736    whereNonZero(double tol=0.0) const;    whereNonZero(double tol=0.0) const;
737    
# Line 638  class Data { Line 740  class Data {
740       Return the maximum absolute value of this Data object.       Return the maximum absolute value of this Data object.
741       *       *
742    */    */
743      ESCRIPT_DLL_API
744    double    double
745    Lsup() const;    Lsup() const;
746    
# Line 646  class Data { Line 749  class Data {
749       Return the minimum absolute value of this Data object.       Return the minimum absolute value of this Data object.
750       *       *
751    */    */
752      ESCRIPT_DLL_API
753    double    double
754    Linf() const;    Linf() const;
755    
# Line 654  class Data { Line 758  class Data {
758       Return the maximum value of this Data object.       Return the maximum value of this Data object.
759       *       *
760    */    */
761      ESCRIPT_DLL_API
762    double    double
763    sup() const;    sup() const;
764    
# Line 662  class Data { Line 767  class Data {
767       Return the minimum value of this Data object.       Return the minimum value of this Data object.
768       *       *
769    */    */
770      ESCRIPT_DLL_API
771    double    double
772    inf() const;    inf() const;
773    
# Line 670  class Data { Line 776  class Data {
776       Return the absolute value of each data point of this Data object.       Return the absolute value of each data point of this Data object.
777       *       *
778    */    */
779      ESCRIPT_DLL_API
780    Data    Data
781    abs() const;    abs() const;
782    
# Line 678  class Data { Line 785  class Data {
785       Return the maximum value of each data point of this Data object.       Return the maximum value of each data point of this Data object.
786       *       *
787    */    */
788      ESCRIPT_DLL_API
789    Data    Data
790    maxval() const;    maxval() const;
791    
# Line 686  class Data { Line 794  class Data {
794       Return the minimum value of each data point of this Data object.       Return the minimum value of each data point of this Data object.
795       *       *
796    */    */
797      ESCRIPT_DLL_API
798    Data    Data
799    minval() const;    minval() const;
800    
# Line 694  class Data { Line 803  class Data {
803       Return the (sample number, data-point number) of the data point with       Return the (sample number, data-point number) of the data point with
804       the minimum value in this Data object.       the minimum value in this Data object.
805    */    */
806      ESCRIPT_DLL_API
807    const boost::python::tuple    const boost::python::tuple
808    mindp() const;    minGlobalDataPoint() const;
809    
810      ESCRIPT_DLL_API
811    void    void
812    calc_mindp(int& SampleNo,    calc_minGlobalDataPoint(int& ProcNo,  int& DataPointNo) const;
              int& DataPointNo) const;  
   
813    /**    /**
814       \brief       \brief
815       Return the sign of each data point of this Data object.       Return the sign of each data point of this Data object.
816       -1 for negative values, zero for zero values, 1 for positive values.       -1 for negative values, zero for zero values, 1 for positive values.
817       *       *
818    */    */
819      ESCRIPT_DLL_API
820    Data    Data
821    sign() const;    sign() const;
822    
823    /**    /**
824       \brief       \brief
825         Return the symmetric part of a matrix which is half the matrix plus its transpose.
826         *
827      */
828      ESCRIPT_DLL_API
829      Data
830      symmetric() const;
831    
832      /**
833         \brief
834         Return the nonsymmetric part of a matrix which is half the matrix minus its transpose.
835         *
836      */
837      ESCRIPT_DLL_API
838      Data
839      nonsymmetric() const;
840    
841      /**
842         \brief
843         Return the trace of a matrix
844         *
845      */
846      ESCRIPT_DLL_API
847      Data
848      trace(int axis_offset) const;
849    
850      /**
851         \brief
852         Transpose each data point of this Data object around the given axis.
853         *
854      */
855      ESCRIPT_DLL_API
856      Data
857      transpose(int axis_offset) const;
858    
859      /**
860         \brief
861       Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.       Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.
862       Currently this function is restricted to rank 2, square shape, and dimension 3.       Currently this function is restricted to rank 2, square shape, and dimension 3.
863       *       *
864    */    */
865      ESCRIPT_DLL_API
866    Data    Data
867    eigenvalues() const;    eigenvalues() const;
868    
# Line 728  class Data { Line 875  class Data {
875       Currently this function is restricted to rank 2, square shape, and dimension 3       Currently this function is restricted to rank 2, square shape, and dimension 3
876       *       *
877    */    */
878      ESCRIPT_DLL_API
879    const boost::python::tuple    const boost::python::tuple
880    eigenvalues_and_eigenvectors(const double tol=1.e-12) const;    eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
881    
882    /**    /**
883       \brief       \brief
884       Transpose each data point of this Data object around the given axis.       swaps the components axis0 and axis1
      --* not implemented yet *--  
885       *       *
886    */    */
887      ESCRIPT_DLL_API
888    Data    Data
889    transpose(int axis) const;    swapaxes(const int axis0, const int axis1) const;
890    
891    /**    /**
892       \brief       \brief
893       Calculate the trace of each data point of this Data object.       Return the error function erf of each data point of this Data object.
894       *       *
895    */    */
896      ESCRIPT_DLL_API
897    Data    Data
898    trace() const;    erf() const;
899    
900    /**    /**
901       \brief       \brief
902       Return the sin of each data point of this Data object.       Return the sin of each data point of this Data object.
903       *       *
904    */    */
905      ESCRIPT_DLL_API
906    Data    Data
907    sin() const;    sin() const;
908    
# Line 761  class Data { Line 911  class Data {
911       Return the cos of each data point of this Data object.       Return the cos of each data point of this Data object.
912       *       *
913    */    */
914      ESCRIPT_DLL_API
915    Data    Data
916    cos() const;    cos() const;
917    
# Line 769  class Data { Line 920  class Data {
920       Return the tan of each data point of this Data object.       Return the tan of each data point of this Data object.
921       *       *
922    */    */
923      ESCRIPT_DLL_API
924    Data    Data
925    tan() const;    tan() const;
926    
# Line 777  class Data { Line 929  class Data {
929       Return the asin of each data point of this Data object.       Return the asin of each data point of this Data object.
930       *       *
931    */    */
932      ESCRIPT_DLL_API
933    Data    Data
934    asin() const;    asin() const;
935    
# Line 785  class Data { Line 938  class Data {
938       Return the acos of each data point of this Data object.       Return the acos of each data point of this Data object.
939       *       *
940    */    */
941      ESCRIPT_DLL_API
942    Data    Data
943    acos() const;    acos() const;
944    
# Line 793  class Data { Line 947  class Data {
947       Return the atan of each data point of this Data object.       Return the atan of each data point of this Data object.
948       *       *
949    */    */
950      ESCRIPT_DLL_API
951    Data    Data
952    atan() const;    atan() const;
953    
# Line 801  class Data { Line 956  class Data {
956       Return the sinh of each data point of this Data object.       Return the sinh of each data point of this Data object.
957       *       *
958    */    */
959      ESCRIPT_DLL_API
960    Data    Data
961    sinh() const;    sinh() const;
962    
# Line 809  class Data { Line 965  class Data {
965       Return the cosh of each data point of this Data object.       Return the cosh of each data point of this Data object.
966       *       *
967    */    */
968      ESCRIPT_DLL_API
969    Data    Data
970    cosh() const;    cosh() const;
971    
# Line 817  class Data { Line 974  class Data {
974       Return the tanh of each data point of this Data object.       Return the tanh of each data point of this Data object.
975       *       *
976    */    */
977      ESCRIPT_DLL_API
978    Data    Data
979    tanh() const;    tanh() const;
980    
# Line 825  class Data { Line 983  class Data {
983       Return the asinh of each data point of this Data object.       Return the asinh of each data point of this Data object.
984       *       *
985    */    */
986      ESCRIPT_DLL_API
987    Data    Data
988    asinh() const;    asinh() const;
989    
# Line 833  class Data { Line 992  class Data {
992       Return the acosh of each data point of this Data object.       Return the acosh of each data point of this Data object.
993       *       *
994    */    */
995      ESCRIPT_DLL_API
996    Data    Data
997    acosh() const;    acosh() const;
998    
# Line 841  class Data { Line 1001  class Data {
1001       Return the atanh of each data point of this Data object.       Return the atanh of each data point of this Data object.
1002       *       *
1003    */    */
1004      ESCRIPT_DLL_API
1005    Data    Data
1006    atanh() const;    atanh() const;
1007    
# Line 849  class Data { Line 1010  class Data {
1010       Return the log to base 10 of each data point of this Data object.       Return the log to base 10 of each data point of this Data object.
1011       *       *
1012    */    */
1013      ESCRIPT_DLL_API
1014    Data    Data
1015    log10() const;    log10() const;
1016    
# Line 857  class Data { Line 1019  class Data {
1019       Return the natural log of each data point of this Data object.       Return the natural log of each data point of this Data object.
1020       *       *
1021    */    */
1022      ESCRIPT_DLL_API
1023    Data    Data
1024    log() const;    log() const;
1025    
# Line 865  class Data { Line 1028  class Data {
1028       Return the exponential function of each data point of this Data object.       Return the exponential function of each data point of this Data object.
1029       *       *
1030    */    */
1031      ESCRIPT_DLL_API
1032    Data    Data
1033    exp() const;    exp() const;
1034    
# Line 873  class Data { Line 1037  class Data {
1037       Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
1038       *       *
1039    */    */
1040      ESCRIPT_DLL_API
1041    Data    Data
1042    sqrt() const;    sqrt() const;
1043    
# Line 881  class Data { Line 1046  class Data {
1046       Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
1047       *       *
1048    */    */
1049      ESCRIPT_DLL_API
1050    Data    Data
1051    neg() const;    neg() const;
1052    
# Line 890  class Data { Line 1056  class Data {
1056       Simply returns this object unmodified.       Simply returns this object unmodified.
1057       *       *
1058    */    */
1059      ESCRIPT_DLL_API
1060    Data    Data
1061    pos() const;    pos() const;
1062    
# Line 900  class Data { Line 1067  class Data {
1067       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1068       *       *
1069    */    */
1070      ESCRIPT_DLL_API
1071    Data    Data
1072    powD(const Data& right) const;    powD(const Data& right) const;
1073    
# Line 910  class Data { Line 1078  class Data {
1078       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1079       *       *
1080     */     */
1081      ESCRIPT_DLL_API
1082    Data    Data
1083    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
1084    
1085    /**    /**
1086       \brief       \brief
1087         Return the given power of each data point of this boost python object.
1088        
1089         \param left Input - the bases
1090         *
1091       */
1092    
1093      ESCRIPT_DLL_API
1094      Data
1095      rpowO(const boost::python::object& left) const;
1096    
1097      /**
1098         \brief
1099       writes the object to a file in the DX file format       writes the object to a file in the DX file format
1100    */    */
1101      ESCRIPT_DLL_API
1102    void    void
1103    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
1104    
# Line 924  class Data { Line 1106  class Data {
1106       \brief       \brief
1107       writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
1108    */    */
1109      ESCRIPT_DLL_API
1110    void    void
1111    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
1112    
# Line 933  class Data { Line 1116  class Data {
1116       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1117       *       *
1118    */    */
1119      ESCRIPT_DLL_API
1120    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
1121      ESCRIPT_DLL_API
1122    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
1123    
1124    /**    /**
# Line 942  class Data { Line 1127  class Data {
1127       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1128       *       *
1129    */    */
1130      ESCRIPT_DLL_API
1131    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
1132      ESCRIPT_DLL_API
1133    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
1134    
1135   /**   /**
# Line 951  class Data { Line 1138  class Data {
1138       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1139       *       *
1140    */    */
1141      ESCRIPT_DLL_API
1142    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
1143      ESCRIPT_DLL_API
1144    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
1145    
1146   /**   /**
# Line 960  class Data { Line 1149  class Data {
1149       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1150       *       *
1151    */    */
1152      ESCRIPT_DLL_API
1153    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
1154      ESCRIPT_DLL_API
1155    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
1156    
1157    /**    /**
1158       \brief       \brief
1159       Returns true if this can be interpolated to functionspace.       Returns true if this can be interpolated to functionspace.
1160    */    */
1161      ESCRIPT_DLL_API
1162    bool    bool
1163    probeInterpolation(const FunctionSpace& functionspace) const;    probeInterpolation(const FunctionSpace& functionspace) const;
1164    
# Line 985  class Data { Line 1177  class Data {
1177       \param key - Input - python slice tuple specifying       \param key - Input - python slice tuple specifying
1178       slice to return.       slice to return.
1179    */    */
1180      ESCRIPT_DLL_API
1181    Data    Data
1182    getItem(const boost::python::object& key) const;    getItem(const boost::python::object& key) const;
1183    
# Line 999  class Data { Line 1192  class Data {
1192       slice to copy from value.       slice to copy from value.
1193       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
1194    */    */
1195      ESCRIPT_DLL_API
1196    void    void
1197    setItemD(const boost::python::object& key,    setItemD(const boost::python::object& key,
1198             const Data& value);             const Data& value);
1199    
1200      ESCRIPT_DLL_API
1201    void    void
1202    setItemO(const boost::python::object& key,    setItemO(const boost::python::object& key,
1203             const boost::python::object& value);             const boost::python::object& value);
# Line 1015  class Data { Line 1210  class Data {
1210       this Data object.       this Data object.
1211    */    */
1212    template <class UnaryFunction>    template <class UnaryFunction>
1213      ESCRIPT_DLL_API
1214    inline    inline
1215    void    void
1216    unaryOp(UnaryFunction operation);    unaryOp(UnaryFunction operation);
# Line 1026  class Data { Line 1222  class Data {
1222       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1223       *       *
1224    */    */
1225      ESCRIPT_DLL_API
1226    Data    Data
1227    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
1228    
# Line 1037  class Data { Line 1234  class Data {
1234       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1235       *       *
1236    */    */
1237      ESCRIPT_DLL_API
1238    void    void
1239    setSlice(const Data& value,    setSlice(const Data& value,
1240             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
# Line 1046  class Data { Line 1244  class Data {
1244       Archive the current Data object to the given file.       Archive the current Data object to the given file.
1245       \param fileName - Input - file to archive to.       \param fileName - Input - file to archive to.
1246    */    */
1247      ESCRIPT_DLL_API
1248    void    void
1249    archiveData(const std::string fileName);    archiveData(const std::string fileName);
1250    
# Line 1057  class Data { Line 1256  class Data {
1256       \param fileName - Input - file to extract from.       \param fileName - Input - file to extract from.
1257       \param fspace - Input - a suitable FunctionSpace descibing the data.       \param fspace - Input - a suitable FunctionSpace descibing the data.
1258    */    */
1259      ESCRIPT_DLL_API
1260    void    void
1261    extractData(const std::string fileName,    extractData(const std::string fileName,
1262                const FunctionSpace& fspace);                const FunctionSpace& fspace);
1263    
1264    
1265      /**
1266         \brief
1267         print the data values to stdout. Used for debugging
1268      */
1269      ESCRIPT_DLL_API
1270      void
1271        print(void);
1272    
1273      /**
1274         \brief
1275         return the MPI rank number of the local data
1276             MPI_COMM_WORLD is assumed and the result of MPI_Comm_size()
1277             is returned
1278      */
1279      ESCRIPT_DLL_API
1280        int
1281        get_MPIRank(void) const;
1282    
1283      /**
1284         \brief
1285         return the MPI rank number of the local data
1286             MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank()
1287             is returned
1288      */
1289      ESCRIPT_DLL_API
1290        int
1291        get_MPISize(void) const;
1292    
1293      /**
1294         \brief
1295         return the MPI rank number of the local data
1296             MPI_COMM_WORLD is assumed and returned.
1297      */
1298      ESCRIPT_DLL_API
1299        MPI_Comm
1300        get_MPIComm(void) const;
1301    
1302      /**
1303         \brief
1304         return the object produced by the factory, which is a DataConstant or DataExpanded
1305      */
1306      ESCRIPT_DLL_API
1307        DataAbstract*
1308        borrowData(void) const;
1309    
1310   protected:   protected:
1311    
1312   private:   private:
# Line 1118  class Data { Line 1364  class Data {
1364    
1365    /**    /**
1366       \brief       \brief
      Perform the given binary operation on all of the data's elements.  
      RHS is a boost::python object.  
   */  
   template <class BinaryFunction>  
   inline  
   void  
   binaryOp(const boost::python::object& right,  
            BinaryFunction operation);  
   
   /**  
      \brief  
1367       Convert the data type of the RHS to match this.       Convert the data type of the RHS to match this.
1368       \param right - Input - data type to match.       \param right - Input - data type to match.
1369    */    */
# Line 1153  class Data { Line 1388  class Data {
1388               const FunctionSpace& what,               const FunctionSpace& what,
1389               bool expanded);               bool expanded);
1390    
1391    /**    //
1392       \brief    // flag to protect the data object against any update
1393       Reshape the data point if the data point is currently rank 0.    bool m_protected;
      Will throw an exception if the data points are not rank 0.  
      The original data point value is used for all values of the new  
      data point.  
   */  
   void  
   reshapeDataPoint(const DataArrayView::ShapeType& shape);  
1394    
1395    //    //
1396    // pointer to the actual data object    // pointer to the actual data object
1397    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1398    
   //  
   // pointer to the internal profiling data  
   struct profDataEntry *profData;  
   
1399  };  };
1400    
1401  template <class IValueType>  template <class IValueType>
# Line 1198  Data::initialise(const IValueType& value Line 1423  Data::initialise(const IValueType& value
1423  /**  /**
1424     Binary Data object operators.     Binary Data object operators.
1425  */  */
1426    inline double rpow(double x,double y)
1427    {
1428        return pow(y,x);
1429    }
1430    
1431  /**  /**
1432    \brief    \brief
1433    Operator+    Operator+
1434    Takes two Data objects.    Takes two Data objects.
1435  */  */
1436  Data operator+(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const Data& right);
1437    
1438  /**  /**
1439    \brief    \brief
1440    Operator-    Operator-
1441    Takes two Data objects.    Takes two Data objects.
1442  */  */
1443  Data operator-(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const Data& right);
1444    
1445  /**  /**
1446    \brief    \brief
1447    Operator*    Operator*
1448    Takes two Data objects.    Takes two Data objects.
1449  */  */
1450  Data operator*(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const Data& right);
1451    
1452  /**  /**
1453    \brief    \brief
1454    Operator/    Operator/
1455    Takes two Data objects.    Takes two Data objects.
1456  */  */
1457  Data operator/(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const Data& right);
1458    
1459  /**  /**
1460    \brief    \brief
# Line 1233  Data operator/(const Data& left, const D Line 1462  Data operator/(const Data& left, const D
1462    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1463    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1464  */  */
1465  Data operator+(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const boost::python::object& right);
1466    
1467  /**  /**
1468    \brief    \brief
# Line 1241  Data operator+(const Data& left, const b Line 1470  Data operator+(const Data& left, const b
1470    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1471    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1472  */  */
1473  Data operator-(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const boost::python::object& right);
1474    
1475  /**  /**
1476    \brief    \brief
# Line 1249  Data operator-(const Data& left, const b Line 1478  Data operator-(const Data& left, const b
1478    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1479    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1480  */  */
1481  Data operator*(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const boost::python::object& right);
1482    
1483  /**  /**
1484    \brief    \brief
# Line 1257  Data operator*(const Data& left, const b Line 1486  Data operator*(const Data& left, const b
1486    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1487    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1488  */  */
1489  Data operator/(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const boost::python::object& right);
1490    
1491  /**  /**
1492    \brief    \brief
# Line 1265  Data operator/(const Data& left, const b Line 1494  Data operator/(const Data& left, const b
1494    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1495    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1496  */  */
1497  Data operator+(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const boost::python::object& left, const Data& right);
1498    
1499  /**  /**
1500    \brief    \brief
# Line 1273  Data operator+(const boost::python::obje Line 1502  Data operator+(const boost::python::obje
1502    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1503    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1504  */  */
1505  Data operator-(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const boost::python::object& left, const Data& right);
1506    
1507  /**  /**
1508    \brief    \brief
# Line 1281  Data operator-(const boost::python::obje Line 1510  Data operator-(const boost::python::obje
1510    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1511    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1512  */  */
1513  Data operator*(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const boost::python::object& left, const Data& right);
1514    
1515  /**  /**
1516    \brief    \brief
# Line 1289  Data operator*(const boost::python::obje Line 1518  Data operator*(const boost::python::obje
1518    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1519    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1520  */  */
1521  Data operator/(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const boost::python::object& left, const Data& right);
1522    
1523  /**  /**
1524    \brief    \brief
1525    Output operator    Output operator
1526  */  */
1527  std::ostream& operator<<(std::ostream& o, const Data& data);  ESCRIPT_DLL_API std::ostream& operator<<(std::ostream& o, const Data& data);
1528    
1529    /**
1530      \brief
1531      Compute a tensor product of two Data objects
1532      \param arg0 - Input - Data object
1533      \param arg1 - Input - Data object
1534      \param axis_offset - Input - axis offset
1535      \param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1
1536    */
1537    ESCRIPT_DLL_API
1538    Data
1539    C_GeneralTensorProduct(Data& arg0,
1540                         Data& arg1,
1541                         int axis_offset=0,
1542                         int transpose=0);
1543    
1544  /**  /**
1545    \brief    \brief
# Line 1303  std::ostream& operator<<(std::ostream& o Line 1547  std::ostream& operator<<(std::ostream& o
1547    NB: this operator does very little at this point, and isn't to    NB: this operator does very little at this point, and isn't to
1548    be relied on. Requires further implementation.    be relied on. Requires further implementation.
1549  */  */
1550  //bool operator==(const Data& left, const Data& right);  //ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);
1551    
1552  /**  /**
1553    \brief    \brief
# Line 1319  Data::binaryOp(const Data& right, Line 1563  Data::binaryOp(const Data& right,
1563     //     //
1564     // if this has a rank of zero promote it to the rank of the RHS     // if this has a rank of zero promote it to the rank of the RHS
1565     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {
1566       reshapeDataPoint(right.getPointDataView().getShape());       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1567     }     }
1568     //     //
1569     // initially make the temporary a shallow copy     // initially make the temporary a shallow copy
# Line 1373  Data::binaryOp(const Data& right, Line 1617  Data::binaryOp(const Data& right,
1617     }     }
1618  }  }
1619    
 /**  
   \brief  
   Perform the given binary operation with this and right as operands.  
   Right is a boost::python object.  
 */  
 template <class BinaryFunction>  
 inline  
 void  
 Data::binaryOp(const boost::python::object& right,  
                BinaryFunction operation)  
 {  
    DataArray temp(right);  
    //  
    // if this has a rank of zero promote it to the rank of the RHS.  
    if (getPointDataView().getRank()==0 && temp.getView().getRank()!=0) {  
       reshapeDataPoint(temp.getView().getShape());  
    }  
    //  
    // Always allow scalar values for the RHS but check other shapes  
    if (temp.getView().getRank()!=0) {  
      if (!getPointDataView().checkShape(temp.getView().getShape())) {  
        throw DataException(getPointDataView().createShapeErrorMessage(  
                   "Error - RHS shape doesn't match LHS shape.",temp.getView().getShape()));  
      }  
    }  
    if (isExpanded()) {  
      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());  
      EsysAssert((leftC!=0),"Programming error - casting to DataExpanded.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    } else if (isTagged()) {  
      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());  
      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    } else if (isConstant()) {  
      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());  
      EsysAssert((leftC!=0),"Programming error - casting to DataConstant.");  
      escript::binaryOp(*leftC,temp.getView(),operation);  
    }  
 }  
   
1620  /**  /**
1621    \brief    \brief
1622    Perform the given unary operation on other and return the result.    Perform the given unary operation on other and return the result.

Legend:
Removed from v.698  
changed lines
  Added in v.1118

  ViewVC Help
Powered by ViewVC 1.1.26