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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1799 - (hide annotations)
Wed Sep 17 06:33:18 2008 UTC (10 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 7144 byte(s)
Added Data::copySelf() [Note: this is exposed as copy() in python].
This method returns a pointer to a deep copy of the target.
There are c++ tests but no python tests for this yet.

All DataAbstracts now have a deepCopy() which simplifies the 
implementation of the compy methods.


1 jgs 480
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 102 #if !defined escript_DataConstant_20040323_H
17 jgs 82 #define escript_DataConstant_20040323_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20 jgs 474 #include "DataAbstract.h"
21 jgs 82
22     #include <boost/python/numeric.hpp>
23    
24     namespace escript {
25 jgs 102
26 jgs 82 /**
27     \brief
28 jgs 102 DataConstant stores a single data point which represents the entire
29 jgs 82 function space.
30    
31     Description:
32 jgs 102 DataConstant stores a single data point which represents the entire
33 jgs 82 function space.
34     */
35 jgs 102 class DataConstant : public DataAbstract {
36 jgs 82
37     public:
38    
39     /**
40     \brief
41 jgs 102 Constructor for DataConstant objects.
42 jgs 82
43     Description:
44 jgs 102 Constructor for DataConstant objects.
45 jgs 82
46 jgs 102 \param value - Input - Data value for a single point.
47     \param what - Input - A description of what this data object represents.
48     */
49 woo409 757 ESCRIPT_DLL_API
50 jgs 102 DataConstant(const boost::python::numeric::array& value,
51     const FunctionSpace& what);
52 jgs 100
53 jgs 82 /**
54     \brief
55     Copy constructor. Performs a deep copy.
56     */
57 woo409 757 ESCRIPT_DLL_API
58 jgs 82 DataConstant(const DataConstant& other);
59 jgs 102
60 jfenwick 1796 // /**
61     /* \brief
62 jgs 102 Alternative constructor for DataConstant objects.
63 jgs 82
64     Description:
65 jgs 102 Alternative Constructor for DataConstant objects.
66     \param value - Input - Data value for a single point.
67 jfenwick 1796 \param what - Input - A description of what this data object represents.*/
68     // */
69     // ESCRIPT_DLL_API
70     // DataConstant(const DataArrayView& value,
71     // const FunctionSpace& what);
72 jgs 102
73 jgs 82 /**
74     \brief
75 jgs 102 Alternative constructor for DataConstant objects.
76 jgs 82
77     Description:
78 jgs 102 Alternative Constructor for DataConstant objects.
79     \param other - Input - Data object to copy from.
80     \param region - Input - region to copy.
81 jgs 82 */
82 woo409 757 ESCRIPT_DLL_API
83 jgs 102 DataConstant(const DataConstant& other,
84 jfenwick 1796 const DataTypes::RegionType& region);
85 jgs 102
86 jgs 82 /**
87     \brief
88 jgs 119 Alternative constructor for DataConstant objects.
89    
90     Description:
91     Alternative Constructor for DataConstant objects.
92     \param what - Input - A description of what this data object represents.
93     \param shape - Input - the shape of each data-point.
94     \param data - the data values for each data-point.
95     */
96 woo409 757 ESCRIPT_DLL_API
97 jgs 119 DataConstant(const FunctionSpace& what,
98 jfenwick 1796 const DataTypes::ShapeType &shape,
99     const DataTypes::ValueType &data);
100 jgs 119
101     /**
102     \brief
103 jgs 82 Write the data as a string.
104     */
105 woo409 757 ESCRIPT_DLL_API
106 jgs 102 std::string
107     toString() const;
108 jfenwick 1799
109     /**
110     \brief Return a deep copy of the current object.
111     */
112     ESCRIPT_DLL_API
113     virtual
114     DataAbstract*
115     deepCopy();
116    
117    
118 gross 950 /**
119     \brief
120     dumps the object into a netCDF file
121     */
122     ESCRIPT_DLL_API
123     virtual
124     void
125     dump(const std::string fileName) const;
126 jgs 102
127 gross 1118 /**
128     \brief
129     sets all values to zero
130     */
131     ESCRIPT_DLL_API
132     virtual
133     void
134     setToZero();
135 gross 950
136 jgs 82 /**
137     \brief
138 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
139 jgs 82 but returns the offset in bytes for the given point into the container
140     holding the point data. Only really necessary to avoid many DataArrayView
141     objects.
142 jgs 102 \param sampleNo - Input - sample number.
143     \param dataPointNo - Input - data point number for the sample.
144 jgs 82 */
145 woo409 757 ESCRIPT_DLL_API
146 jgs 102 virtual
147 jfenwick 1796 DataTypes::ValueType::size_type
148 jgs 102 getPointOffset(int sampleNo,
149     int dataPointNo) const;
150    
151 jfenwick 1796 // /**
152     /* \brief
153 jgs 82 Return a view into the data for the data point specified.
154 jgs 102 \param sampleNo - Input - sample number.
155 jfenwick 1796 \param dataPointNo - Input - data point number for the sample.*/
156     // */
157     // ESCRIPT_DLL_API
158     // virtual
159     // DataArrayView
160     // getDataPoint(int sampleNo,
161     // int dataPointNo);
162 jgs 102
163 jgs 82 /**
164     \brief
165 jgs 102 Return the number of doubles stored for the Data object.
166 jgs 82 */
167 woo409 757 ESCRIPT_DLL_API
168 jgs 102 virtual
169 jfenwick 1796 DataTypes::ValueType::size_type
170 jgs 102 getLength() const;
171    
172 jgs 82 /**
173     \brief
174 jgs 102 Factory method that returns a newly created DataConstant object
175     sliced from the specified region of this object.
176 jgs 82 The caller is reponsible for managing the object created.
177 jgs 102 \param region - Input - region to slice from this object.
178 jgs 82 */
179 woo409 757 ESCRIPT_DLL_API
180 jgs 102 virtual
181     DataAbstract*
182 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
183 jgs 102
184     /**
185 jgs 82 \brief
186     Copy the specified region from the given value.
187 jgs 102 \param value - Input - Data object to copy from.
188     \param region - Input - Region to copy.
189 jgs 82 */
190 woo409 757 ESCRIPT_DLL_API
191 jgs 102 virtual
192     void
193     setSlice(const DataAbstract* value,
194 jfenwick 1796 const DataTypes::RegionType& region);
195 jgs 102
196 jgs 123
197     /**
198 gross 580 \brief
199 ksteube 775 Computes a symmetric matrix (A + AT) / 2
200    
201     \param ev - Output - symmetric matrix
202    
203     */
204 gross 800 ESCRIPT_DLL_API
205 ksteube 775 virtual void
206     symmetric(DataAbstract* ev);
207    
208     /**
209     \brief
210     Computes a nonsymmetric matrix (A - AT) / 2
211    
212     \param ev - Output - nonsymmetric matrix
213    
214     */
215 gross 800 ESCRIPT_DLL_API
216 ksteube 775 virtual void
217     nonsymmetric(DataAbstract* ev);
218    
219     /**
220     \brief
221     Computes the trace of a matrix
222    
223     \param ev - Output - trace of matrix
224    
225     */
226 gross 800 ESCRIPT_DLL_API
227 ksteube 775 virtual void
228 gross 800 trace(DataAbstract* ev, int axis_offset);
229 ksteube 775
230     /**
231     \brief
232     Transpose each data point of this Data object around the given axis.
233    
234     \param ev - Output - transpose of matrix
235    
236     */
237 gross 800 ESCRIPT_DLL_API
238 ksteube 775 virtual void
239     transpose(DataAbstract* ev, int axis_offset);
240    
241     /**
242     \brief
243 gross 804 swaps components axis0 and axis1
244 gross 800
245     \param ev - Output - swapped components
246    
247     */
248     ESCRIPT_DLL_API
249     virtual void
250 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
251 gross 800
252    
253     /**
254     \brief
255 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
256    
257     \param ev - Output - eigenvalues in increasing order at each data point
258    
259     */
260 woo409 757 ESCRIPT_DLL_API
261 gross 580 virtual void
262     eigenvalues(DataAbstract* ev);
263    
264     /**
265     \brief
266     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
267    
268     \param ev - Output - eigenvalues in increasing order at each data point
269     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
270     and the first nonzero component is positive.
271     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
272    
273     */
274    
275 woo409 757 ESCRIPT_DLL_API
276 gross 580 virtual void
277     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
278    
279    
280 jfenwick 1796 /**
281     \brief
282     Return a reference to the underlying DataVector.
283     */
284     ESCRIPT_DLL_API
285     DataTypes::ValueType&
286     getVector();
287    
288     ESCRIPT_DLL_API
289     const DataTypes::ValueType&
290     getVector() const;
291    
292    
293 jgs 82 protected:
294    
295     private:
296     //
297 jgs 102 // the actual data
298 jfenwick 1796 DataTypes::ValueType m_data;
299 jgs 102
300 jgs 82 };
301    
302 jfenwick 1796 inline
303     DataTypes::ValueType&
304     DataConstant::getVector()
305     {
306     return m_data;
307     }
308    
309     inline
310     const DataTypes::ValueType&
311     DataConstant::getVector() const
312     {
313     return m_data;
314     }
315    
316    
317 jgs 82 } // end of namespace
318     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26