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

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

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

trunk/esys2/escript/src/Data/Data.h revision 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/src/Data.h revision 789 by dhawcroft, Wed Jul 26 05:41:11 2006 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 "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
21  #include "escript/Data/DataTagged.h"  #include "DataAlgorithm.h"
22  #include "escript/Data/FunctionSpace.h"  #include "FunctionSpace.h"
23  #include "escript/Data/BinaryOp.h"  #include "BinaryOp.h"
24  #include "escript/Data/UnaryOp.h"  #include "UnaryOp.h"
25  #include "escript/Data/DataException.h"  #include "DataException.h"
26    
27  extern "C" {  extern "C" {
28  #include "escript/Data/DataC.h"  #include "DataC.h"
29    #include "paso/Paso.h"
30  }  }
31    
 #include <iostream>  
32  #include <string>  #include <string>
 #include <memory>  
33  #include <algorithm>  #include <algorithm>
34    
35  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
36  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
 #include <boost/python/list.hpp>  
37  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
38  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
39    
40  namespace escript {  namespace escript {
41    
42  //  //
43  // Forward declaration for various implimentations of Data.  // Forward declaration for various implementations of Data.
 class DataEmpty;  
44  class DataConstant;  class DataConstant;
45  class DataTagged;  class DataTagged;
46  class DataExpanded;  class DataExpanded;
# Line 79  class Data { Line 75  class Data {
75       Default constructor.       Default constructor.
76       Creates a DataEmpty object.       Creates a DataEmpty object.
77    */    */
78      ESCRIPT_DLL_API
79    Data();    Data();
80    
81    /**    /**
# Line 86  class Data { Line 83  class Data {
83       Copy constructor.       Copy constructor.
84       WARNING: Only performs a shallow copy.       WARNING: Only performs a shallow copy.
85    */    */
86      ESCRIPT_DLL_API
87    Data(const Data& inData);    Data(const Data& inData);
88    
89    /**    /**
# Line 94  class Data { Line 92  class Data {
92       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,
93       otherwise a shallow copy of inData is returned.       otherwise a shallow copy of inData is returned.
94    */    */
95      ESCRIPT_DLL_API
96    Data(const Data& inData,    Data(const Data& inData,
97         const FunctionSpace& what);         const FunctionSpace& what);
98    
# Line 107  class Data { Line 106  class Data {
106                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
107                         mechanism will be used.                         mechanism will be used.
108    */    */
109      ESCRIPT_DLL_API
110    Data(const DataArrayView& value,    Data(const DataArrayView& value,
111         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
112         bool expanded=false);         bool expanded=false);
# Line 122  class Data { Line 122  class Data {
122                         the given value. Otherwise a more efficient storage                         the given value. Otherwise a more efficient storage
123                         mechanism will be used.                         mechanism will be used.
124    */    */
125      ESCRIPT_DLL_API
126    Data(double value,    Data(double value,
127         const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(),         const DataArrayView::ShapeType& dataPointShape=DataArrayView::ShapeType(),
128         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
# Line 134  class Data { Line 135  class Data {
135       \param inData - Input - Input Data object.       \param inData - Input - Input Data object.
136       \param region - Input - Region to copy.       \param region - Input - Region to copy.
137    */    */
138      ESCRIPT_DLL_API
139    Data(const Data& inData,    Data(const Data& inData,
140         const DataArrayView::RegionType& region);         const DataArrayView::RegionType& region);
141    
# Line 149  class Data { Line 151  class Data {
151       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
152       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
153                         the appropriate values.                         the appropriate values.
154        ==>*
155    */    */
156      ESCRIPT_DLL_API
157    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
158         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
159         const DataArrayView& defaultValue,         const DataArrayView& defaultValue,
# Line 166  class Data { Line 170  class Data {
170                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
171                         mechanism will be used.                         mechanism will be used.
172    */    */
173      ESCRIPT_DLL_API
174    Data(const boost::python::numeric::array& value,    Data(const boost::python::numeric::array& value,
175         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
176         bool expanded=false);         bool expanded=false);
# Line 181  class Data { Line 186  class Data {
186                         the value. Otherwise a more efficient storage                         the value. Otherwise a more efficient storage
187                         mechanism will be used.                         mechanism will be used.
188    */    */
189      ESCRIPT_DLL_API
190    Data(const boost::python::object& value,    Data(const boost::python::object& value,
191         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
192         bool expanded=false);         bool expanded=false);
# Line 194  class Data { Line 200  class Data {
200       \param value - Input - Input data.       \param value - Input - Input data.
201       \param other - Input - contains all other parameters.       \param other - Input - contains all other parameters.
202    */    */
203      ESCRIPT_DLL_API
204    Data(const boost::python::object& value,    Data(const boost::python::object& value,
205         const Data& other);         const Data& other);
206    
# Line 201  class Data { Line 208  class Data {
208       \brief       \brief
209       Constructor which creates a DataConstant of "shape" with constant value.       Constructor which creates a DataConstant of "shape" with constant value.
210    */    */
211      ESCRIPT_DLL_API
212    Data(double value,    Data(double value,
213         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
214         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
215         bool expanded=false);         bool expanded=false);
216      /**
217         \brief
218         Destructor
219      */
220      ESCRIPT_DLL_API
221      ~Data();
222    
223    /**    /**
224       \brief       \brief
225       Perform a deep copy.       Perform a deep copy.
226    */    */
227      ESCRIPT_DLL_API
228    void    void
229    copy(const Data& other);    copy(const Data& other);
230    
# Line 219  class Data { Line 234  class Data {
234    
235    /**    /**
236       \brief       \brief
237         switches on update protection
238    
239      */
240      ESCRIPT_DLL_API
241      void
242      setProtection();
243    
244      /**
245         \brief
246         Returns trueif the data object is protected against update
247    
248      */
249      ESCRIPT_DLL_API
250      bool
251      isProtected() const;
252      /**
253         \brief
254       Return the values of all data-points as a single python numarray object.       Return the values of all data-points as a single python numarray object.
255    */    */
256      ESCRIPT_DLL_API
257    const boost::python::numeric::array    const boost::python::numeric::array
258    convertToNumArray();    convertToNumArray();
259    
# Line 228  class Data { Line 261  class Data {
261       \brief       \brief
262       Return the values of all data-points for the given sample as a single python numarray object.       Return the values of all data-points for the given sample as a single python numarray object.
263    */    */
264      ESCRIPT_DLL_API
265    const boost::python::numeric::array    const boost::python::numeric::array
266    convertToNumArrayFromSampleNo(int sampleNo);    convertToNumArrayFromSampleNo(int sampleNo);
267    
# Line 235  class Data { Line 269  class Data {
269       \brief       \brief
270       Return the value of the specified data-point as a single python numarray object.       Return the value of the specified data-point as a single python numarray object.
271    */    */
272    #ifndef PASO_MPI  
273      ESCRIPT_DLL_API
274    const boost::python::numeric::array    const boost::python::numeric::array
275    convertToNumArrayFromDPNo(int sampleNo,    convertToNumArrayFromDPNo(int sampleNo,
276                              int dataPointNo);                              int dataPointNo);
277    #else
278      ESCRIPT_DLL_API
279      const boost::python::numeric::array
280      convertToNumArrayFromDPNo(int procNo,
281                    int sampleNo,
282                    int dataPointNo);
283    #endif
284    
285    
286      /**
287         \brief
288         Fills the expanded Data object from values of a python numarray object.
289      */
290      ESCRIPT_DLL_API
291      void
292      fillFromNumArray(const boost::python::numeric::array);
293    
294      /**
295         \brief
296         Return the tag number associated with the given data-point.
297    
298         The data-point number here corresponds to the data-point number in the
299         numarray returned by convertToNumArray.
300      */
301      ESCRIPT_DLL_API
302      int
303      getTagNumber(int dpno);
304    
305    /**    /**
306       \brief       \brief
307       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
308    */    */
309      ESCRIPT_DLL_API
310    escriptDataC    escriptDataC
311    getDataC();    getDataC();
312    
# Line 250  class Data { Line 314  class Data {
314       \brief       \brief
315       Return the C wrapper for the Data object - const version.       Return the C wrapper for the Data object - const version.
316    */    */
317      ESCRIPT_DLL_API
318    escriptDataC    escriptDataC
319    getDataC() const;    getDataC() const;
320    
# Line 257  class Data { Line 322  class Data {
322       \brief       \brief
323       Write the data as a string.       Write the data as a string.
324    */    */
325      ESCRIPT_DLL_API
326    inline    inline
327    std::string    std::string
328    toString() const    toString() const
# Line 270  class Data { Line 336  class Data {
336       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
337       to manipulate the point data.       to manipulate the point data.
338    */    */
339      ESCRIPT_DLL_API
340    inline    inline
341    const DataArrayView&    const DataArrayView&
342    getPointDataView() const    getPointDataView() const
# Line 281  class Data { Line 348  class Data {
348       \brief       \brief
349       Whatever the current Data type make this into a DataExpanded.       Whatever the current Data type make this into a DataExpanded.
350    */    */
351      ESCRIPT_DLL_API
352    void    void
353    expand();    expand();
354    
# Line 289  class Data { Line 357  class Data {
357       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
358       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
359       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
360        ==>*
361    */    */
362      ESCRIPT_DLL_API
363    void    void
364    tag();    tag();
365    
# Line 297  class Data { Line 367  class Data {
367       \brief       \brief
368       Return true if this Data is expanded.       Return true if this Data is expanded.
369    */    */
370      ESCRIPT_DLL_API
371    bool    bool
372    isExpanded() const;    isExpanded() const;
373    
# Line 304  class Data { Line 375  class Data {
375       \brief       \brief
376       Return true if this Data is tagged.       Return true if this Data is tagged.
377    */    */
378      ESCRIPT_DLL_API
379    bool    bool
380    isTagged() const;    isTagged() const;
381    
# Line 311  class Data { Line 383  class Data {
383       \brief       \brief
384       Return true if this Data is constant.       Return true if this Data is constant.
385    */    */
386      ESCRIPT_DLL_API
387    bool    bool
388    isConstant() const;    isConstant() const;
389    
# Line 318  class Data { Line 391  class Data {
391       \brief       \brief
392       Return true if this Data is empty.       Return true if this Data is empty.
393    */    */
394      ESCRIPT_DLL_API
395    bool    bool
396    isEmpty() const;    isEmpty() const;
397    
# Line 325  class Data { Line 399  class Data {
399       \brief       \brief
400       Return the function space.       Return the function space.
401    */    */
402      ESCRIPT_DLL_API
403    inline    inline
404    const FunctionSpace&    const FunctionSpace&
405    getFunctionSpace() const    getFunctionSpace() const
# Line 336  class Data { Line 411  class Data {
411       \brief       \brief
412       Return a copy of the function space.       Return a copy of the function space.
413    */    */
414      ESCRIPT_DLL_API
415    const FunctionSpace    const FunctionSpace
416    getCopyOfFunctionSpace() const;    getCopyOfFunctionSpace() const;
417    
# Line 343  class Data { Line 419  class Data {
419       \brief       \brief
420       Return the domain.       Return the domain.
421    */    */
422      ESCRIPT_DLL_API
423    inline    inline
424    const AbstractDomain&    const AbstractDomain&
425    getDomain() const    getDomain() const
# Line 354  class Data { Line 431  class Data {
431       \brief       \brief
432       Return a copy of the domain.       Return a copy of the domain.
433    */    */
434      ESCRIPT_DLL_API
435    const AbstractDomain    const AbstractDomain
436    getCopyOfDomain() const;    getCopyOfDomain() const;
437    
# Line 361  class Data { Line 439  class Data {
439       \brief       \brief
440       Return the rank of the point data.       Return the rank of the point data.
441    */    */
442      ESCRIPT_DLL_API
443    inline    inline
444    int    int
445    getDataPointRank() const    getDataPointRank() const
# Line 372  class Data { Line 451  class Data {
451       \brief       \brief
452       Return the number of samples.       Return the number of samples.
453    */    */
454      ESCRIPT_DLL_API
455    inline    inline
456    int    int
457    getNumSamples() const    getNumSamples() const
# Line 383  class Data { Line 463  class Data {
463       \brief       \brief
464       Return the number of data points per sample.       Return the number of data points per sample.
465    */    */
466      ESCRIPT_DLL_API
467    inline    inline
468    int    int
469    getNumDataPointsPerSample() const    getNumDataPointsPerSample() const
# Line 396  class Data { Line 477  class Data {
477       preferred interface but is provided for use by C code.       preferred interface but is provided for use by C code.
478       \param sampleNo - Input - the given sample no.       \param sampleNo - Input - the given sample no.
479    */    */
480      ESCRIPT_DLL_API
481    inline    inline
482    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
483    getSampleData(DataAbstract::ValueType::size_type sampleNo)    getSampleData(DataAbstract::ValueType::size_type sampleNo)
# Line 409  class Data { Line 491  class Data {
491       access data that isn't tagged an exception will be thrown.       access data that isn't tagged an exception will be thrown.
492       \param tag - Input - the tag key.       \param tag - Input - the tag key.
493    */    */
494      ESCRIPT_DLL_API
495    inline    inline
496    DataAbstract::ValueType::value_type*    DataAbstract::ValueType::value_type*
497    getSampleDataByTag(int tag)    getSampleDataByTag(int tag)
# Line 432  class Data { Line 515  class Data {
515       \param value - Input - value to assign to data-points associated with       \param value - Input - value to assign to data-points associated with
516                              the given reference number.                              the given reference number.
517    */    */
518      ESCRIPT_DLL_API
519    void    void
520    setRefValue(int ref,    setRefValue(int ref,
521                const boost::python::numeric::array& value);                const boost::python::numeric::array& value);
# Line 451  class Data { Line 535  class Data {
535       \param value - Output - object to receive values from data-points       \param value - Output - object to receive values from data-points
536                               associated with the given reference number.                               associated with the given reference number.
537    */    */
538      ESCRIPT_DLL_API
539    void    void
540    getRefValue(int ref,    getRefValue(int ref,
541                boost::python::numeric::array& value);                boost::python::numeric::array& value);
# Line 463  class Data { Line 548  class Data {
548       \param sampleNo - Input -       \param sampleNo - Input -
549       \param dataPointNo - Input -       \param dataPointNo - Input -
550    */    */
551      ESCRIPT_DLL_API
552    inline    inline
553    DataArrayView    DataArrayView
554    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
# Line 475  class Data { Line 561  class Data {
561       \brief       \brief
562       Return a reference to the data point shape.       Return a reference to the data point shape.
563    */    */
564      ESCRIPT_DLL_API
565    const DataArrayView::ShapeType&    const DataArrayView::ShapeType&
566    getDataPointShape() const;    getDataPointShape() const;
567    
# Line 482  class Data { Line 569  class Data {
569       \brief       \brief
570       Return the data point shape as a tuple of integers.       Return the data point shape as a tuple of integers.
571    */    */
572      ESCRIPT_DLL_API
573    const boost::python::tuple    const boost::python::tuple
574    getShapeTuple() const;    getShapeTuple() const;
575    
# Line 490  class Data { Line 578  class Data {
578       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
579       data point shape dimensions.       data point shape dimensions.
580    */    */
581      ESCRIPT_DLL_API
582    int    int
583    getDataPointSize() const;    getDataPointSize() const;
584    
# Line 497  class Data { Line 586  class Data {
586       \brief       \brief
587       Return the number of doubles stored for this Data.       Return the number of doubles stored for this Data.
588    */    */
589      ESCRIPT_DLL_API
590    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
591    getLength() const;    getLength() const;
592    
# Line 507  class Data { Line 597  class Data {
597       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
598       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
599       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
600        ==>*
601    */    */
602      ESCRIPT_DLL_API
603    void    void
604    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
605                   const boost::python::object& value);                   const boost::python::object& value);
# Line 519  class Data { Line 611  class Data {
611       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
612       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
613       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
614        ==>*
615    */    */
616      ESCRIPT_DLL_API
617    void    void
618    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
619                          const DataArrayView& value);                          const DataArrayView& value);
# Line 528  class Data { Line 622  class Data {
622      \brief      \brief
623      Copy other Data object into this Data object where mask is positive.      Copy other Data object into this Data object where mask is positive.
624    */    */
625      ESCRIPT_DLL_API
626    void    void
627    copyWithMask(const Data& other,    copyWithMask(const Data& other,
628                 const Data& mask);                 const Data& mask);
# Line 540  class Data { Line 635  class Data {
635       \brief       \brief
636       Interpolates this onto the given functionspace and returns       Interpolates this onto the given functionspace and returns
637       the result as a Data object.       the result as a Data object.
638         *
639    */    */
640      ESCRIPT_DLL_API
641    Data    Data
642    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
643    
# Line 548  class Data { Line 645  class Data {
645       \brief       \brief
646       Calculates the gradient of the data at the data points of functionspace.       Calculates the gradient of the data at the data points of functionspace.
647       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.
648         *
649    */    */
650      ESCRIPT_DLL_API
651    Data    Data
652    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
653    
654      ESCRIPT_DLL_API
655    Data    Data
656    grad() const;    grad() const;
657    
658    /**    /**
659       \brief       \brief
660       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
661         *
662    */    */
663      ESCRIPT_DLL_API
664    boost::python::numeric::array    boost::python::numeric::array
665    integrate() const;    integrate() const;
666    
667    /**    /**
668       \brief       \brief
669       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.
670         *
671    */    */
672      ESCRIPT_DLL_API
673    Data    Data
674    wherePositive() const;    wherePositive() const;
675    
676    /**    /**
677       \brief       \brief
678       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.
679         *
680    */    */
681      ESCRIPT_DLL_API
682    Data    Data
683    whereNegative() const;    whereNegative() const;
684    
685    /**    /**
686       \brief       \brief
687       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.
688         *
689    */    */
690      ESCRIPT_DLL_API
691    Data    Data
692    whereNonNegative() const;    whereNonNegative() const;
693    
694    /**    /**
695       \brief       \brief
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    whereNonPositive() const;    whereNonPositive() const;
702    
703    /**    /**
704       \brief       \brief
705       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.
706         *
707    */    */
708      ESCRIPT_DLL_API
709    Data    Data
710    whereZero() const;    whereZero(double tol=0.0) const;
711    
712    /**    /**
713       \brief       \brief
714       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.
715         *
716    */    */
717      ESCRIPT_DLL_API
718    Data    Data
719    whereNonZero() const;    whereNonZero(double tol=0.0) const;
720    
721    /**    /**
722       \brief       \brief
723       Return the sin of each data point of this Data object.       Return the maximum absolute value of this Data object.
724         *
725      */
726      ESCRIPT_DLL_API
727      double
728      Lsup() const;
729    
730      /**
731         \brief
732         Return the minimum absolute value of this Data object.
733         *
734      */
735      ESCRIPT_DLL_API
736      double
737      Linf() const;
738    
739      /**
740         \brief
741         Return the maximum value of this Data object.
742         *
743      */
744      ESCRIPT_DLL_API
745      double
746      sup() const;
747    
748      /**
749         \brief
750         Return the minimum value of this Data object.
751         *
752      */
753      ESCRIPT_DLL_API
754      double
755      inf() const;
756    
757      /**
758         \brief
759         Return the absolute value of each data point of this Data object.
760         *
761    */    */
762      ESCRIPT_DLL_API
763    Data    Data
764    sin() const;    abs() const;
765    
766    /**    /**
767       \brief       \brief
768       Return the cos of each data point of this Data object.       Return the maximum value of each data point of this Data object.
769         *
770    */    */
771      ESCRIPT_DLL_API
772    Data    Data
773    cos() const;    maxval() const;
774    
775    /**    /**
776       \brief       \brief
777       Return the tan of each data point of this Data object.       Return the minimum value of each data point of this Data object.
778         *
779    */    */
780      ESCRIPT_DLL_API
781    Data    Data
782    tan() const;    minval() const;
783    
784    /**    /**
785       \brief       \brief
786       Return the log to base 10 of each data point of this Data object.       Return the (sample number, data-point number) of the data point with
787         the minimum value in this Data object.
788    */    */
789      ESCRIPT_DLL_API
790      const boost::python::tuple
791      mindp() const;
792    
793      ESCRIPT_DLL_API
794      void
795    #ifndef PASO_MPI
796      calc_mindp(int& SampleNo,
797                 int& DataPointNo) const;
798    #else
799      calc_mindp(int& ProcNo,
800                            int& SampleNo,  
801                 int& DataPointNo) const;
802    #endif
803      /**
804         \brief
805         Return the sign of each data point of this Data object.
806         -1 for negative values, zero for zero values, 1 for positive values.
807         *
808      */
809      ESCRIPT_DLL_API
810    Data    Data
811    log() const;    sign() const;
812    
813    /**    /**
814       \brief       \brief
815       Return the natural log of each data point of this Data object.       Return the symmetric part of a matrix which is half the matrix plus its transpose.
816         *
817    */    */
818      ESCRIPT_DLL_API
819    Data    Data
820    ln() const;    symmetric() const;
821    
822    /**    /**
823       \brief       \brief
824       Return the maximum absolute value of this Data object.       Return the nonsymmetric part of a matrix which is half the matrix minus its transpose.
825         *
826    */    */
827    double    ESCRIPT_DLL_API
828    Lsup() const;    Data
829      nonsymmetric() const;
830    
831    /**    /**
832       \brief       \brief
833       Return the minimum absolute value of this Data object.       Return the trace of a matrix
834         *
835    */    */
836    double    ESCRIPT_DLL_API
837    Linf() const;    Data
838      matrixtrace(int axis_offset) const;
839    
840    /**    /**
841       \brief       \brief
842       Return the maximum value of this Data object.       Transpose each data point of this Data object around the given axis.
843         *
844    */    */
845    double    ESCRIPT_DLL_API
846    sup() const;    Data
847      transpose(int axis_offset) const;
848    
849    /**    /**
850       \brief       \brief
851       Return the minimum value of this Data object.       Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.
852         Currently this function is restricted to rank 2, square shape, and dimension 3.
853         *
854    */    */
855    double    ESCRIPT_DLL_API
856    inf() const;    Data
857      eigenvalues() const;
858    
859    /**    /**
860       \brief       \brief
861       Return the absolute value of each data point of this Data object.       Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
862         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
863         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
864         first non-zero entry is positive.
865         Currently this function is restricted to rank 2, square shape, and dimension 3
866         *
867    */    */
868      ESCRIPT_DLL_API
869      const boost::python::tuple
870      eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
871    
872      /**
873         \brief
874         Calculate the trace of each data point of this Data object.
875         *
876      */
877      ESCRIPT_DLL_API
878    Data    Data
879    abs() const;    trace() const;
880    
881    /**    /**
882       \brief       \brief
883       Return the maximum value of each data point of this Data object.       Return the sin of each data point of this Data object.
884         *
885    */    */
886      ESCRIPT_DLL_API
887    Data    Data
888    maxval() const;    sin() const;
889    
890    /**    /**
891       \brief       \brief
892       Return the minimum value of each data point of this Data object.       Return the cos of each data point of this Data object.
893         *
894    */    */
895      ESCRIPT_DLL_API
896    Data    Data
897    minval() const;    cos() const;
898    
899    /**    /**
900       \brief       \brief
901       Return the (sample number, data-point number) of the data point with       Return the tan of each data point of this Data object.
902       the minimum value in this Data object.       *
903    */    */
904    const boost::python::tuple    ESCRIPT_DLL_API
905    mindp() const;    Data
906      tan() const;
907    
908    /**    /**
909       \brief       \brief
910       Return the length of each data point of this Data object.       Return the asin of each data point of this Data object.
911       sqrt(sum(A[i,j,k,l]^2))       *
912    */    */
913      ESCRIPT_DLL_API
914    Data    Data
915    length() const;    asin() const;
916    
917    /**    /**
918       \brief       \brief
919       Return the sign of each data point of this Data object.       Return the acos of each data point of this Data object.
920       -1 for negative values, zero for zero values, 1 for positive values.       *
921    */    */
922      ESCRIPT_DLL_API
923    Data    Data
924    sign() const;    acos() const;
925    
926    /**    /**
927      \brief       \brief
928      Transpose each data point of this Data object around the given axis.       Return the atan of each data point of this Data object.
929      --* not implemented yet *--       *
930    */    */
931      ESCRIPT_DLL_API
932    Data    Data
933    transpose(int axis) const;    atan() const;
934    
935    /**    /**
936      \brief       \brief
937      Calculate the trace of each data point of this Data object.       Return the sinh of each data point of this Data object.
938      sum(A[i,i,i,i])       *
939    */    */
940      ESCRIPT_DLL_API
941    Data    Data
942    trace() const;    sinh() const;
943    
944    /**    /**
945      \brief       \brief
946      Return the exponential function of each data point of this Data object.       Return the cosh of each data point of this Data object.
947         *
948      */
949      ESCRIPT_DLL_API
950      Data
951      cosh() const;
952    
953      /**
954         \brief
955         Return the tanh of each data point of this Data object.
956         *
957      */
958      ESCRIPT_DLL_API
959      Data
960      tanh() const;
961    
962      /**
963         \brief
964         Return the asinh of each data point of this Data object.
965         *
966      */
967      ESCRIPT_DLL_API
968      Data
969      asinh() const;
970    
971      /**
972         \brief
973         Return the acosh of each data point of this Data object.
974         *
975      */
976      ESCRIPT_DLL_API
977      Data
978      acosh() const;
979    
980      /**
981         \brief
982         Return the atanh of each data point of this Data object.
983         *
984      */
985      ESCRIPT_DLL_API
986      Data
987      atanh() const;
988    
989      /**
990         \brief
991         Return the log to base 10 of each data point of this Data object.
992         *
993      */
994      ESCRIPT_DLL_API
995      Data
996      log10() const;
997    
998      /**
999         \brief
1000         Return the natural log of each data point of this Data object.
1001         *
1002      */
1003      ESCRIPT_DLL_API
1004      Data
1005      log() const;
1006    
1007      /**
1008         \brief
1009         Return the exponential function of each data point of this Data object.
1010         *
1011    */    */
1012      ESCRIPT_DLL_API
1013    Data    Data
1014    exp() const;    exp() const;
1015    
1016    /**    /**
1017      \brief       \brief
1018      Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
1019         *
1020    */    */
1021      ESCRIPT_DLL_API
1022    Data    Data
1023    sqrt() const;    sqrt() const;
1024    
1025    /**    /**
1026      \brief       \brief
1027      Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
1028         *
1029    */    */
1030      ESCRIPT_DLL_API
1031    Data    Data
1032    neg() const;    neg() const;
1033    
1034    /**    /**
1035      \brief       \brief
1036      Return the identity of each data point of this Data object.       Return the identity of each data point of this Data object.
1037      Simply returns this object unmodified.       Simply returns this object unmodified.
1038         *
1039    */    */
1040      ESCRIPT_DLL_API
1041    Data    Data
1042    pos() const;    pos() const;
1043    
# Line 762  class Data { Line 1046  class Data {
1046       Return the given power of each data point of this Data object.       Return the given power of each data point of this Data object.
1047    
1048       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
1049         *
1050    */    */
1051      ESCRIPT_DLL_API
1052    Data    Data
1053    powD(const Data& right) const;    powD(const Data& right) const;
1054    
1055    /**    /**
1056     * \brief       \brief
1057     * Return the given power of each data point of this boost python object.       Return the given power of each data point of this boost python object.
1058     *      
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    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
1065    
1066    /**    /**
1067      \brief       \brief
1068      writes the object to a file in the DX file format       Return the given power of each data point of this boost python object.
1069        
1070         \param left Input - the bases
1071         *
1072       */
1073    
1074      ESCRIPT_DLL_API
1075      Data
1076      rpowO(const boost::python::object& left) const;
1077    
1078      /**
1079         \brief
1080         writes the object to a file in the DX file format
1081    */    */
1082      ESCRIPT_DLL_API
1083    void    void
1084    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
1085    
1086    /**    /**
1087      \brief       \brief
1088      writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
1089    */    */
1090      ESCRIPT_DLL_API
1091    void    void
1092    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
1093    
# Line 793  class Data { Line 1095  class Data {
1095       \brief       \brief
1096       Overloaded operator +=       Overloaded operator +=
1097       \param right - Input - The right hand side.       \param right - Input - The right hand side.
1098         *
1099    */    */
1100      ESCRIPT_DLL_API
1101    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
1102      ESCRIPT_DLL_API
1103    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
1104    
1105    /**    /**
1106       \brief       \brief
1107       Overloaded operator -=       Overloaded operator -=
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   /**   /**
1117       \brief       \brief
1118       Overloaded operator *=       Overloaded operator *=
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   /**   /**
1128       \brief       \brief
1129       Overloaded operator /=       Overloaded operator /=
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    /**    /**
1139       \brief       \brief
1140       Returns true if this can be interpolated to functionspace.       Returns true if this can be interpolated to functionspace.
1141    */    */
1142      ESCRIPT_DLL_API
1143    bool    bool
1144    probeInterpolation(const FunctionSpace& functionspace) const;    probeInterpolation(const FunctionSpace& functionspace) const;
1145    
# Line 843  class Data { Line 1158  class Data {
1158       \param key - Input - python slice tuple specifying       \param key - Input - python slice tuple specifying
1159       slice to return.       slice to return.
1160    */    */
1161      ESCRIPT_DLL_API
1162    Data    Data
1163    getItem(const boost::python::object& key) const;    getItem(const boost::python::object& key) const;
1164    
# Line 857  class Data { Line 1173  class Data {
1173       slice to copy from value.       slice to copy from value.
1174       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
1175    */    */
1176      ESCRIPT_DLL_API
1177    void    void
1178    setItemD(const boost::python::object& key,    setItemD(const boost::python::object& key,
1179             const Data& value);             const Data& value);
1180    
1181      ESCRIPT_DLL_API
1182    void    void
1183    setItemO(const boost::python::object& key,    setItemO(const boost::python::object& key,
1184             const boost::python::object& value);             const boost::python::object& value);
# Line 873  class Data { Line 1191  class Data {
1191       this Data object.       this Data object.
1192    */    */
1193    template <class UnaryFunction>    template <class UnaryFunction>
1194      ESCRIPT_DLL_API
1195    inline    inline
1196    void    void
1197    unaryOp(UnaryFunction operation);    unaryOp(UnaryFunction operation);
# Line 882  class Data { Line 1201  class Data {
1201       Return a Data object containing the specified slice of       Return a Data object containing the specified slice of
1202       this Data object.       this Data object.
1203       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1204         *
1205    */    */
1206      ESCRIPT_DLL_API
1207    Data    Data
1208    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
1209    
# Line 892  class Data { Line 1213  class Data {
1213       Data object.       Data object.
1214       \param value - Input - Data to copy from.       \param value - Input - Data to copy from.
1215       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1216         *
1217    */    */
1218      ESCRIPT_DLL_API
1219    void    void
1220    setSlice(const Data& value,    setSlice(const Data& value,
1221             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
# Line 902  class Data { Line 1225  class Data {
1225       Archive the current Data object to the given file.       Archive the current Data object to the given file.
1226       \param fileName - Input - file to archive to.       \param fileName - Input - file to archive to.
1227    */    */
1228      ESCRIPT_DLL_API
1229    void    void
1230    archiveData(const std::string fileName);    archiveData(const std::string fileName);
1231    
# Line 913  class Data { Line 1237  class Data {
1237       \param fileName - Input - file to extract from.       \param fileName - Input - file to extract from.
1238       \param fspace - Input - a suitable FunctionSpace descibing the data.       \param fspace - Input - a suitable FunctionSpace descibing the data.
1239    */    */
1240      ESCRIPT_DLL_API
1241    void    void
1242    extractData(const std::string fileName,    extractData(const std::string fileName,
1243                const FunctionSpace& fspace);                const FunctionSpace& fspace);
1244    
1245    
1246    #ifdef PASO_MPI
1247      /**
1248         \brief
1249         print the data values to stdout. Used for debugging
1250      */
1251      ESCRIPT_DLL_API
1252      void
1253        print(void);
1254    
1255      /**
1256         \brief
1257         return the MPI rank number of the local data
1258             MPI_COMM_WORLD is assumed and the result of MPI_Comm_size()
1259             is returned
1260      */
1261      ESCRIPT_DLL_API
1262        int
1263        get_MPIRank(void) const;
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_rank()
1269             is returned
1270      */
1271      ESCRIPT_DLL_API
1272        int
1273        get_MPISize(void) const;
1274    
1275      /**
1276         \brief
1277         return the MPI rank number of the local data
1278             MPI_COMM_WORLD is assumed and returned.
1279      */
1280      ESCRIPT_DLL_API
1281        MPI_Comm
1282        get_MPIComm(void) const;
1283    #endif
1284        
1285   protected:   protected:
1286    
1287   private:   private:
# Line 939  class Data { Line 1304  class Data {
1304       Perform the specified reduction algorithm on every element of every data point in       Perform the specified reduction algorithm on every element of every data point in
1305       this Data object according to the given function and return the single value result.       this Data object according to the given function and return the single value result.
1306    */    */
1307    template <class UnaryFunction>    template <class BinaryFunction>
1308    inline    inline
1309    double    double
1310    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1311                double initial_value) const;
1312    
1313    /**    /**
1314       \brief       \brief
# Line 951  class Data { Line 1317  class Data {
1317       one value - the result of the reduction operation on the corresponding data-point in       one value - the result of the reduction operation on the corresponding data-point in
1318       this Data object       this Data object
1319    */    */
1320    template <class UnaryFunction>    template <class BinaryFunction>
1321    inline    inline
1322    Data    Data
1323    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1324                   double initial_value) const;
1325    
1326    /**    /**
1327       \brief       \brief
# Line 1018  class Data { Line 1385  class Data {
1385    reshapeDataPoint(const DataArrayView::ShapeType& shape);    reshapeDataPoint(const DataArrayView::ShapeType& shape);
1386    
1387    //    //
1388      // flag to protect the data object against any update
1389      bool m_protected;
1390    
1391      //
1392    // pointer to the actual data object    // pointer to the actual data object
1393    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1394    
1395      //
1396      // pointer to the internal profiling data
1397      struct profDataEntry *profData;
1398    
1399  };  };
1400    
1401  template <class IValueType>  template <class IValueType>
# Line 1054  Data::initialise(const IValueType& value Line 1429  Data::initialise(const IValueType& value
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 1083  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 1091  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 1099  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 1107  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 1115  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 1123  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 1131  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 1139  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    \brief
# Line 1153  std::ostream& operator<<(std::ostream& o Line 1528  std::ostream& operator<<(std::ostream& o
1528    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
1529    be relied on. Requires further implementation.    be relied on. Requires further implementation.
1530  */  */
1531  //bool operator==(const Data& left, const Data& right);  //ESCRIPT_DLL_API bool operator==(const Data& left, const Data& right);
1532    
1533  /**  /**
1534    \brief    \brief
# Line 1316  Data::unaryOp(UnaryFunction operation) Line 1691  Data::unaryOp(UnaryFunction operation)
1691    object (*this) is a rank n Data object, and returned object is a scalar.    object (*this) is a rank n Data object, and returned object is a scalar.
1692    Calls escript::algorithm.    Calls escript::algorithm.
1693  */  */
1694  template <class UnaryFunction>  template <class BinaryFunction>
1695  inline  inline
1696  double  double
1697  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1698  {  {
1699    if (isExpanded()) {    if (isExpanded()) {
1700      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1701      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1702      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1703    } else if (isTagged()) {    } else if (isTagged()) {
1704      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1705      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1706      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1707    } else if (isConstant()) {    } else if (isConstant()) {
1708      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1709      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1710      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1711    }    }
1712    return 0;    return 0;
1713  }  }
# Line 1345  Data::algorithm(UnaryFunction operation) Line 1720  Data::algorithm(UnaryFunction operation)
1720    rank 0 Data object.    rank 0 Data object.
1721    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1722  */  */
1723  template <class UnaryFunction>  template <class BinaryFunction>
1724  inline  inline
1725  Data  Data
1726  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1727  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1728    if (isExpanded()) {    if (isExpanded()) {
1729        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1730      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1731      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1732      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1733      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1734      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1735        return result;
1736    } else if (isTagged()) {    } else if (isTagged()) {
1737      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1738        DataArrayView::ShapeType viewShape;
1739        DataArrayView::ValueType viewData(1);
1740        viewData[0]=0;
1741        DataArrayView defaultValue(viewData,viewShape);
1742        DataTagged::TagListType keys;
1743        DataTagged::ValueListType values;
1744        DataTagged::DataMapType::const_iterator i;
1745        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1746          keys.push_back(i->first);
1747          values.push_back(defaultValue);
1748        }
1749        Data result(keys,values,defaultValue,getFunctionSpace());
1750      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1751      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1752      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1753      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1754        return result;
1755    } else if (isConstant()) {    } else if (isConstant()) {
1756        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1757      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1758      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1759      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1760      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1761      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1762        return result;
1763    }    }
1764    return result;    Data falseRetVal; // to keep compiler quiet
1765      return falseRetVal;
1766  }  }
1767    
1768  }  }

Legend:
Removed from v.121  
changed lines
  Added in v.789

  ViewVC Help
Powered by ViewVC 1.1.26