/[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

trunk/esys2/escript/src/Data/DataConstant.h revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC trunk/escript/src/DataConstant.h revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC
# Line 1  Line 1 
1  //$Id$  
2  /*  /*******************************************************
3   ******************************************************************************  *
4   *                                                                            *  * Copyright (c) 2003-2009 by University of Queensland
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Earth Systems Science Computational Center (ESSCC)
6   *                                                                            *  * http://www.uq.edu.au/esscc
7   * This software is the property of ACcESS. No part of this code              *  *
8   * may be copied in any form or by any means without the expressed written    *  * Primary Business: Queensland, Australia
9   * consent of ACcESS.  Copying, use or modification of this software          *  * Licensed under the Open Software License version 3.0
10   * by any unauthorised person is illegal unless that person has a software    *  * http://www.opensource.org/licenses/osl-3.0.php
11   * license agreement with ACcESS.                                             *  *
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"
18    
19  #include "escript/Data/DataAbstract.h"  #include "DataReady.h"
20  #include "escript/Data/DataArray.h"  #include "WrappedArray.h"
 #include "escript/Data/DataArrayView.h"  
21    
 #include <boost/python/numeric.hpp>  
22    
23  namespace escript {  namespace escript {
24    
# Line 33  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 47  class DataConstant : public DataAbstract Line 45  class DataConstant : public DataAbstract
45       \param value - Input - Data value for a single point.       \param value - Input - Data value for a single point.
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    DataConstant(const boost::python::numeric::array& value,    ESCRIPT_DLL_API
49      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.
56    */    */
57      ESCRIPT_DLL_API
58    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
59    
60    
61    /**    /**
62       \brief       \brief
63       Alternative constructor for DataConstant objects.       Alternative constructor for DataConstant objects.
64    
65       Description:       Description:
66       Alternative Constructor for DataConstant objects.       Alternative Constructor for DataConstant objects.
67       \param value - Input - Data value for a single point.       \param other - Input - Data object to copy from.
68       \param what - Input - A description of what this data object represents.       \param region - Input - region to copy.
69    */    */
70    DataConstant(const DataArrayView& value,    ESCRIPT_DLL_API
71                 const FunctionSpace& what);    DataConstant(const DataConstant& other,
72                   const DataTypes::RegionType& region);
73    
74    /**    /**
75       \brief       \brief
# Line 74  class DataConstant : public DataAbstract Line 77  class DataConstant : public DataAbstract
77    
78       Description:       Description:
79       Alternative Constructor for DataConstant objects.       Alternative Constructor for DataConstant objects.
80       \param other - Input - Data object to copy from.       \param what - Input - A description of what this data object represents.
81       \param region - Input - region to copy.       \param shape - Input - the shape of each data-point.
82         \param data - the data values for each data-point.
83    */    */
84    DataConstant(const DataConstant& other,    ESCRIPT_DLL_API
85                 const DataArrayView::RegionType& region);    DataConstant(const FunctionSpace& what,
86                   const DataTypes::ShapeType &shape,
87                   const DataTypes::ValueType &data);
88    
89    
90      ESCRIPT_DLL_API
91      bool
92      isConstant() const
93      {
94        return true;
95      };
96    
97    /**    /**
98       \brief       \brief
99       Write the data as a string.       Write the data as a string.
100    */    */
101      ESCRIPT_DLL_API
102    std::string    std::string
103    toString() const;    toString() const;
104    
105    /**    /**
106         \brief Return a deep copy of the current object.
107      */
108      ESCRIPT_DLL_API
109      virtual
110      DataAbstract*
111      deepCopy();
112    
113    
114     /**
115         \brief
116         dumps the object into a netCDF file
117      */
118      ESCRIPT_DLL_API
119      virtual
120      void
121      dump(const std::string fileName) const;
122    
123     /**
124         \brief
125        sets all values to zero
126      */
127      ESCRIPT_DLL_API
128      virtual
129      void
130      setToZero();
131    
132      /**
133       \brief       \brief
134       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
135       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 96  class DataConstant : public DataAbstract Line 138  class DataConstant : public DataAbstract
138       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
139       \param dataPointNo - Input - data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
140     */     */
141      ESCRIPT_DLL_API
142    virtual    virtual
143    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
144    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
145                   int dataPointNo) const;                   int dataPointNo) const;
146    
147    /**    ESCRIPT_DLL_API
      \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.  
   */  
