/[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 854 by gross, Thu Sep 21 05:29:42 2006 UTC
# Line 1  Line 1 
1    //$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 person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13                                                                              
14  #if !defined  escript_DataConstant_20040323_H  #if !defined escript_DataConstant_20040323_H
15  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
16    #include "system_dep.h"
17    
18  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
19  #include "escript/Data/DataArray.h"  #include "DataArrayView.h"
 #include "escript/Data/DataArrayView.h"  
20    
21  #include <boost/python/numeric.hpp>  #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 DataAbstract  {
35    
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 boost::python::numeric::array& value,
50                   const FunctionSpace& what);
51    
52    /**    /**
53       \brief       \brief
54       Copy constructor. Performs a deep copy.       Copy constructor. Performs a deep copy.
55    */    */
56      ESCRIPT_DLL_API
57    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
58    
59      /**
60         \brief
61         Alternative constructor for DataConstant objects.
62    
63         Description:
64         Alternative Constructor for DataConstant objects.
65         \param value - Input - Data value for a single point.
66         \param what - Input - A description of what this data object represents.
67      */
68      ESCRIPT_DLL_API
69      DataConstant(const DataArrayView& value,
70                   const FunctionSpace& what);
71    
72    /**    /**
73       \brief       \brief
74       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
75    
76       Description:       Description:
77       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
78       \param value Input - Data value for a single point.       \param other - Input - Data object to copy from.
79       \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.  
80    */    */
81    DataConstant(const DataArrayView& value, const FunctionSpace& what);    ESCRIPT_DLL_API
82      DataConstant(const DataConstant& other,
83                   const DataArrayView::RegionType& region);
84    
85    /**    /**
86       \brief       \brief
87       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
88    
89       Description:       Description:
90       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
91       \param other Input - Other DataConstant       \param what - Input - A description of what this data object represents.
92       \param region Input - region to copy       \param shape - Input - the shape of each data-point.
93         \param data - the data values for each data-point.
94    */    */
95    DataConstant(const DataConstant& other, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
96      DataConstant(const FunctionSpace& what,
97                   const DataArrayView::ShapeType &shape,
98                   const DataArrayView::ValueType &data);
99    
100    /**    /**
101       \brief       \brief
102       Write the data as a string.       Write the data as a string.
103    */    */
104    std::string toString() const;    ESCRIPT_DLL_API
105      std::string
106      toString() const;
107    
108    /**    /**
109       \brief       \brief
110       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
111       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
112       holding the point data. Only really necessary to avoid many DataArrayView       holding the point data. Only really necessary to avoid many DataArrayView
113       objects.       objects.
114       \param sampleNo - Input, sample number.       \param sampleNo - Input - sample number.
115       \param dataPointNo - Input, data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
116     */     */
117    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    ESCRIPT_DLL_API
118      virtual
119      DataArrayView::ValueType::size_type
120      getPointOffset(int sampleNo,
121                     int dataPointNo) const;
122    
123    /**    /**
124       \brief       \brief
125       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
126       NOTE: Construction of the DataArrayView is a relatively expensive       \param sampleNo - Input - sample number.
127       operation       \param dataPointNo - Input - data point number for the sample.
      \param sampleNo Input  
      \param dataPointNo Input  
128    */    */
129    virtual DataArrayView getDataPoint(int sampleNo, int dataPointNo);    ESCRIPT_DLL_API
130      virtual
131      DataArrayView
132      getDataPoint(int sampleNo,
133                   int dataPointNo);
134    
135    /**    /**
136       \brief       \brief
137       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data object.
138    */    */
139    virtual ValueType::size_type getLength() const;    ESCRIPT_DLL_API
140      virtual
141      DataArrayView::ValueType::size_type
142      getLength() const;
143    
144    /**    /**
145       \brief       \brief
146       Factory method that returns a newly created DataConstant.       Factory method that returns a newly created DataConstant object
147         sliced from the specified region of this object.
148       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
149         \param region - Input - region to slice from this object.
150    */    */
151    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;  /**    ESCRIPT_DLL_API
152      virtual
153      DataAbstract*
154      getSlice(const DataArrayView::RegionType& region) const;
155    
156      /**
157       \brief       \brief
158       Copy the specified region from the given value.       Copy the specified region from the given value.
159       \param value Input - Data to copy from       \param value - Input - Data object to copy from.
160       \param region Input - Region to copy.       \param region - Input - Region to copy.
161      */
162      ESCRIPT_DLL_API
163      virtual
164      void
165      setSlice(const DataAbstract* value,
166               const DataArrayView::RegionType& region);
167    
168      /**
169        \brief
170        Archive the underlying data values to the file referenced
171        by ofstream. A count of the number of values expected to be written
172        is provided as a cross-check.
173    
174        The return value indicates success (0) or otherwise (1).
175      */
176      ESCRIPT_DLL_API
177      int
178      archiveData(std::ofstream& archiveFile,
179                  const DataArrayView::ValueType::size_type noValues) const;
180    
181      /**
182        \brief
183        Extract the number of values specified by noValues from the file
184        referenced by ifstream to the underlying data structure.
185    
186        The return value indicates success (0) or otherwise (1).
187      */
188      ESCRIPT_DLL_API
189      int
190      extractData(std::ifstream& archiveFile,
191                  const DataArrayView::ValueType::size_type noValues);
192    
193      /**
194         \brief
195         Computes a symmetric matrix (A + AT) / 2
196    
197         \param ev - Output - symmetric matrix
198    
199      */
200      ESCRIPT_DLL_API
201      virtual void
202      symmetric(DataAbstract* ev);
203    
204      /**
205         \brief
206         Computes a nonsymmetric matrix (A - AT) / 2
207    
208         \param ev - Output - nonsymmetric matrix
209    
210      */
211      ESCRIPT_DLL_API
212      virtual void
213      nonsymmetric(DataAbstract* ev);
214    
215      /**
216         \brief
217         Computes the trace of a matrix
218    
219         \param ev - Output - trace of matrix
220    
221      */
222      ESCRIPT_DLL_API
223      virtual void
224      trace(DataAbstract* ev, int axis_offset);
225    
226      /**
227         \brief
228         Transpose each data point of this Data object around the given axis.
229    
230         \param ev - Output - transpose of matrix
231    
232      */
233      ESCRIPT_DLL_API
234      virtual void
235      transpose(DataAbstract* ev, int axis_offset);
236    
237      /**
238         \brief
239         swaps components axis0 and axis1
240    
241         \param ev - Output - swapped components
242    
243      */
244      ESCRIPT_DLL_API
245      virtual void
246      swapaxes(DataAbstract* ev, int axis0, int axis1);
247    
248    
249      /**
250         \brief
251         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
252    
253         \param ev - Output - eigenvalues in increasing order at each data point
254    
255    */    */
256    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
257      virtual void
258      eigenvalues(DataAbstract* ev);
259    
260    /**    /**
261       \brief       \brief
262       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
263       The original data point value is used for all values of the new  
264       data point.       \param ev - Output - eigenvalues in increasing order at each data point
265         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
266                             and the first nonzero component is positive.
267         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
268    
269    */    */
270    void reshapeDataPoint(const DataArrayView::ShapeType& shape);  
271      ESCRIPT_DLL_API
272      virtual void
273      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
274    
275    
276   protected:   protected:
277    
278   private:   private:
279    //    //
280    // data    // the actual data
281    DataArrayView::ValueType m_data;    DataArrayView::ValueType m_data;
282    
283  };  };
284    
285  } // end of namespace  } // end of namespace
286  #endif  #endif
   

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

  ViewVC Help
Powered by ViewVC 1.1.26