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

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

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

revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC revision 2792 by jfenwick, Tue Dec 1 05:02:18 2009 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*  /*******************************************************
3   ************************************************************  *
4   *          Copyright 2006 by ACcESS MNRF                   *  * Copyright (c) 2003-2009 by University of Queensland
5   *                                                          *  * Earth Systems Science Computational Center (ESSCC)
6   *              http://www.access.edu.au                    *  * http://www.uq.edu.au/esscc
7   *       Primary Business: Queensland, Australia            *  *
8   *  Licensed under the Open Software License version 3.0    *  * Primary Business: Queensland, Australia
9   *     http://www.opensource.org/licenses/osl-3.0.php       *  * Licensed under the Open Software License version 3.0
10   *                                                          *  * http://www.opensource.org/licenses/osl-3.0.php
11   ************************************************************  *
12  */  *******************************************************/
13    
14    
15  #if !defined escript_DataConstant_20040323_H  #if !defined escript_DataConstant_20040323_H
16  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
17  #include "system_dep.h"  #include "system_dep.h"
18    
19  #include "DataAbstract.h"  #include "DataReady.h"
20  #include "DataArrayView.h"  #include "WrappedArray.h"
21    
 #include <boost/python/numeric.hpp>  
22    
23  namespace escript {  namespace escript {
24    
# Line 31  namespace escript { Line 31  namespace escript {
31     DataConstant stores a single data point which represents the entire     DataConstant stores a single data point which represents the entire
32     function space.     function space.
33  */  */
34  class DataConstant : public DataAbstract  {  class DataConstant : public DataReady  {
35    typedef DataReady parent;
36   public:   public:
37    
38    /**    /**
# Line 46  class DataConstant : public DataAbstract Line 46  class DataConstant : public DataAbstract
46       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.
47    */    */
48    ESCRIPT_DLL_API    ESCRIPT_DLL_API
49    DataConstant(const boost::python::numeric::array& value,    DataConstant(const WrappedArray& value,
50                 const FunctionSpace& what);                 const FunctionSpace& what);
51    
52    
53    /**    /**
54       \brief       \brief
55       Copy constructor. Performs a deep copy.       Copy constructor. Performs a deep copy.
# Line 56  class DataConstant : public DataAbstract Line 57  class DataConstant : public DataAbstract
57    ESCRIPT_DLL_API    ESCRIPT_DLL_API
58    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
59    
   /**  
      \brief  
      Alternative constructor for DataConstant objects.  
   
      Description:  
      Alternative Constructor for DataConstant objects.  
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data object represents.  
   */  
   ESCRIPT_DLL_API  
   DataConstant(const DataArrayView& value,  
                const FunctionSpace& what);  
60    
61    /**    /**
62       \brief       \brief
# Line 80  class DataConstant : public DataAbstract Line 69  class DataConstant : public DataAbstract
69    */    */
70    ESCRIPT_DLL_API    ESCRIPT_DLL_API
71    DataConstant(const DataConstant& other,    DataConstant(const DataConstant& other,
72                 const DataArrayView::RegionType& region);                 const DataTypes::RegionType& region);
73    
74    /**    /**
75       \brief       \brief
# Line 94  class DataConstant : public DataAbstract Line 83  class DataConstant : public DataAbstract
83    */    */
84    ESCRIPT_DLL_API    ESCRIPT_DLL_API
85    DataConstant(const FunctionSpace& what,    DataConstant(const FunctionSpace& what,
86                 const DataArrayView::ShapeType &shape,                 const DataTypes::ShapeType &shape,
87                 const DataArrayView::ValueType &data);                 const DataTypes::ValueType &data);
88    
89    
90      ESCRIPT_DLL_API
91      bool
92      isConstant() const
93      {
94        return true;
95      };
96    
97      /**
98      \brief Return true if the value contains a NaN.
99      */
100      ESCRIPT_DLL_API
101      bool
102      hasNaN() const;
103    
104    /**    /**
105       \brief       \brief
# Line 106  class DataConstant : public DataAbstract Line 110  class DataConstant : public DataAbstract
110    toString() const;    toString() const;
111    
112    /**    /**
113         \brief Return a deep copy of the current object.
114      */
115      ESCRIPT_DLL_API
116      virtual
117      DataAbstract*
118      deepCopy();
119    
120    
121     /**
122         \brief
123         dumps the object into a netCDF file
124      */
125      ESCRIPT_DLL_API
126      virtual
127      void
128      dump(const std::string fileName) const;
129    
130     /**
131         \brief
132        sets all values to zero
133      */
134      ESCRIPT_DLL_API
135      virtual
136      void
137      setToZero();
138    
139      /**
140       \brief       \brief
141       Return the offset for the given sample. This is a somewhat artificial notion       Return the offset for the given sample. This is a somewhat artificial notion
142       but returns the offset in bytes for the given point into the container       but returns the offset in bytes for the given point into the container
# Line 116  class DataConstant : public DataAbstract Line 147  class DataConstant : public DataAbstract
147     */     */
148    ESCRIPT_DLL_API    ESCRIPT_DLL_API
149    virtual    virtual
150    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
151    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
152                   int dataPointNo) const;                   int dataPointNo) const;
153    
   /**  
      \brief  
      Return a view into the data for the data point specified.  
      \param sampleNo - Input - sample number.  
      \param dataPointNo - Input - data point number for the sample.  
   */  
154    ESCRIPT_DLL_API    ESCRIPT_DLL_API
155    virtual    virtual
156    DataArrayView    DataTypes::ValueType::size_type
157    getDataPoint(int sampleNo,    getPointOffset(int sampleNo,
158                 int dataPointNo);                   int dataPointNo);
159    
160    /**    /**
161       \brief       \brief
# Line 138  class DataConstant : public DataAbstract Line 163  class DataConstant : public DataAbstract
163    */    */
164    ESCRIPT_DLL_API    ESCRIPT_DLL_API
165    virtual    virtual
166    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
167    getLength() const;    getLength() const;
168    
169    /**    /**
# Line 151  class DataConstant : public DataAbstract Line 176  class DataConstant : public DataAbstract
176    ESCRIPT_DLL_API    ESCRIPT_DLL_API
177    virtual    virtual
178    DataAbstract*    DataAbstract*
179    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
180    
181    /**    /**
182       \brief       \brief
# Line 163  class DataConstant : public DataAbstract Line 188  class DataConstant : public DataAbstract
188    virtual    virtual
189    void    void
190    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
191             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
192    
   /**  
     \brief  
     Archive the underlying data values to the file referenced  
     by ofstream. A count of the number of values expected to be written  
     is provided as a cross-check.  
   
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   int  
   archiveData(std::ofstream& archiveFile,  
               const DataArrayView::ValueType::size_type noValues) const;  
   
   /**  
     \brief  
     Extract the number of values specified by noValues from the file  
     referenced by ifstream to the underlying data structure.  
   
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   int  
   extractData(std::ifstream& archiveFile,  
               const DataArrayView::ValueType::size_type noValues);  
193    
194    /**    /**
195       \brief       \brief
# Line 217  class DataConstant : public DataAbstract Line 218  class DataConstant : public DataAbstract
218       Computes the trace of a matrix       Computes the trace of a matrix
219    
220       \param ev - Output - trace of matrix       \param ev - Output - trace of matrix
221         \param axis_offset
222    
223    */    */
224    ESCRIPT_DLL_API    ESCRIPT_DLL_API
# Line 228  class DataConstant : public DataAbstract Line 230  class DataConstant : public DataAbstract
230       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
231    
232       \param ev - Output - transpose of matrix       \param ev - Output - transpose of matrix
233         \param axis_offset
234    */    */
235    ESCRIPT_DLL_API    ESCRIPT_DLL_API
236    virtual void    virtual void
# Line 239  class DataConstant : public DataAbstract Line 241  class DataConstant : public DataAbstract
241       swaps components axis0 and axis1       swaps components axis0 and axis1
242    
243       \param ev - Output - swapped components       \param ev - Output - swapped components
244         \param axis0
245         \param axis1
246    */    */
247    ESCRIPT_DLL_API    ESCRIPT_DLL_API
248    virtual void    virtual void
# Line 273  class DataConstant : public DataAbstract Line 276  class DataConstant : public DataAbstract
276    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
277    
278    
279      /**
280        \brief invert square matricies
281        \param out - Where to store the results
282        \return errorcode (0 indicates success)
283      */
284      ESCRIPT_DLL_API
285      virtual int
286      matrixInverse(DataAbstract* out) const;
287    
288      /**
289         \brief
290         Return a reference to the underlying DataVector.
291      */
292      ESCRIPT_DLL_API
293      DataTypes::ValueType&
294      getVectorRW();
295    
296    
297      ESCRIPT_DLL_API
298      const DataTypes::ValueType&
299      getVectorRO() const;
300    
301   protected:   protected:
302    
303   private:   private:
304    //    //
305    // the actual data    // the actual data
306    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
307    
308  };  };
309    

Legend:
Removed from v.854  
changed lines
  Added in v.2792

  ViewVC Help
Powered by ViewVC 1.1.26