/[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 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataConstant.h revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC
# Line 1  Line 1 
1  /*  
2   ******************************************************************************  /*******************************************************
3   *                                                                            *  *
4   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Copyright (c) 2003-2009 by University of Queensland
5   *                                                                            *  * Earth Systems Science Computational Center (ESSCC)
6   * This software is the property of ACcESS. No part of this code              *  * http://www.uq.edu.au/esscc
7   * may be copied in any form or by any means without the expressed written    *  *
8   * consent of ACcESS.  Copying, use or modification of this software          *  * Primary Business: Queensland, Australia
9   * by any unauthorised person is illegal unless that person has a software    *  * Licensed under the Open Software License version 3.0
10   * license agreement with ACcESS.                                             *  * 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"
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    
25  /**  /**
26     \brief     \brief
27     DataConstant stores single data point which represents the entire     DataConstant stores a single data point which represents the entire
28     function space.     function space.
29    
30     Description:     Description:
31     DataConstant stores 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    /**    /**
39       \brief       \brief
40       Default constructor for DataConstant       Constructor for DataConstant objects.
41    
42       Description:       Description:
43       Default constructor for DataConstant       Constructor for DataConstant objects.
   
      \param value Input - Data value for a single point.  
      \param noSamples Input - number of samples.  
      \param noDataPointsPerSample Input - Input.  
      \param what Input - A description of what this data represents.  
44    
45         \param value - Input - Data value for a single point.
46         \param what - Input - A description of what this data object represents.
47    */    */
48    DataConstant(const boost::python::numeric::array& value, const FunctionSpace& what);    ESCRIPT_DLL_API
49      DataConstant(const WrappedArray& value,
50                   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       Alternative constructor for DataConstant objects.
64    
65       Description:       Description:
66       Alternative Constructor for DataConstant       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 noSamples Input - number of samples.       \param region - Input - region to copy.
      \param noDataPointsPerSample Input - Input.  
      \param what Input - A description of what this data represents.  
69    */    */
70    DataConstant(const DataArrayView& value, const FunctionSpace& what);    ESCRIPT_DLL_API
71      DataConstant(const DataConstant& other,
72                   const DataTypes::RegionType& region);
73    
74    /**    /**
75       \brief       \brief
76       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
77    
78       Description:       Description:
79       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
80       \param other Input - Other DataConstant       \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, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
85      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    std::string toString() const;    ESCRIPT_DLL_API
102      std::string
103      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 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
136       holding the point data. Only really necessary to avoid many DataArrayView       holding the point data. Only really necessary to avoid many DataArrayView
137       objects.       objects.
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    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    ESCRIPT_DLL_API
142      virtual
143      DataTypes::ValueType::size_type
144      getPointOffset(int sampleNo,
145                     int dataPointNo) const;
146    
147      ESCRIPT_DLL_API
148      virtual
149      DataTypes::ValueType::size_type
150      getPointOffset(int sampleNo,
151                     int dataPointNo);
152    
153    /**    /**
154       \brief       \brief
155       Return a view into the data for the data point specified.       Return the number of doubles stored for the Data object.
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation  
      \param sampleNo Input  
      \param dataPointNo Input  
156    */    */
157    virtual DataArrayView getDataPoint(int sampleNo, int dataPointNo);    ESCRIPT_DLL_API
158      virtual
159      DataTypes::ValueType::size_type
160      getLength() const;
161    
162    /**    /**
163       \brief       \brief
164       Return the number of doubles stored for the Data       Factory method that returns a newly created DataConstant object
165         sliced from the specified region of this object.
166         The caller is reponsible for managing the object created.
167         \param region - Input - region to slice from this object.
168    */    */
169    virtual ValueType::size_type getLength() const;    ESCRIPT_DLL_API
170      virtual
171      DataAbstract*
172      getSlice(const DataTypes::RegionType& region) const;
173    
174    /**    /**
175       \brief       \brief
176       Factory method that returns a newly created DataConstant.       Copy the specified region from the given value.
177       The caller is reponsible for managing the object created.       \param value - Input - Data object to copy from.
178         \param region - Input - Region to copy.
179    */    */
180    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;  /**    ESCRIPT_DLL_API
181      virtual
182      void
183      setSlice(const DataAbstract* value,
184               const DataTypes::RegionType& region);
185    
186    
187      /**
188       \brief       \brief
189       Copy the specified region from the given value.       Computes a symmetric matrix (A + AT) / 2
190       \param value Input - Data to copy from  
191       \param region Input - Region to copy.       \param ev - Output - symmetric matrix
192    
193      */
194      ESCRIPT_DLL_API
195      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    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
253      virtual void
254      eigenvalues(DataAbstract* ev);
255    
256    /**    /**
257       \brief       \brief
258       Reshape the data point if the data point is currently rank 0.       solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
259       The original data point value is used for all values of the new  
260       data point.       \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    void reshapeDataPoint(const DataArrayView::ShapeType& shape);  
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    // data    // the actual data
298    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
299    
300  };  };
301    
302  } // end of namespace  } // end of namespace
303  #endif  #endif
   

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

  ViewVC Help
Powered by ViewVC 1.1.26