/[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 1141 by gross, Tue May 15 04:24:51 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
251         Returns trueif the data object is protected against update
252    
253      */
254      ESCRIPT_DLL_API
255      bool
256      isProtected() const;
257    
258    /**    /**
259       \brief       \brief
260       Return the values of all data-points for the given sample 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    convertToNumArrayFromSampleNo(int sampleNo);    getValueOfDataPoint(int dataPointNo);
265    
266    /**    /**
267       \brief       \brief
268       Return the value of the specified data-point as a single python numarray object.       sets the values of a data-point from a python object on this process
269    */    */
270    const boost::python::numeric::array    ESCRIPT_DLL_API
271    convertToNumArrayFromDPNo(int sampleNo,    void
272                              int dataPointNo);    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       \brief
284       Fills the expanded Data object from values of a python numarray object.       sets the values of a data-point on this process
285    */    */
286      ESCRIPT_DLL_API
287    void    void
288    fillFromNumArray(const boost::python::numeric::array);    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
333    {    {
334      return m_data->toString();      return m_data->toString();
335    }    }
336      
337      /**
338         \brief
339         Return a description for this domain for python.
340      */
341      ESCRIPT_DLL_API
342      const boost::python::str str() const;
343    
344    /**    /**
345       \brief       \brief
# Line 293  class Data { Line 347  class Data {
347       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
348       to manipulate the point data.       to manipulate the point data.
349    */    */
350      ESCRIPT_DLL_API
351    inline    inline
352    const DataArrayView&    const DataArrayView&
353    getPointDataView() const    getPointDataView() const
# Line 304  class Data { Line 359  class Data {
359       \brief       \brief
360       Whatever the current Data type make this into a DataExpanded.       Whatever the current Data type make this into a DataExpanded.
361    */    */
362      ESCRIPT_DLL_API
363    void    void
364    expand();    expand();
365    
# Line 312  class Data { Line 368  class Data {
368       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
369       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
370       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
371        ==>*
372    */    */
373      ESCRIPT_DLL_API
374    void    void
375    tag();    tag();
376    
# Line 320  class Data { Line 378  class Data {
378       \brief       \brief
379       Return true if this Data is expanded.       Return true if this Data is expanded.
380    */    */
381      ESCRIPT_DLL_API
382    bool    bool
383    isExpanded() const;    isExpanded() const;
384    
# Line 327  class Data { Line 386  class Data {
386       \brief       \brief
387       Return true if this Data is tagged.       Return true if this Data is tagged.
388    */    */
389      ESCRIPT_DLL_API
390    bool    bool
391    isTagged() const;    isTagged() const;
392    
# Line 334  class Data { Line 394  class Data {
394       \brief       \brief
395       Return true if this Data is constant.       Return true if this Data is constant.
396    */    */
397      ESCRIPT_DLL_API
398    bool    bool
399    isConstant() const;    isConstant() const;
400    
# Line 341  class Data { Line 402  class Data {
402       \brief       \brief
403       Return true if this Data is empty.       Return true if this Data is empty.
404    */    */
405      ESCRIPT_DLL_API
406    bool    bool
407    isEmpty() const;    isEmpty() const;
408    
# Line 348  class Data { Line 410  class Data {
410       \brief       \brief
411       Return the function space.       Return the function space.
412    */    */
413      ESCRIPT_DLL_API
414    inline    inline
415    const FunctionSpace&    const FunctionSpace&
416    getFunctionSpace() const    getFunctionSpace() const
# Line 359  class Data { Line 422  class Data {
422       \brief       \brief
423       Return a copy of the function space.       Return a copy of the function space.
424    */    */
425      ESCRIPT_DLL_API
426    const FunctionSpace    const FunctionSpace
427    getCopyOfFunctionSpace() const;    getCopyOfFunctionSpace() const;
428    
# Line 366  class Data { Line 430  class Data {
430       \brief       \brief
431       Return the domain.       Return the domain.
432    */    */
433      ESCRIPT_DLL_API
434    inline    inline
435    const AbstractDomain&    const AbstractDomain&
436    getDomain() const    getDomain() const
# Line 377  class Data { Line 442  class Data {
442       \brief       \brief
443       Return a copy of the domain.       Return a copy of the domain.
444    */    */
445      ESCRIPT_DLL_API
446    const AbstractDomain    const AbstractDomain
447    getCopyOfDomain() const;    getCopyOfDomain() const;
448    
# Line 384  class Data { Line 450  class Data {
450       \brief       \brief
451       Return the rank of the point data.       Return the rank of the point data.
452    */    */
453      ESCRIPT_DLL_API
454    inline    inline
455    int    int
456    getDataPointRank() const    getDataPointRank() const
# Line 393  class Data { Line 460  class Data {
460    
461    /**    /**
462       \brief       \brief
463         Return the number of data points
464      */
465      ESCRIPT_DLL_API
466      inline
467      int
468      getNumDataPoints() const
469      {
470        return getNumSamples() * getNumDataPointsPerSample();
471      }
472      /**
473         \brief
474       Return the number of samples.       Return the number of samples.
475    */    */
476      ESCRIPT_DLL_API
477    inline    inline
478    int    int
479    getNumSamples() const    getNumSamples() const
# Line 406  class Data { Line 485  class Data {
485       \brief       \brief
486       Return the number of data points per sample.       Return the number of data points per sample.
487    */    */
488      ESCRIPT_DLL_API
489    inline    inline
490    int    int
491    getNumDataPointsPerSample() const    getNumDataPointsPerSample() const
492    {    {
493      return m_data->getNumDPPSample();      return m_data->getNumDPPSample();
494    }    }
495      /**
496         \brief
497         dumps the object into a netCDF file
498      */
499      ESCRIPT_DLL_API
500      void
501      dump(const std::string fileName) const;
502    /**    /**
503       \brief       \brief
504       Return the sample data for the given sample no. This is not the       Return the sample data for the given sample no. This is not the
505       preferred interface but is provided for use by C code.       preferred interface but is provided for use by C code.
506       \param sampleNo - Input - the given sample no.       \param sampleNo - Input - the given sample no.
507    */    */
508      ESCRIPT_DLL_API
509    inline    inline
510    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
511    getSampleData(DataAbstract::ValueType::size_type sampleNo)    getSampleData(DataAbstract::ValueType::size_type sampleNo)
# Line 432  class Data { Line 519  class Data {
519       access data that isn't tagged an exception will be thrown.       access data that isn't tagged an exception will be thrown.
520       \param tag - Input - the tag key.       \param tag - Input - the tag key.
521    */    */
522      ESCRIPT_DLL_API
523    inline    inline
524    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
525    getSampleDataByTag(int tag)    getSampleDataByTag(int tag)
# Line 441  class Data { Line 529  class Data {
529    
530    /**    /**
531       \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  
532       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
533       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
534       operation.       operation.
535       \param sampleNo - Input -       \param sampleNo - Input -
536       \param dataPointNo - Input -       \param dataPointNo - Input -
537    */    */
538      ESCRIPT_DLL_API
539    inline    inline
540    DataArrayView    DataArrayView
541    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
542                 int dataPointNo)                 int dataPointNo)
543    {    {
544      return m_data->getDataPoint(sampleNo,dataPointNo);          return m_data->getDataPoint(sampleNo,dataPointNo);
545    }    }
546    
547    /**    /**
548       \brief       \brief
549       Return a reference to the data point shape.       Return a reference to the data point shape.
550    */    */
551      ESCRIPT_DLL_API
552    const DataArrayView::ShapeType&    const DataArrayView::ShapeType&
553    getDataPointShape() const;    getDataPointShape() const;
554    
# Line 505  class Data { Line 556  class Data {
556       \brief       \brief
557       Return the data point shape as a tuple of integers.       Return the data point shape as a tuple of integers.
558    */    */
559      ESCRIPT_DLL_API
560    const boost::python::tuple    const boost::python::tuple
561    getShapeTuple() const;    getShapeTuple() const;
562    
# Line 513  class Data { Line 565  class Data {
565       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
566       data point shape dimensions.       data point shape dimensions.
567    */    */
568      ESCRIPT_DLL_API
569    int    int
570    getDataPointSize() const;    getDataPointSize() const;
571    
# Line 520  class Data { Line 573  class Data {
573       \brief       \brief
574       Return the number of doubles stored for this Data.       Return the number of doubles stored for this Data.
575    */    */
576      ESCRIPT_DLL_API
577    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
578    getLength() const;    getLength() const;
579    
580    
581    
582      /**
583         \brief
584         Assign the given value to the tag assocciated with name. Implicitly converts this
585         object to type DataTagged. Throws an exception if this object
586         cannot be converted to a DataTagged object or name cannot be mapped onto a tag key.
587         \param tagKey - Input - Integer key.
588         \param value - Input - Value to associate with given key.
589        ==>*
590      */
591      ESCRIPT_DLL_API
592      void
593      setTaggedValueByName(std::string name,
594                           const boost::python::object& value);
595    
596    /**    /**
597       \brief       \brief
598       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 600  class Data {
600       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
601       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
602       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
603        ==>*
604    */    */
605      ESCRIPT_DLL_API
606    void    void
607    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
608                   const boost::python::object& value);                   const boost::python::object& value);
# Line 542  class Data { Line 614  class Data {
614       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
615       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
616       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
617        ==>*
618    */    */
619      ESCRIPT_DLL_API
620    void    void
621    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
622                          const DataArrayView& value);                          const DataArrayView& value);
# Line 551  class Data { Line 625  class Data {
625      \brief      \brief
626      Copy other Data object into this Data object where mask is positive.      Copy other Data object into this Data object where mask is positive.
627    */    */
628      ESCRIPT_DLL_API
629    void    void
630    copyWithMask(const Data& other,    copyWithMask(const Data& other,
631                 const Data& mask);                 const Data& mask);
# Line 561  class Data { Line 636  class Data {
636    
637    /**    /**
638       \brief       \brief
639         set all values to zero
640         *
641      */
642      ESCRIPT_DLL_API
643      void
644      setToZero();
645    
646      /**
647         \brief
648       Interpolates this onto the given functionspace and returns       Interpolates this onto the given functionspace and returns
649       the result as a Data object.       the result as a Data object.
650       *       *
651    */    */
652      ESCRIPT_DLL_API
653    Data    Data
654    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
   
