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

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

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

revision 474 by jgs, Mon Jan 30 04:23:44 2006 UTC revision 1044 by gross, Mon Mar 19 07:29:31 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT ACcESS 2004 -  All Rights Reserved                         *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS.  No part of this code             *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that                          *   *                                                          *
11   * person has a software license agreement with ACcESS.                       *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13    
14  /** \file Data.h */  /** \file Data.h */
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"
 #include "DataTagged.h"  
21  #include "DataAlgorithm.h"  #include "DataAlgorithm.h"
22  #include "FunctionSpace.h"  #include "FunctionSpace.h"
23  #include "BinaryOp.h"  #include "BinaryOp.h"
# Line 28  Line 26 
26    
27  extern "C" {  extern "C" {
28  #include "DataC.h"  #include "DataC.h"
29    #include "paso/Paso.h"
30  }  }
31    
32  #include <iostream>  #ifndef PASO_MPI
33    #define MPI_Comm long
34    #endif
35    
36  #include <string>  #include <string>
 #include <memory>  
37  #include <algorithm>  #include <algorithm>
38    
39  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
40  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
 #include <boost/python/list.hpp>  
41  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
42  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
43    
# Line 45  namespace escript { Line 45  namespace escript {
45    
46  //  //
47  // Forward declaration for various implementations of Data.  // Forward declaration for various implementations of Data.
 class DataEmpty;  