148    virtual    virtual
149    DataArrayView    DataTypes::ValueType::size_type
150    getDataPoint(int sampleNo,    getPointOffset(int sampleNo,
151                 int dataPointNo);                   int dataPointNo);
152    
153    /**    /**
154       \brief       \brief
155       Return the number of doubles stored for the Data object.       Return the number of doubles stored for the Data object.
156    */    */
157      ESCRIPT_DLL_API
158    virtual    virtual
159    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
160    getLength() const;    getLength() const;
161    
162    /**    /**
# Line 127  class DataConstant : public DataAbstract Line 166  class DataConstant : public DataAbstract
166       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
167       \param region - Input - region to slice from this object.       \param region - Input - region to slice from this object.
168    */    */
169      ESCRIPT_DLL_API
170    virtual    virtual
171    DataAbstract*    DataAbstract*
172    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
173    
174    /**    /**
175       \brief       \brief
# Line 137  class DataConstant : public DataAbstract Line 177  class DataConstant : public DataAbstract
177       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
178       \param region - Input - Region to copy.       \param region - Input - Region to copy.
179    */    */
180      ESCRIPT_DLL_API
181    virtual    virtual
182    void    void
183    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
184             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
185    
186    
187    /**    /**
188       \brief       \brief
189       Reshape the data point if the data point is currently rank 0.       Computes a symmetric matrix (A + AT) / 2
190       The original data point value is used for all values of the new  
191       data point.       \param ev - Output - symmetric matrix
192    
193    */    */
194    void    ESCRIPT_DLL_API
195    reshapeDataPoint(const DataArrayView::ShapeType& shape);    virtual void
196      symmetric(DataAbstract* ev);
197    
198      /**
199         \brief
200         Computes a nonsymmetric matrix (A - AT) / 2
201    
202         \param ev - Output - nonsymmetric matrix
203    
204      */
205      ESCRIPT_DLL_API
206      virtual void
207      nonsymmetric(DataAbstract* ev);
208    
209      /**
210         \brief
211         Computes the trace of a matrix
212    
213         \param ev - Output - trace of matrix
214         \param axis_offset
215    
216      */
217      ESCRIPT_DLL_API
218      virtual void
219      trace(DataAbstract* ev, int axis_offset);
220    
221      /**
222         \brief
223         Transpose each data point of this Data object around the given axis.
224    
225         \param ev - Output - transpose of matrix
226         \param axis_offset
227      */
228      ESCRIPT_DLL_API
229      virtual void
230      transpose(DataAbstract* ev, int axis_offset);
231    
232      /**
233         \brief
234         swaps components axis0 and axis1
235    
236         \param ev - Output - swapped components
237         \param axis0
238         \param axis1
239      */
240      ESCRIPT_DLL_API
241      virtual void
242      swapaxes(DataAbstract* ev, int axis0, int axis1);
243    
244    
245      /**
246         \brief
247         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
248    
249         \param ev - Output - eigenvalues in increasing order at each data point
250    
251      */
252      ESCRIPT_DLL_API
253      virtual void
254      eigenvalues(DataAbstract* ev);
255    
256      /**
257         \brief
258         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
259    
260         \param ev - Output - eigenvalues in increasing order at each data point
261         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
262                             and the first nonzero component is positive.
263         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
264    
265      */
266    
267      ESCRIPT_DLL_API
268      virtual void
269      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
270    
271    
272      /**
273        \brief invert square matricies
274        \param out - Where to store the results
275      */
276      ESCRIPT_DLL_API
277      virtual void
278      matrixInverse(DataAbstract* out) const;
279    
280      /**
281         \brief
282         Return a reference to the underlying DataVector.
283      */
284      ESCRIPT_DLL_API
285      DataTypes::ValueType&
286      getVectorRW();
287    
288    
289      ESCRIPT_DLL_API
290      const DataTypes::ValueType&
291      getVectorRO() const;
292    
293   protected:   protected:
294    
295   private:   private:
296    //    //
297    // the actual data    // the actual data
298    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
299    
300  };  };
301    

Legend:
Removed from v.117  
changed lines
  Added in v.2742

  ViewVC Help
Powered by ViewVC 1.1.26