655    /**    /**
656       \brief       \brief
657       Calculates the gradient of the data at the data points of functionspace.       Calculates the gradient of the data at the data points of functionspace.
658       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.
659       *       *
660    */    */
661      ESCRIPT_DLL_API
662    Data    Data
663    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
664    
665      ESCRIPT_DLL_API
666    Data    Data
667    grad() const;    grad() const;
668    
# Line 585  class Data { Line 671  class Data {
671       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
672       *       *
673    */    */
674      ESCRIPT_DLL_API
675    boost::python::numeric::array    boost::python::numeric::array
676    integrate() const;    integrate() const;
677    
678    /**    /**
679       \brief       \brief
680         Returns 1./ Data object
681         *
682      */
683      ESCRIPT_DLL_API
684      Data
685      oneOver() const;
686      /**
687         \brief
688       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.
689       *       *
690    */    */
691      ESCRIPT_DLL_API
692    Data    Data
693    wherePositive() const;    wherePositive() const;
694    
# Line 601  class Data { Line 697  class Data {
697       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.
698       *       *
699    */    */
700      ESCRIPT_DLL_API
701    Data    Data
702    whereNegative() const;    whereNegative() const;
703    
# Line 609  class Data { Line 706  class Data {
706       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.
707       *       *
708    */    */
709      ESCRIPT_DLL_API
710    Data    Data
711    whereNonNegative() const;    whereNonNegative() const;
712    
# Line 617  class Data { Line 715  class Data {
715       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.
716       *       *
717    */    */
718      ESCRIPT_DLL_API
719    Data    Data
720    whereNonPositive() const;    whereNonPositive() const;
721    
# Line 625  class Data { Line 724  class Data {
724       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.
725       *       *
726    */    */
727      ESCRIPT_DLL_API
728    Data    Data
729    whereZero() const;    whereZero(double tol=0.0) const;
730    
731    /**    /**
732       \brief       \brief
733       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.
734       *       *
735    */    */
736      ESCRIPT_DLL_API
737    Data    Data
738    whereNonZero() const;    whereNonZero(double tol=0.0) const;
739    
740    /**    /**
741       \brief       \brief
742       Return the maximum absolute value of this Data object.       Return the maximum absolute value of this Data object.
743       *       *
744    */    */
745      ESCRIPT_DLL_API
746    double    double
747    Lsup() const;    Lsup() const;
748    
# Line 649  class Data { Line 751  class Data {
751       Return the minimum absolute value of this Data object.       Return the minimum absolute value of this Data object.
752       *       *
753    */    */
754      ESCRIPT_DLL_API
755    double    double
756    Linf() const;    Linf() const;
757    
# Line 657  class Data { Line 760  class Data {
760       Return the maximum value of this Data object.       Return the maximum value of this Data object.
761       *       *
762    */    */
763      ESCRIPT_DLL_API
764    double    double
765    sup() const;    sup() const;
766    
# Line 665  class Data { Line 769  class Data {
769       Return the minimum value of this Data object.       Return the minimum value of this Data object.
770       *       *
771    */    */
772      ESCRIPT_DLL_API
773    double    double
774    inf() const;    inf() const;
775    
# Line 673  class Data { Line 778  class Data {
778       Return the absolute value of each data point of this Data object.       Return the absolute value of each data point of this Data object.
779       *       *
780    */    */
781      ESCRIPT_DLL_API
782    Data    Data
783    abs() const;    abs() const;
784    
# Line 681  class Data { Line 787  class Data {
787       Return the maximum value of each data point of this Data object.       Return the maximum value of each data point of this Data object.
788       *       *
789    */    */
790      ESCRIPT_DLL_API
791    Data    Data
792    maxval() const;    maxval() const;
793    
# Line 689  class Data { Line 796  class Data {
796       Return the minimum value of each data point of this Data object.       Return the minimum value of each data point of this Data object.
797       *       *
798    */    */
799      ESCRIPT_DLL_API
800    Data    Data
801    minval() const;    minval() const;
802    
# Line 697  class Data { Line 805  class Data {
805       Return the (sample number, data-point number) of the data point with       Return the (sample number, data-point number) of the data point with
806       the minimum value in this Data object.       the minimum value in this Data object.
807    */    */
808      ESCRIPT_DLL_API
809    const boost::python::tuple    const boost::python::tuple
810    mindp() const;    minGlobalDataPoint() const;
811    
812      ESCRIPT_DLL_API
813    void    void
814    calc_mindp(int& SampleNo,    calc_minGlobalDataPoint(int& ProcNo,  int& DataPointNo) const;
              int& DataPointNo) const;  
   