48  class DataConstant;  class DataConstant;
49  class DataTagged;  class DataTagged;
50  class DataExpanded;  class DataExpanded;
# Line 71  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 80  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 87  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 95  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 108  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 123  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 135  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 150  class Data { Line 156  class Data {
156       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
157       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
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 167  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 182  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 195  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 202  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 210  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 225  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 259  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 266  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 273  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 280  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 293  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 304  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 312  class Data { Line 361  class Data {
361       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
362       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
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 320  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 327  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 334  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 341  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 348  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 359  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 366  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 377  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 384  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 393  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 406  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 419  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 432  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 441  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 505  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 513  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 520  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 530  class Data { Line 598  class Data {
598       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
599       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
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 542  class Data { Line 612  class Data {
612       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
613       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
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 551  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 565  class Data { Line 638  class Data {
638       the result as a Data object.       the result as a Data object.
639       *       *
640    */    */
641      ESCRIPT_DLL_API
642    Data    Data
643    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
644    
# Line 574  class Data { Line 648  class Data {
648       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.
649       *       *
650    */    */
651      ESCRIPT_DLL_API
652    Data    Data
653    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
654    
655      ESCRIPT_DLL_API
656    Data    Data
657    grad() const;    grad() const;
658    
# Line 585  class Data { Line 661  class Data {
661       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
662       *       *
663    */    */
664      ESCRIPT_DLL_API
665    boost::python::numeric::array    boost::python::numeric::array
666    integrate() const;    integrate() const;
667    
668    /**    /**
669       \brief       \brief
670         Returns 1./ Data object
671         *
672      */
673      ESCRIPT_DLL_API
674      Data
675      oneOver() const;
676      /**
677         \brief
678       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.
679       *       *
680    */    */
681      ESCRIPT_DLL_API
682    Data    Data
683    wherePositive() const;    wherePositive() const;
684    
# Line 601  class Data { Line 687  class Data {
687       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.
688       *       *
689    */    */
690      ESCRIPT_DLL_API
691    Data    Data
692    whereNegative() const;    whereNegative() const;
693    
# Line 609  class Data { Line 696  class Data {
696       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.
697       *       *
698    */    */
699      ESCRIPT_DLL_API
700    Data    Data
701    whereNonNegative() const;    whereNonNegative() const;
702    
# Line 617  class Data { Line 705  class Data {
705       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.
706       *       *
707    */    */
708      ESCRIPT_DLL_API
709    Data    Data
710    whereNonPositive() const;    whereNonPositive() const;
711    
# Line 625  class Data { Line 714  class Data {
714       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.
715       *       *
716    */    */
717      ESCRIPT_DLL_API
718    Data    Data
719    whereZero() const;    whereZero(double tol=0.0) const;
720    
721    /**    /**
722       \brief       \brief
723       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.
724       *       *
725    */    */
726      ESCRIPT_DLL_API
727    Data    Data
728    whereNonZero() const;    whereNonZero(double tol=0.0) const;
729    
730    /**    /**
731       \brief       \brief
732       Return the maximum absolute value of this Data object.       Return the maximum absolute value of this Data object.
733       *       *
734    */    */
735      ESCRIPT_DLL_API
736    double    double
737    Lsup() const;    Lsup() const;
738    
# Line 649  class Data { Line 741  class Data {
741       Return the minimum absolute value of this Data object.       Return the minimum absolute value of this Data object.
742       *       *
743    */    */
744      ESCRIPT_DLL_API
745    double    double
746    Linf() const;    Linf() const;
747    
# Line 657  class Data { Line 750  class Data {
750       Return the maximum value of this Data object.       Return the maximum value of this Data object.
751       *       *
752    */    */
753      ESCRIPT_DLL_API
754    double    double
755    sup() const;    sup() const;
756    
# Line 665  class Data { Line 759  class Data {
759       Return the minimum value of this Data object.       Return the minimum value of this Data object.
760       *       *
761    */    */
762      ESCRIPT_DLL_API
763    double    double
764    inf() const;    inf() const;
765    
# Line 673  class Data { Line 768  class Data {
768       Return the absolute value of each data point of this Data object.       Return the absolute value of each data point of this Data object.
769       *       *
770    */    */
771      ESCRIPT_DLL_API
772    Data    Data
773    abs() const;    abs() const;
774    
# Line 681  class Data { Line 777  class Data {
777       Return the maximum value of each data point of this Data object.       Return the maximum value of each data point of this Data object.
778       *       *
779    */    */
780      ESCRIPT_DLL_API
781    Data    Data
782    maxval() const;    maxval() const;
783    
# Line 689  class Data { Line 786  class Data {
786       Return the minimum value of each data point of this Data object.       Return the minimum value of each data point of this Data object.
787       *       *
788    */    */
789      ESCRIPT_DLL_API
790    Data    Data
791    minval() const;    minval() const;
792    
# Line 697  class Data { Line 795  class Data {
795       Return the (sample number, data-point number) of the data point with       Return the (sample number, data-point number) of the data point with
796       the minimum value in this Data object.       the minimum value in this Data object.
797    */    */
798      ESCRIPT_DLL_API
799    const boost::python::tuple    const boost::python::tuple
800    mindp() const;    minGlobalDataPoint() const;
801    
802      ESCRIPT_DLL_API
803    void    void
804    calc_mindp(int& SampleNo,    calc_minGlobalDataPoint(int& ProcNo,  int& DataPointNo) const;
              int& DataPointNo) const;  
   
805    /**    /**
806       \brief       \brief
807       Return the sign of each data point of this Data object.       Return the sign of each data point of this Data object.
808       -1 for negative values, zero for zero values, 1 for positive values.       -1 for negative values, zero for zero values, 1 for positive values.
809       *       *
810    */    */
811      ESCRIPT_DLL_API
812    Data    Data
813    sign() const;    sign() const;
814    
815    /**    /**
816       \brief       \brief
817         Return the symmetric part of a matrix which is half the matrix plus its transpose.
818         *
819      */
820      ESCRIPT_DLL_API
821      Data
822      symmetric() const;
823    
824      /**
825         \brief
826         Return the nonsymmetric part of a matrix which is half the matrix minus its transpose.
827         *
828      */
829      ESCRIPT_DLL_API
830      Data
831      nonsymmetric() const;
832    
833      /**
834         \brief
835         Return the trace of a matrix
836         *
837      */
838      ESCRIPT_DLL_API
839      Data
840      trace(int axis_offset) const;
841    
842      /**
843         \brief
844       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
      --* not implemented yet *--  
845       *       *
846    */    */
847      ESCRIPT_DLL_API
848    Data    Data
849    transpose(int axis) const;    transpose(int axis_offset) const;
850    
851    /**    /**
852       \brief       \brief
853       Calculate the trace of each data point of this Data object.       Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.
854       sum(A[i,i,i,i])       Currently this function is restricted to rank 2, square shape, and dimension 3.
855       *       *
856    */    */
857      ESCRIPT_DLL_API
858    Data    Data
859    trace() const;    eigenvalues() const;
860    
861      /**
862         \brief
863         Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
864         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
865         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
866         first non-zero entry is positive.
867         Currently this function is restricted to rank 2, square shape, and dimension 3
868         *
869      */
870      ESCRIPT_DLL_API
871      const boost::python::tuple
872      eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
873    
874      /**
875         \brief
876         swaps the components axis0 and axis1
877         *
878      */
879      ESCRIPT_DLL_API
880      Data
881      swapaxes(const int axis0, const int axis1) const;
882    
883      /**
884         \brief
885         Return the error function erf of each data point of this Data object.
886         *
887      */
888      ESCRIPT_DLL_API
889      Data
890      erf() const;
891    
892    /**    /**
893       \brief       \brief
894       Return the sin of each data point of this Data object.       Return the sin of each data point of this Data object.
895       *       *
896    */    */
897      ESCRIPT_DLL_API
898    Data    Data
899    sin() const;    sin() const;
900    
# Line 744  class Data { Line 903  class Data {
903       Return the cos of each data point of this Data object.       Return the cos of each data point of this Data object.
904       *       *
905    */    */
906      ESCRIPT_DLL_API
907    Data    Data
908    cos() const;    cos() const;
909    
# Line 752  class Data { Line 912  class Data {
912       Return the tan of each data point of this Data object.       Return the tan of each data point of this Data object.
913       *       *
914    */    */
915      ESCRIPT_DLL_API
916    Data    Data
917    tan() const;    tan() const;
918    
# Line 760  class Data { Line 921  class Data {
921       Return the asin of each data point of this Data object.       Return the asin of each data point of this Data object.
922       *       *
923    */    */
924      ESCRIPT_DLL_API
925    Data    Data
926    asin() const;    asin() const;
927    
# Line 768  class Data { Line 930  class Data {
930       Return the acos of each data point of this Data object.       Return the acos of each data point of this Data object.
931       *       *
932    */    */
933      ESCRIPT_DLL_API
934    Data    Data
935    acos() const;    acos() const;
936    
# Line 776  class Data { Line 939  class Data {
939       Return the atan of each data point of this Data object.       Return the atan of each data point of this Data object.
940       *       *
941    */    */
942      ESCRIPT_DLL_API
943    Data    Data
944    atan() const;    atan() const;
945    
# Line 784  class Data { Line 948  class Data {
948       Return the sinh of each data point of this Data object.       Return the sinh of each data point of this Data object.
949       *       *
950    */    */
951      ESCRIPT_DLL_API
952    Data    Data
953    sinh() const;    sinh() const;
954    
# Line 792  class Data { Line 957  class Data {
957       Return the cosh of each data point of this Data object.       Return the cosh of each data point of this Data object.
958       *       *
959    */    */
960      ESCRIPT_DLL_API
961    Data    Data
962    cosh() const;    cosh() const;
963    
# Line 800  class Data { Line 966  class Data {
966       Return the tanh of each data point of this Data object.       Return the tanh of each data point of this Data object.
967       *       *
968    */    */
969      ESCRIPT_DLL_API
970    Data    Data
971    tanh() const;    tanh() const;
972    
# Line 808  class Data { Line 975  class Data {
975       Return the asinh of each data point of this Data object.       Return the asinh of each data point of this Data object.
976       *       *
977    */    */
978      ESCRIPT_DLL_API
979    Data    Data
980    asinh() const;    asinh() const;
981    
# Line 816  class Data { Line 984  class Data {
984       Return the acosh of each data point of this Data object.       Return the acosh of each data point of this Data object.
985       *       *
986    */    */
987      ESCRIPT_DLL_API
988    Data    Data
989    acosh() const;    acosh() const;
990    
# Line 824  class Data { Line 993  class Data {
993       Return the atanh of each data point of this Data object.       Return the atanh of each data point of this Data object.
994       *       *
995    */    */
996      ESCRIPT_DLL_API
997    Data    Data
998    atanh() const;    atanh() const;
999    
# Line 832  class Data { Line 1002  class Data {
1002       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.
1003       *       *
1004    */    */
1005      ESCRIPT_DLL_API
1006    Data    Data
1007    log10() const;    log10() const;
1008    
# Line 840  class Data { Line 1011  class Data {
1011       Return the natural log of each data point of this Data object.       Return the natural log of each data point of this Data object.
1012       *       *
1013    */    */
1014      ESCRIPT_DLL_API
1015    Data    Data
1016    log() const;    log() const;
1017    
# Line 848  class Data { Line 1020  class Data {
1020       Return the exponential function of each data point of this Data object.       Return the exponential function of each data point of this Data object.
1021       *       *
1022    */    */
1023      ESCRIPT_DLL_API
1024    Data    Data
1025    exp() const;    exp() const;
1026    
# Line 856  class Data { Line 1029  class Data {
1029       Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
1030       *       *
1031    */    */
1032      ESCRIPT_DLL_API
1033    Data    Data
1034    sqrt() const;    sqrt() const;
1035    
# Line 864  class Data { Line 1038  class Data {
1038       Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
1039       *       *
1040    */    */
1041      ESCRIPT_DLL_API
1042    Data    Data
1043    neg() const;    neg() const;
1044    
# Line 873  class Data { Line 1048  class Data {
1048       Simply returns this object unmodified.       Simply returns this object unmodified.
1049       *       *
1050    */    */
1051      ESCRIPT_DLL_API
1052    Data    Data
1053    pos() const;    pos() const;
1054    
# Line 883  class Data { Line 1059  class Data {
1059       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1060       *       *
1061    */    */
1062      ESCRIPT_DLL_API
1063    Data    Data
1064    powD(const Data& right) const;    powD(const Data& right) const;
1065    
# Line 893  class Data { Line 1070  class Data {
1070       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1071       *       *
1072     */     */
1073      ESCRIPT_DLL_API
1074    Data    Data
1075    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
1076    
1077    /**    /**
1078       \brief       \brief
1079         Return the given power of each data point of this boost python object.
1080        
1081         \param left Input - the bases
1082         *
1083       */
1084    
1085      ESCRIPT_DLL_API
1086      Data
1087      rpowO(const boost::python::object& left) const;
1088    
1089      /**
1090         \brief
1091       writes the object to a file in the DX file format       writes the object to a file in the DX file format
1092    */    */
1093      ESCRIPT_DLL_API
1094    void    void
1095    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
1096    
# Line 907  class Data { Line 1098  class Data {
1098       \brief       \brief
1099       writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
1100    */    */
1101      ESCRIPT_DLL_API
1102    void    void
1103    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
1104    
# Line 916  class Data { Line 1108  class Data {
1108       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1109       *       *
1110    */    */
1111      ESCRIPT_DLL_API
1112    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
1113      ESCRIPT_DLL_API
1114    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
1115    
1116    /**    /**
# Line 925  class Data { Line 1119  class Data {
1119       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1120       *       *
1121    */    */
1122      ESCRIPT_DLL_API
1123    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
1124      ESCRIPT_DLL_API
1125    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
1126    
1127   /**   /**
# Line 934  class Data { Line 1130  class Data {
1130       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1131       *       *
1132    */    */
1133      ESCRIPT_DLL_API
1134    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
1135      ESCRIPT_DLL_API
1136    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
1137    
1138   /**   /**
# Line 943  class Data { Line 1141  class Data {
1141       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1142       *       *
1143    */    */
1144      ESCRIPT_DLL_API
1145    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
1146      ESCRIPT_DLL_API
1147    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
1148    
1149    /**    /**
1150       \brief       \brief
1151       Returns true if this can be interpolated to functionspace.       Returns true if this can be interpolated to functionspace.
1152    */    */
1153      ESCRIPT_DLL_API
1154    bool    bool
1155    probeInterpolation(const FunctionSpace& functionspace) const;    probeInterpolation(const FunctionSpace& functionspace) const;
1156    
# Line 968  class Data { Line 1169  class Data {
1169       \param key - Input - python slice tuple specifying       \param key - Input - python slice tuple specifying
1170       slice to return.       slice to return.
1171    */    */
1172      ESCRIPT_DLL_API
1173    Data    Data
1174    getItem(const boost::python::object& key) const;    getItem(const boost::python::object& key) const;
1175    
# Line 982  class Data { Line 1184  class Data {
1184       slice to copy from value.       slice to copy from value.
1185       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
1186    */    */
1187      ESCRIPT_DLL_API
1188    void    void
1189    setItemD(const boost::python::object& key,    setItemD(const boost::python::object& key,
1190             const Data& value);             const Data& value);
1191    
1192      ESCRIPT_DLL_API
1193    void    void
1194    setItemO(const boost::python::object& key,    setItemO(const boost::python::object& key,
1195             const boost::python::object& value);             const boost::python::object& value);
# Line 998  class Data { Line 1202  class Data {
1202       this Data object.       this Data object.
1203    */    */
1204    template <class UnaryFunction>    template <class UnaryFunction>
1205      ESCRIPT_DLL_API
1206    inline    inline
1207    void    void
1208    unaryOp(UnaryFunction operation);    unaryOp(UnaryFunction operation);
# Line 1009  class Data { Line 1214  class Data {
1214       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1215       *       *
1216    */    */
1217      ESCRIPT_DLL_API
1218    Data    Data
1219    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
1220    
# Line 1020  class Data { Line 1226  class Data {
1226       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1227       *       *
1228    */    */
1229      ESCRIPT_DLL_API
1230    void    void
1231    setSlice(const Data& value,    setSlice(const Data& value,
1232             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
# Line 1029  class Data { Line 1236  class Data {
1236       Archive the current Data object to the given file.       Archive the current Data object to the given file.
1237       \param fileName - Input - file to archive to.       \param fileName - Input - file to archive to.
1238    */    */
1239      ESCRIPT_DLL_API
1240    void    void
1241    archiveData(const std::string fileName);    archiveData(const std::string fileName);
1242    
# Line 1040  class Data { Line 1248  class Data {
1248       \param fileName - Input - file to extract from.       \param fileName - Input - file to extract from.
1249       \param fspace - Input - a suitable FunctionSpace descibing the data.       \param fspace - Input - a suitable FunctionSpace descibing the data.
1250    */    */
1251      ESCRIPT_DLL_API
1252    void    void
1253    extractData(const std::string fileName,    extractData(const std::string fileName,
1254                const FunctionSpace& fspace);                const FunctionSpace& fspace);
1255    
1256    
1257      /**
1258         \brief
1259         print the data values to stdout. Used for debugging
1260      */
1261      ESCRIPT_DLL_API
1262      void
1263        print(void);
1264    
1265      /**
1266         \brief
1267         return the MPI rank number of the local data
1268             MPI_COMM_WORLD is assumed and the result of MPI_Comm_size()
1269             is returned
1270      */
1271      ESCRIPT_DLL_API
1272        int
1273        get_MPIRank(void) const;
1274    
1275      /**
1276         \brief
1277         return the MPI rank number of the local data
1278             MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank()
1279             is returned
1280      */
1281      ESCRIPT_DLL_API
1282        int
1283        get_MPISize(void) const;
1284    
1285      /**
1286         \brief
1287         return the MPI rank number of the local data
1288             MPI_COMM_WORLD is assumed and returned.
1289      */
1290      ESCRIPT_DLL_API
1291        MPI_Comm
1292        get_MPIComm(void) const;
1293    
1294      /**
1295         \brief
1296         return the object produced by the factory, which is a DataConstant or DataExpanded
1297      */
1298      ESCRIPT_DLL_API
1299        DataAbstract*
1300        borrowData(void) const;
1301    
1302   protected:   protected:
1303    
1304   private:   private:
# Line 1101  class Data { Line 1356  class Data {
1356    
1357    /**    /**
1358       \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  
1359       Convert the data type of the RHS to match this.       Convert the data type of the RHS to match this.
1360       \param right - Input - data type to match.       \param right - Input - data type to match.
1361    */    */
# Line 1136  class Data { Line 1380  class Data {
1380               const FunctionSpace& what,               const FunctionSpace& what,
1381               bool expanded);               bool expanded);
1382    
1383    /**    //
1384       \brief    // flag to protect the data object against any update
1385       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);  
1386    
1387    //    //
1388    // pointer to the actual data object    // pointer to the actual data object
# Line 1181  Data::initialise(const IValueType& value Line 1419  Data::initialise(const IValueType& value
1419  /**  /**
1420     Binary Data object operators.     Binary Data object operators.
1421  */  */
1422    inline double rpow(double x,double y)
1423    {
1424        return pow(y,x);
1425    }
1426    
1427  /**  /**
1428    \brief    \brief
1429    Operator+    Operator+
1430    Takes two Data objects.    Takes two Data objects.
1431  */  */
1432  Data operator+(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const Data& right);
1433    
1434  /**  /**
1435    \brief    \brief
1436    Operator-    Operator-
1437    Takes two Data objects.    Takes two Data objects.
1438  */  */
1439  Data operator-(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const Data& right);
1440    
1441  /**  /**
1442    \brief    \brief
1443    Operator*    Operator*
1444    Takes two Data objects.    Takes two Data objects.
1445  */  */
1446  Data operator*(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const Data& right);
1447    
1448  /**  /**
1449    \brief    \brief
1450    Operator/    Operator/
1451    Takes two Data objects.    Takes two Data objects.
1452  */  */
1453  Data operator/(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const Data& right);
1454    
1455  /**  /**
1456    \brief    \brief
# Line 1216  Data operator/(const Data& left, const D Line 1458  Data operator/(const Data& left, const D
1458    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1459    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1460  */  */
1461  Data operator+(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const boost::python::object& right);
1462    
1463  /**  /**
1464    \brief    \brief
# Line 1224  Data operator+(const Data& left, const b Line 1466  Data operator+(const Data& left, const b
1466    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1467    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1468  */  */
1469  Data operator-(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const boost::python::object& right);
1470    
1471  /**  /**
1472    \brief    \brief
# Line 1232  Data operator-(const Data& left, const b Line 1474  Data operator-(const Data& left, const b
1474    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1475    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1476  */  */
1477  Data operator*(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const boost::python::object& right);
1478    
1479  /**  /**
1480    \brief    \brief
# Line 1240  Data operator*(const Data& left, const b Line 1482  Data operator*(const Data& left, const b
1482    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1483    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1484  */  */
1485  Data operator/(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const boost::python::object& right);
1486    
1487  /**  /**
1488    \brief    \brief
# Line 1248  Data operator/(const Data& left, const b Line 1490  Data operator/(const Data& left, const b
1490    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1491    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1492  */  */
1493  Data operator+(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const boost::python::object& left, const Data& right);
1494    
1495  /**  /**
1496    \brief    \brief
# Line 1256  Data operator+(const boost::python::obje Line 1498  Data operator+(const boost::python::obje
1498    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1499    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1500  */  */
1501  Data operator-(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const boost::python::object& left, const Data& right);
1502    
1503  /**  /**
1504    \brief    \brief
# Line 1264  Data operator-(const boost::python::obje Line 1506  Data operator-(const boost::python::obje
1506    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1507    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1508  */  */
1509  Data operator*(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const boost::python::object& left, const Data& right);
1510    
1511  /**  /**
1512    \brief    \brief
# Line 1272  Data operator*(const boost::python::obje Line 1514  Data operator*(const boost::python::obje
1514    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1515    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1516  */  */
1517  Data operator/(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const boost::python::object& left, const Data& right);
1518    
1519  /**  /**
1520    \brief    \brief
1521    Output operator    Output operator
1522  */  */
1523  std::ostream& operator<<(std::ostream& o, const Data& data);  ESCRIPT_DLL_API std::ostream& operator<<(std::ostream& o, const Data& data);
1524    
1525    /**
1526      \brief
1527      Compute a tensor product of two Data objects
1528      \param arg0 - Input - Data object
1529      \param arg1 - Input - Data object
1530      \param axis_offset - Input - axis offset
1531      \param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1
1532    */
1533    ESCRIPT_DLL_API
1534    Data
1535    C_GeneralTensorProduct(Data& arg0,
1536                         Data& arg1,
1537                         int axis_offset=0,
1538                         int transpose=0);
1539    
1540  /**  /**
1541    \brief    \brief
# Line 1286  std::ostream& operator<<(std::ostream& o Line 1543  std::ostream& operator<<(std::ostream& o
1543    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
1544    be relied on. Requires further implementation.    be relied on. Requires further implementation.
1545  */  */
1546  //bool operator==(const Data& left, const Data& right);  //ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);
1547    
1548  /**  /**
1549    \brief    \brief
# Line 1302  Data::binaryOp(const Data& right, Line 1559  Data::binaryOp(const Data& right,
1559     //     //
1560     // 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
1561     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {
1562       reshapeDataPoint(right.getPointDataView().getShape());       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1563     }     }
1564     //     //
1565     // initially make the temporary a shallow copy     // initially make the temporary a shallow copy
# Line 1354  Data::binaryOp(const Data& right, Line 1611  Data::binaryOp(const Data& right,
1611       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");       EsysAssert((leftC!=0 && rightC!=0), "Programming error - casting to DataConstant.");
1612       escript::binaryOp(*leftC,*rightC,operation);       escript::binaryOp(*leftC,*rightC,operation);
1613     }     }
1614  }     #if defined DOPROF
1615       profData->binary++;
1616  /**     #endif
   \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);  
    }  
1617  }  }
1618    
1619  /**  /**
# Line 1483  inline Line 1703  inline
1703  Data  Data
1704  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1705  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1706    if (isExpanded()) {    if (isExpanded()) {
1707        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1708      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1709      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1710      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1711      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1712      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1713        return result;
1714    } else if (isTagged()) {    } else if (isTagged()) {
1715      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1716        DataArrayView::ShapeType viewShape;
1717        DataArrayView::ValueType viewData(1);
1718        viewData[0]=0;
1719        DataArrayView defaultValue(viewData,viewShape);
1720        DataTagged::TagListType keys;
1721        DataTagged::ValueListType values;
1722        DataTagged::DataMapType::const_iterator i;
1723        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1724          keys.push_back(i->first);
1725          values.push_back(defaultValue);
1726        }
1727        Data result(keys,values,defaultValue,getFunctionSpace());
1728      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1729      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1730      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1731      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1732        return result;
1733    } else if (isConstant()) {    } else if (isConstant()) {
1734        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1735      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1736      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1737      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1738      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1739      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1740        return result;
1741    }    }
1742    return result;    Data falseRetVal; // to keep compiler quiet
1743      return falseRetVal;
1744  }  }
1745    
1746  }  }

Legend:
Removed from v.474  
changed lines
  Added in v.1044

  ViewVC Help
Powered by ViewVC 1.1.26