/[escript]/branches/trilinos_from_5897/escriptcore/src/DataConstant.h
ViewVC logotype

Annotation of /branches/trilinos_from_5897/escriptcore/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26