815    /**    /**
816       \brief       \brief
817       Return the sign of each data point of this Data object.       Return the sign of each data point of this Data object.
818       -1 for negative values, zero for zero values, 1 for positive values.       -1 for negative values, zero for zero values, 1 for positive values.
819       *       *
820    */    */
821      ESCRIPT_DLL_API
822    Data    Data
823    sign() const;    sign() const;
824    
825    /**    /**
826       \brief       \brief
827         Return the symmetric part of a matrix which is half the matrix plus its transpose.
828         *
829      */
830      ESCRIPT_DLL_API
831      Data
832      symmetric() const;
833    
834      /**
835         \brief
836         Return the nonsymmetric part of a matrix which is half the matrix minus its transpose.
837         *
838      */
839      ESCRIPT_DLL_API
840      Data
841      nonsymmetric() const;
842    
843      /**
844         \brief
845         Return the trace of a matrix
846         *
847      */
848      ESCRIPT_DLL_API
849      Data
850      trace(int axis_offset) const;
851    
852      /**
853         \brief
854       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 *--  
855       *       *
856    */    */
857      ESCRIPT_DLL_API
858    Data    Data
859    transpose(int axis) const;    transpose(int axis_offset) const;
860    
861    /**    /**
862       \brief       \brief
863       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.
864       sum(A[i,i,i,i])       Currently this function is restricted to rank 2, square shape, and dimension 3.
865       *       *
866    */    */
867      ESCRIPT_DLL_API
868    Data    Data
869    trace() const;    eigenvalues() const;
870    
871      /**
872         \brief
873         Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
874         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
875         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
876         first non-zero entry is positive.
877         Currently this function is restricted to rank 2, square shape, and dimension 3
878         *
879      */
880      ESCRIPT_DLL_API
881      const boost::python::tuple
882      eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
883    
884      /**
885         \brief
886         swaps the components axis0 and axis1
887         *
888      */
889      ESCRIPT_DLL_API
890      Data
891      swapaxes(const int axis0, const int axis1) const;
892    
893      /**
894         \brief
895         Return the error function erf of each data point of this Data object.
896         *
897      */
898      ESCRIPT_DLL_API
899      Data
900      erf() const;
901    
902    /**    /**
903       \brief       \brief
904       Return the sin of each data point of this Data object.       Return the sin of each data point of this Data object.
905       *       *
906    */    */
907      ESCRIPT_DLL_API
908    Data    Data
909    sin() const;    sin() const;
910    
# Line 744  class Data { Line 913  class Data {
913       Return the cos of each data point of this Data object.       Return the cos of each data point of this Data object.
914       *       *
915    */    */
916      ESCRIPT_DLL_API
917    Data    Data
918    cos() const;    cos() const;
919    
# Line 752  class Data { Line 922  class Data {
922       Return the tan of each data point of this Data object.       Return the tan of each data point of this Data object.
923       *       *
924    */    */
925      ESCRIPT_DLL_API
926    Data    Data
927    tan() const;    tan() const;
928    
# Line 760  class Data { Line 931  class Data {
931       Return the asin of each data point of this Data object.       Return the asin of each data point of this Data object.
932       *       *
933    */    */
934      ESCRIPT_DLL_API
935    Data    Data
936    asin() const;    asin() const;
937    
# Line 768  class Data { Line 940  class Data {
940       Return the acos of each data point of this Data object.       Return the acos of each data point of this Data object.
941       *       *
942    */    */
943      ESCRIPT_DLL_API
944    Data    Data
945    acos() const;    acos() const;
946    
# Line 776  class Data { Line 949  class Data {
949       Return the atan of each data point of this Data object.       Return the atan of each data point of this Data object.
950       *       *
951    */    */
952      ESCRIPT_DLL_API
953    Data    Data
954    atan() const;    atan() const;
955    
# Line 784  class Data { Line 958  class Data {
958       Return the sinh of each data point of this Data object.       Return the sinh of each data point of this Data object.
959       *       *
960    */    */
961      ESCRIPT_DLL_API
962    Data    Data
963    sinh() const;    sinh() const;
964    
# Line 792  class Data { Line 967  class Data {
967       Return the cosh of each data point of this Data object.       Return the cosh of each data point of this Data object.
968       *       *
969    */    */
970      ESCRIPT_DLL_API
971    Data    Data
972    cosh() const;    cosh() const;
973    
# Line 800  class Data { Line 976  class Data {
976       Return the tanh of each data point of this Data object.       Return the tanh of each data point of this Data object.
977       *       *
978    */    */
979      ESCRIPT_DLL_API
980    Data    Data
981    tanh() const;    tanh() const;
982    
# Line 808  class Data { Line 985  class Data {
985       Return the asinh of each data point of this Data object.       Return the asinh of each data point of this Data object.
986       *       *
987    */    */
988      ESCRIPT_DLL_API
989    Data    Data
990    asinh() const;    asinh() const;
991    
# Line 816  class Data { Line 994  class Data {
994       Return the acosh of each data point of this Data object.       Return the acosh of each data point of this Data object.
995       *       *
996    */    */
997      ESCRIPT_DLL_API
998    Data    Data
999    acosh() const;    acosh() const;
1000    
# Line 824  class Data { Line 1003  class Data {
1003       Return the atanh of each data point of this Data object.       Return the atanh of each data point of this Data object.
1004       *       *
1005    */    */
1006      ESCRIPT_DLL_API
1007    Data    Data
1008    atanh() const;    atanh() const;
1009    
# Line 832  class Data { Line 1012  class Data {
1012       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.
1013       *       *
1014    */    */
1015      ESCRIPT_DLL_API
1016    Data    Data
1017    log10() const;    log10() const;
1018    
# Line 840  class Data { Line 1021  class Data {
1021       Return the natural log of each data point of this Data object.       Return the natural log of each data point of this Data object.
1022       *       *
1023    */    */
1024      ESCRIPT_DLL_API
1025    Data    Data
1026    log() const;    log() const;
1027    
# Line 848  class Data { Line 1030  class Data {
1030       Return the exponential function of each data point of this Data object.       Return the exponential function of each data point of this Data object.
1031       *       *
1032    */    */
1033      ESCRIPT_DLL_API
1034    Data    Data
1035    exp() const;    exp() const;
1036    
# Line 856  class Data { Line 1039  class Data {
1039       Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
1040       *       *
1041    */    */
1042      ESCRIPT_DLL_API
1043    Data    Data
1044    sqrt() const;    sqrt() const;
1045    
# Line 864  class Data { Line 1048  class Data {
1048       Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
1049       *       *
1050    */    */
1051      ESCRIPT_DLL_API
1052    Data    Data
1053    neg() const;    neg() const;
1054    
# Line 873  class Data { Line 1058  class Data {
1058       Simply returns this object unmodified.       Simply returns this object unmodified.
1059       *       *
1060    */    */
1061      ESCRIPT_DLL_API
1062    Data    Data
1063    pos() const;    pos() const;
1064    
# Line 883  class Data { Line 1069  class Data {
1069       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1070       *       *
1071    */    */
1072      ESCRIPT_DLL_API
1073    Data    Data
1074    powD(const Data& right) const;    powD(const Data& right) const;
1075    
# Line 893  class Data { Line 1080  class Data {
1080       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1081       *       *
1082     */     */
1083      ESCRIPT_DLL_API
1084    Data    Data
1085    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
1086    
1087    /**    /**
1088       \brief       \brief
1089         Return the given power of each data point of this boost python object.
1090        
1091         \param left Input - the bases
1092         *
1093       */
1094    
1095      ESCRIPT_DLL_API
1096      Data
1097      rpowO(const boost::python::object& left) const;
1098    
1099      /**
1100         \brief
1101       writes the object to a file in the DX file format       writes the object to a file in the DX file format
1102    */    */
1103      ESCRIPT_DLL_API
1104    void    void
1105    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
1106    
# Line 907  class Data { Line 1108  class Data {
1108       \brief       \brief
1109       writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
1110    */    */
1111      ESCRIPT_DLL_API
1112    void    void
1113    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
1114    
# Line 916  class Data { Line 1118  class Data {
1118       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1119       *       *
1120    */    */
1121      ESCRIPT_DLL_API
1122    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
1123      ESCRIPT_DLL_API
1124    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
1125    
1126    /**    /**
# Line 925  class Data { Line 1129  class Data {
1129       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1130       *       *
1131    */    */
1132      ESCRIPT_DLL_API
1133    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
1134      ESCRIPT_DLL_API
1135    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
1136    
1137   /**   /**
# Line 934  class Data { Line 1140  class Data {
1140       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1141       *       *
1142    */    */
1143      ESCRIPT_DLL_API
1144    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
1145      ESCRIPT_DLL_API
1146    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
1147    
1148   /**   /**
# Line 943  class Data { Line 1151  class Data {
1151       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1152       *       *
1153    */    */
1154      ESCRIPT_DLL_API
1155    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
1156      ESCRIPT_DLL_API
1157    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
1158    
1159    /**    /**
1160       \brief       \brief
1161       Returns true if this can be interpolated to functionspace.       Returns true if this can be interpolated to functionspace.
1162    */    */
1163      ESCRIPT_DLL_API
1164    bool    bool
1165    probeInterpolation(const FunctionSpace& functionspace) const;    probeInterpolation(const FunctionSpace& functionspace) const;
1166    
# Line 968  class Data { Line 1179  class Data {
1179       \param key - Input - python slice tuple specifying       \param key - Input - python slice tuple specifying
1180       slice to return.       slice to return.
1181    */    */
1182      ESCRIPT_DLL_API
1183    Data    Data
1184    getItem(const boost::python::object& key) const;    getItem(const boost::python::object& key) const;
1185    
# Line 982  class Data { Line 1194  class Data {
1194       slice to copy from value.       slice to copy from value.
1195       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
1196    */    */
1197      ESCRIPT_DLL_API
1198    void    void
1199    setItemD(const boost::python::object& key,    setItemD(const boost::python::object& key,
1200             const Data& value);             const Data& value);
1201    
1202      ESCRIPT_DLL_API
1203    void    void
1204    setItemO(const boost::python::object& key,    setItemO(const boost::python::object& key,
1205             const boost::python::object& value);             const boost::python::object& value);
# Line 998  class Data { Line 1212  class Data {
1212       this Data object.       this Data object.
1213    */    */
1214    template <class UnaryFunction>    template <class UnaryFunction>
1215      ESCRIPT_DLL_API
1216    inline    inline
1217    void    void
1218    unaryOp(UnaryFunction operation);    unaryOp(UnaryFunction operation);
# Line 1009  class Data { Line 1224  class Data {
1224       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1225       *       *
1226    */    */
1227      ESCRIPT_DLL_API
1228    Data    Data
1229    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
1230    
# Line 1020  class Data { Line 1236  class Data {
1236       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1237       *       *
1238    */    */
1239      ESCRIPT_DLL_API
1240    void    void
1241    setSlice(const Data& value,    setSlice(const Data& value,
1242             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
# Line 1029  class Data { Line 1246  class Data {
1246       Archive the current Data object to the given file.       Archive the current Data object to the given file.
1247       \param fileName - Input - file to archive to.       \param fileName - Input - file to archive to.
1248    */    */
1249      ESCRIPT_DLL_API
1250    void    void
1251    archiveData(const std::string fileName);    archiveData(const std::string fileName);
1252    
# Line 1040  class Data { Line 1258  class Data {
1258       \param fileName - Input - file to extract from.       \param fileName - Input - file to extract from.
1259       \param fspace - Input - a suitable FunctionSpace descibing the data.       \param fspace - Input - a suitable FunctionSpace descibing the data.
1260    */    */
1261      ESCRIPT_DLL_API
1262    void    void
1263    extractData(const std::string fileName,    extractData(const std::string fileName,
1264                const FunctionSpace& fspace);                const FunctionSpace& fspace);
1265    
1266    
1267      /**
1268         \brief
1269         print the data values to stdout. Used for debugging
1270      */
1271      ESCRIPT_DLL_API
1272      void
1273        print(void);
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_size()
1279             is returned
1280      */
1281      ESCRIPT_DLL_API
1282        int
1283        get_MPIRank(void) const;
1284    
1285      /**
1286         \brief
1287         return the MPI rank number of the local data
1288             MPI_COMM_WORLD is assumed and the result of MPI_Comm_rank()
1289             is returned
1290      */
1291      ESCRIPT_DLL_API
1292        int
1293        get_MPISize(void) const;
1294    
1295      /**
1296         \brief
1297         return the MPI rank number of the local data
1298             MPI_COMM_WORLD is assumed and returned.
1299      */
1300      ESCRIPT_DLL_API
1301        MPI_Comm
1302        get_MPIComm(void) const;
1303    
1304      /**
1305         \brief
1306         return the object produced by the factory, which is a DataConstant or DataExpanded
1307      */
1308      ESCRIPT_DLL_API
1309        DataAbstract*
1310        borrowData(void) const;
1311    
1312   protected:   protected:
1313    
1314   private:   private:
# Line 1101  class Data { Line 1366  class Data {
1366    
1367    /**    /**
1368       \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  
1369       Convert the data type of the RHS to match this.       Convert the data type of the RHS to match this.
1370       \param right - Input - data type to match.       \param right - Input - data type to match.
1371    */    */
# Line 1136  class Data { Line 1390  class Data {
1390               const FunctionSpace& what,               const FunctionSpace& what,
1391               bool expanded);               bool expanded);
1392    
1393    /**    //
1394       \brief    // flag to protect the data object against any update
1395       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);  
1396    
1397    //    //
1398    // pointer to the actual data object    // pointer to the actual data object
1399    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1400    
   //  
   // pointer to the internal profiling data  
   struct profDataEntry *profData;  
   
1401  };  };
1402    
1403  template <class IValueType>  template <class IValueType>
# Line 1181  Data::initialise(const IValueType& value Line 1425  Data::initialise(const IValueType& value
1425  /**  /**
1426     Binary Data object operators.     Binary Data object operators.
1427  */  */
1428    inline double rpow(double x,double y)
1429    {
1430        return pow(y,x);
1431    }
1432    
1433  /**  /**
1434    \brief    \brief
1435    Operator+    Operator+
1436    Takes two Data objects.    Takes two Data objects.
1437  */  */
1438  Data operator+(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const Data& right);
1439    
1440  /**  /**
1441    \brief    \brief
1442    Operator-    Operator-
1443    Takes two Data objects.    Takes two Data objects.
1444  */  */
1445  Data operator-(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const Data& right);
1446    
1447  /**  /**
1448    \brief    \brief
1449    Operator*    Operator*
1450    Takes two Data objects.    Takes two Data objects.
1451  */  */
1452  Data operator*(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const Data& right);
1453    
1454  /**  /**
1455    \brief    \brief
1456    Operator/    Operator/
1457    Takes two Data objects.    Takes two Data objects.
1458  */  */
1459  Data operator/(const Data& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const Data& right);
1460    
1461  /**  /**
1462    \brief    \brief
# Line 1216  Data operator/(const Data& left, const D Line 1464  Data operator/(const Data& left, const D
1464    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1465    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1466  */  */
1467  Data operator+(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator+(const Data& left, const boost::python::object& right);
1468    
1469  /**  /**
1470    \brief    \brief
# Line 1224  Data operator+(const Data& left, const b Line 1472  Data operator+(const Data& left, const b
1472    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1473    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1474  */  */
1475  Data operator-(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator-(const Data& left, const boost::python::object& right);
1476    
1477  /**  /**
1478    \brief    \brief
# Line 1232  Data operator-(const Data& left, const b Line 1480  Data operator-(const Data& left, const b
1480    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1481    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1482  */  */
1483  Data operator*(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator*(const Data& left, const boost::python::object& right);
1484    
1485  /**  /**
1486    \brief    \brief
# Line 1240  Data operator*(const Data& left, const b Line 1488  Data operator*(const Data& left, const b
1488    Takes LHS Data object and RHS python::object.    Takes LHS Data object and RHS python::object.
1489    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1490  */  */
1491  Data operator/(const Data& left, const boost::python::object& right);  ESCRIPT_DLL_API Data operator/(const Data& left, const boost::python::object& right);
1492    
1493  /**  /**
1494    \brief    \brief
# Line 1248  Data operator/(const Data& left, const b Line 1496  Data operator/(const Data& left, const b
1496    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1497    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1498  */  */
1499  Data operator+(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator+(const boost::python::object& left, const Data& right);
1500    
1501  /**  /**
1502    \brief    \brief
# Line 1256  Data operator+(const boost::python::obje Line 1504  Data operator+(const boost::python::obje
1504    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1505    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1506  */  */
1507  Data operator-(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator-(const boost::python::object& left, const Data& right);
1508    
1509  /**  /**
1510    \brief    \brief
# Line 1264  Data operator-(const boost::python::obje Line 1512  Data operator-(const boost::python::obje
1512    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1513    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1514  */  */
1515  Data operator*(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator*(const boost::python::object& left, const Data& right);
1516    
1517  /**  /**
1518    \brief    \brief
# Line 1272  Data operator*(const boost::python::obje Line 1520  Data operator*(const boost::python::obje
1520    Takes LHS python::object and RHS Data object.    Takes LHS python::object and RHS Data object.
1521    python::object must be convertable to Data type.    python::object must be convertable to Data type.
1522  */  */
1523  Data operator/(const boost::python::object& left, const Data& right);  ESCRIPT_DLL_API Data operator/(const boost::python::object& left, const Data& right);
1524    
1525  /**  /**
1526    \brief    \brief
1527    Output operator    Output operator
1528  */  */
1529  std::ostream& operator<<(std::ostream& o, const Data& data);  ESCRIPT_DLL_API std::ostream& operator<<(std::ostream& o, const Data& data);
1530    
1531    /**
1532      \brief
1533      Compute a tensor product of two Data objects
1534      \param arg0 - Input - Data object
1535      \param arg1 - Input - Data object
1536      \param axis_offset - Input - axis offset
1537      \param transpose - Input - 0: transpose neither, 1: transpose arg0, 2: transpose arg1
1538    */
1539    ESCRIPT_DLL_API
1540    Data
1541    C_GeneralTensorProduct(Data& arg0,
1542                         Data& arg1,
1543                         int axis_offset=0,
1544                         int transpose=0);
1545    
1546  /**  /**
1547    \brief    \brief
# Line 1286  std::ostream& operator<<(std::ostream& o Line 1549  std::ostream& operator<<(std::ostream& o
1549    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
1550    be relied on. Requires further implementation.    be relied on. Requires further implementation.
1551  */  */
1552  //bool operator==(const Data& left, const Data& right);  //ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);
1553    
1554  /**  /**
1555    \brief    \brief
# Line 1302  Data::binaryOp(const Data& right, Line 1565  Data::binaryOp(const Data& right,
1565     //     //
1566     // 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
1567     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {     if (getPointDataView().getRank()==0 && right.getPointDataView().getRank()!=0) {
1568       reshapeDataPoint(right.getPointDataView().getShape());       throw DataException("Error - attempt to update rank zero object with object with rank bigger than zero.");
1569     }     }
1570     //     //
1571     // initially make the temporary a shallow copy     // initially make the temporary a shallow copy
# Line 1358  Data::binaryOp(const Data& right, Line 1621  Data::binaryOp(const Data& right,
1621    
1622  /**  /**
1623    \brief    \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);  
    }  
 }  
   
 /**  
   \brief  
1624    Perform the given unary operation on other and return the result.    Perform the given unary operation on other and return the result.
1625    Given operation is performed on each element of each data point, thus    Given operation is performed on each element of each data point, thus
1626    argument object is a rank n Data object, and returned object is a rank n    argument object is a rank n Data object, and returned object is a rank n
# Line 1483  inline Line 1706  inline
1706  Data  Data
1707  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1708  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1709    if (isExpanded()) {    if (isExpanded()) {
1710        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1711      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1712      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1713      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1714      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1715      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1716        return result;
1717    } else if (isTagged()) {    } else if (isTagged()) {
1718      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1719        DataArrayView::ShapeType viewShape;
1720        DataArrayView::ValueType viewData(1);
1721        viewData[0]=0;
1722        DataArrayView defaultValue(viewData,viewShape);
1723        DataTagged::TagListType keys;
1724        DataTagged::ValueListType values;
1725        DataTagged::DataMapType::const_iterator i;
1726        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1727          keys.push_back(i->first);
1728          values.push_back(defaultValue);
1729        }
1730        Data result(keys,values,defaultValue,getFunctionSpace());
1731      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1732      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1733      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1734      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1735        return result;
1736    } else if (isConstant()) {    } else if (isConstant()) {
1737        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1738      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1739      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1740      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1741      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1742      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1743        return result;
1744    }    }
1745    return result;    Data falseRetVal; // to keep compiler quiet
1746      return falseRetVal;
1747  }  }
1748    
1749  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26