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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (hide annotations)
Wed Sep 17 01:45:46 2008 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 7018 byte(s)
Merged noarrayview branch onto trunk.


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 gross 950 /**
109     \brief
110     dumps the object into a netCDF file
111     */
112     ESCRIPT_DLL_API
113     virtual
114     void
115     dump(const std::string fileName) const;
116 jgs 102
117 gross 1118 /**
118     \brief
119     sets all values to zero
120     */
121     ESCRIPT_DLL_API
122     virtual
123     void
124     setToZero();
125 gross 950
126 jgs 82 /**
127     \brief
128 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
129 jgs 82 but returns the offset in bytes for the given point into the container
130     holding the point data. Only really necessary to avoid many DataArrayView
131     objects.
132 jgs 102 \param sampleNo - Input - sample number.
133     \param dataPointNo - Input - data point number for the sample.
134 jgs 82 */
135 woo409 757 ESCRIPT_DLL_API
136 jgs 102 virtual
137 jfenwick 1796 DataTypes::ValueType::size_type
138 jgs 102 getPointOffset(int sampleNo,
139     int dataPointNo) const;
140    
141 jfenwick 1796 // /**
142     /* \brief
143 jgs 82 Return a view into the data for the data point specified.
144 jgs 102 \param sampleNo - Input - sample number.
145 jfenwick 1796 \param dataPointNo - Input - data point number for the sample.*/
146     // */
147     // ESCRIPT_DLL_API
148     // virtual
149     // DataArrayView
150     // getDataPoint(int sampleNo,
151     // int dataPointNo);
152 jgs 102
153 jgs 82 /**
154     \brief
155 jgs 102 Return the number of doubles stored for the Data object.
156 jgs 82 */
157 woo409 757 ESCRIPT_DLL_API
158 jgs 102 virtual
159 jfenwick 1796 DataTypes::ValueType::size_type
160 jgs 102 getLength() const;
161    
162 jgs 82 /**
163     \brief
164 jgs 102 Factory method that returns a newly created DataConstant object
165     sliced from the specified region of this object.
166 jgs 82 The caller is reponsible for managing the object created.
167 jgs 102 \param region - Input - region to slice from this object.
168 jgs 82 */
169 woo409 757 ESCRIPT_DLL_API
170 jgs 102 virtual
171     DataAbstract*
172 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
173 jgs 102
174     /**
175 jgs 82 \brief
176     Copy the specified region from the given value.
177 jgs 102 \param value - Input - Data object to copy from.
178     \param region - Input - Region to copy.
179 jgs 82 */
180 woo409 757 ESCRIPT_DLL_API
181 jgs 102 virtual
182     void
183     setSlice(const DataAbstract* value,
184 jfenwick 1796 const DataTypes::RegionType& region);
185 jgs 102
186 jgs 123
187     /**
188 gross 580 \brief
189 ksteube 775 Computes a symmetric matrix (A + AT) / 2
190    
191     \param ev - Output - symmetric matrix
192    
193     */
194 gross 800 ESCRIPT_DLL_API
195 ksteube 775 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 gross 800 ESCRIPT_DLL_API
206 ksteube 775 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    
215     */
216 gross 800 ESCRIPT_DLL_API
217 ksteube 775 virtual void
218 gross 800 trace(DataAbstract* ev, int axis_offset);
219 ksteube 775
220     /**
221     \brief
222     Transpose each data point of this Data object around the given axis.
223    
224     \param ev - Output - transpose of matrix
225    
226     */
227 gross 800 ESCRIPT_DLL_API
228 ksteube 775 virtual void
229     transpose(DataAbstract* ev, int axis_offset);
230    
231     /**
232     \brief
233 gross 804 swaps components axis0 and axis1
234 gross 800
235     \param ev - Output - swapped components
236    
237     */
238     ESCRIPT_DLL_API
239     virtual void
240 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
241 gross 800
242    
243     /**
244     \brief
245 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
246    
247     \param ev - Output - eigenvalues in increasing order at each data point
248    
249     */
250 woo409 757 ESCRIPT_DLL_API
251 gross 580 virtual void
252     eigenvalues(DataAbstract* ev);
253    
254     /**
255     \brief
256     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
257    
258     \param ev - Output - eigenvalues in increasing order at each data point
259     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
260     and the first nonzero component is positive.
261     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
262    
263     */
264    
265 woo409 757 ESCRIPT_DLL_API
266 gross 580 virtual void
267     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
268    
269    
270 jfenwick 1796 /**
271     \brief
272     Return a reference to the underlying DataVector.
273     */
274     ESCRIPT_DLL_API
275     DataTypes::ValueType&
276     getVector();
277    
278     ESCRIPT_DLL_API
279     const DataTypes::ValueType&
280     getVector() const;
281    
282    
283 jgs 82 protected:
284    
285     private:
286     //
287 jgs 102 // the actual data
288 jfenwick 1796 DataTypes::ValueType m_data;
289 jgs 102
290 jgs 82 };
291    
292 jfenwick 1796 inline
293     DataTypes::ValueType&
294     DataConstant::getVector()
295     {
296     return m_data;
297     }
298    
299     inline
300     const DataTypes::ValueType&
301     DataConstant::getVector() const
302     {
303     return m_data;
304     }
305    
306    
307 jgs 82 } // end of namespace
308     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26