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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 922 - (hide annotations)
Fri Jan 5 04:23:05 2007 UTC (12 years, 7 months ago) by gross
File MIME type: text/plain
File size: 12546 byte(s)
setValueOfDataPoint accepts double value as argument now
1 jgs 102 // $Id$
2 jgs 82 /*
3 elspeth 615 ************************************************************
4     * Copyright 2006 by ACcESS MNRF *
5     * *
6     * http://www.access.edu.au *
7     * Primary Business: Queensland, Australia *
8     * Licensed under the Open Software License version 3.0 *
9     * http://www.opensource.org/licenses/osl-3.0.php *
10     * *
11     ************************************************************
12 jgs 82 */
13 jgs 480
14 jgs 102 #if !defined escript_DataExpanded_20040323_H
15 jgs 82 #define escript_DataExpanded_20040323_H
16 woo409 757 #include "system_dep.h"
17 jgs 82
18     #include "DataAbstract.h"
19     #include "DataBlocks2D.h"
20     #include "DataArrayView.h"
21    
22     #include <boost/python/numeric.hpp>
23    
24     namespace escript {
25    
26 jgs 117 //
27     // Forward declarations of other Data types.
28 jgs 102 class DataConstant;
29     class DataTagged;
30 jgs 82
31     /**
32     \brief
33     Give a short description of what DataExpanded does.
34    
35     Description:
36 jgs 117 Give a detailed description of DataExpanded.
37 jgs 82
38     Template Parameters:
39     For templates describe any conditions that the parameters used in the
40 jgs 117 template must satisfy.
41 jgs 82 */
42    
43 jgs 117 class DataExpanded : public DataAbstract {
44 jgs 82
45     public:
46    
47     /**
48     \brief
49 jgs 117 Constructor for DataExpanded.
50 jgs 82
51 jgs 117 Description:
52     Constructor for DataExpanded.
53 jgs 82
54 jgs 117 The given single data value is copied to all the data points in
55     this data object, where the number of data points is defined by
56     the given function space.
57 jgs 82
58 jgs 117 \param value - Input - A single data value.
59 jgs 82 \param what - Input - A description of what this data represents.
60     */
61 woo409 757 ESCRIPT_DLL_API
62 jgs 102 DataExpanded(const boost::python::numeric::array& value,
63     const FunctionSpace& what);
64 jgs 82
65     /**
66     \brief
67 jgs 117 Alternative constructor for DataExpanded.
68 jgs 82
69     Description:
70 jgs 102 Alternative Constructor for DataExpanded.
71 jgs 117
72     The given single data value is copied to all the data points in
73     this data object, where the number of data points is defined by
74     the given function space.
75    
76     \param value - Input - A single data value.
77 jgs 82 \param what - Input - A description of what this data represents.
78     */
79 woo409 757 ESCRIPT_DLL_API
80 jgs 102 DataExpanded(const DataArrayView& value,
81     const FunctionSpace& what);
82 jgs 82
83     /**
84     \brief
85     Alternative constructor for DataExpanded that copies a slice from
86     another DataExpanded.
87    
88 jgs 102 \param other - Input - DataExpanded object to slice from.
89     \param region - Input - region to copy.
90 jgs 82 */
91 woo409 757 ESCRIPT_DLL_API
92 jgs 102 DataExpanded(const DataExpanded& other,
93     const DataArrayView::RegionType& region);
94 jgs 82
95     /**
96     \brief
97 jgs 119 Alternative constructor for DataExpanded objects.
98    
99     Description:
100     Alternative Constructor for DataExpanded objects.
101     \param what - Input - A description of what this data object represents.
102     \param shape - Input - the shape of each data-point.
103 jgs 122 \param data - the array of data values for the data-points.
104 jgs 119 */
105 woo409 757 ESCRIPT_DLL_API
106 jgs 119 DataExpanded(const FunctionSpace& what,
107     const DataArrayView::ShapeType &shape,
108     const DataArrayView::ValueType &data);
109    
110     /**
111     \brief
112 jgs 117 Copy constructor for DataExpanded.
113     Performs a deep copy from another DataExpanded.
114 jgs 82 */
115 woo409 757 ESCRIPT_DLL_API
116 jgs 117 DataExpanded(const DataExpanded& other);
117    
118     /**
119     \brief
120     Copy constructor for DataExpanded.
121     Construct a DataExpanded from a DataConstant.
122     */
123 woo409 757 ESCRIPT_DLL_API
124 jgs 117 DataExpanded(const DataConstant& other);
125    
126     /**
127     \brief
128     Copy constructor for DataExpanded.
129     Construct a DataExpanded from a DataTagged.
130     */
131 woo409 757 ESCRIPT_DLL_API
132 jgs 117 DataExpanded(const DataTagged& other);
133    
134     /**
135     \brief
136     Default destructor for DataExpanded.
137     */
138 woo409 757 ESCRIPT_DLL_API
139 jgs 102 virtual
140     ~DataExpanded();
141 jgs 82
142     /**
143     \brief
144 jgs 117 Return a textual representation of the data.
145 jgs 82 */
146 woo409 757 ESCRIPT_DLL_API
147 jgs 102 virtual
148     std::string
149     toString() const;
150 jgs 82
151     /**
152     \brief
153 jgs 117 Return the offset for the given given data point. This returns
154     the offset in bytes for the given point into the container
155 jgs 82 holding the point data.
156 jgs 117
157     \param sampleNo - Input - sample number.
158     \param dataPointNo - Input - data point number.
159 jgs 82 */
160 woo409 757 ESCRIPT_DLL_API
161 jgs 102 virtual
162     DataArrayView::ValueType::size_type
163     getPointOffset(int sampleNo,
164     int dataPointNo) const;
165 jgs 82
166     /**
167     \brief
168 jgs 117 Return a view into the data array for the data point specified.
169    
170 jgs 82 NOTE: Construction of the DataArrayView is a relatively expensive
171 jgs 102 operation.
172 jgs 117
173     \param sampleNo - Input - sample number.
174     \param dataPointNo - Input - data point number.
175     \return DataArrayView for the data point.
176 jgs 82 */
177 woo409 757 ESCRIPT_DLL_API
178 jgs 102 DataArrayView
179     getDataPoint(int sampleNo,
180     int dataPointNo);
181 jgs 82
182     /**
183     \brief
184 jgs 102 Return the number of doubles stored for the Data.
185 jgs 82 */
186 woo409 757 ESCRIPT_DLL_API
187 jgs 102 virtual
188     ValueType::size_type
189     getLength() const;
190 jgs 82
191     /**
192     \brief
193     Factory method that returns a newly created DataExpanded.
194     The caller is reponsible for managing the object created.
195 jgs 117
196 jgs 82 \param region - Input - Region to copy.
197     */
198 woo409 757 ESCRIPT_DLL_API
199 jgs 102 virtual
200     DataAbstract*
201     getSlice(const DataArrayView::RegionType& region) const;
202 jgs 82
203     /**
204     \brief
205     Copy the specified region from the given value.
206 jgs 117
207     \param value - Input - Data object to copy from.
208 jgs 82 \param region - Input - Region to copy.
209     */
210 woo409 757 ESCRIPT_DLL_API
211 jgs 102 virtual
212     void
213     setSlice(const DataAbstract* value,
214     const DataArrayView::RegionType& region);
215 jgs 82
216 jgs 110 /**
217     \brief
218 jgs 113 Assign the given value to all data-points associated with the given
219 jgs 110 reference number.
220    
221     A reference number corresponds to a sample, and thus to all data-points
222 jgs 113 in that sample.
223 jgs 110
224 jgs 113 If the given reference number does not correspond to any sample in this
225     Data object, an exception will be thrown.
226    
227 jgs 110 If the given value is a different shape to this Data object, an exception
228     will be thrown.
229    
230 jgs 113 \param ref - Input - reference number which determines sample numebr to
231     assign given values to.
232 jgs 110 \param value - Input - Value to assign to data-point associated with
233     the given reference number.
234     */
235 woo409 757 ESCRIPT_DLL_API
236 jgs 110 virtual
237     void
238     setRefValue(int ref,
239     const DataArray& value);
240    
241     /**
242     \brief
243 jgs 113 Return the value of the first data-point in the sample associated with
244     the given reference number.
245 jgs 110
246     A reference number corresponds to a sample, and thus to all data-points
247     in that sample. If there is more than one data-point per sample number
248 jgs 113 in this Data object, the value of the first data-point will be returned.
249 jgs 110
250 jgs 113 If the given reference number does not correspond to any sample in this
251     Data object, an exception will be thrown.
252    
253 jgs 110 If the given value is a different shape to this Data object, an exception
254     will be thrown.
255    
256 jgs 113 \param ref - Input - reference number which determines sample number to
257     read from.
258 jgs 110 \param value - Output - Object to receive data-points associated with
259     the given reference number.
260     */
261 woo409 757 ESCRIPT_DLL_API
262 jgs 110 virtual
263     void
264     getRefValue(int ref,
265     DataArray& value);
266    
267 jgs 123 /**
268     \brief
269     Archive the underlying data values to the file referenced
270     by ofstream. A count of the number of values expected to be written
271     is provided as a cross-check.
272    
273     The return value indicates success (0) or otherwise (1).
274     */
275 woo409 757 ESCRIPT_DLL_API
276 jgs 123 int
277     archiveData(std::ofstream& archiveFile,
278     const DataArrayView::ValueType::size_type noValues) const;
279    
280     /**
281     \brief
282     Extract the number of values specified by noValues from the file
283     referenced by ifstream to the underlying data structure.
284    
285     The return value indicates success (0) or otherwise (1).
286     */
287 woo409 757 ESCRIPT_DLL_API
288 jgs 123 int
289     extractData(std::ifstream& archiveFile,
290     const DataArrayView::ValueType::size_type noValues);
291    
292 gross 580 /**
293     \brief
294 ksteube 775 Computes a symmetric matrix (A + AT) / 2
295    
296     \param ev - Output - symmetric matrix
297    
298     */
299 gross 800 ESCRIPT_DLL_API
300 ksteube 775 virtual void
301     symmetric(DataAbstract* ev);
302    
303     /**
304     \brief
305     Computes a nonsymmetric matrix (A - AT) / 2
306    
307     \param ev - Output - nonsymmetric matrix
308    
309     */
310 gross 800 ESCRIPT_DLL_API
311 ksteube 775 virtual void
312     nonsymmetric(DataAbstract* ev);
313    
314     /**
315     \brief
316     Computes the trace of a matrix
317    
318     \param ev - Output - trace of your matrix
319    
320     */
321 gross 800 ESCRIPT_DLL_API
322 ksteube 775 virtual void
323 gross 800 trace(DataAbstract* ev, int axis_offset);
324 ksteube 775
325     /**
326     \brief
327     Transpose each data point of this Data object around the given axis.
328    
329     \param ev - Output - transpose of your matrix
330    
331     */
332 gross 800 ESCRIPT_DLL_API
333 ksteube 775 virtual void
334     transpose(DataAbstract* ev, int axis_offset);
335    
336     /**
337     \brief
338 gross 804 swaps components axis0 and axis1
339 gross 800
340     \param ev - Output - swapped components
341    
342     */
343     ESCRIPT_DLL_API
344     virtual void
345 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
346 gross 800
347    
348     /**
349     \brief
350 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
351    
352     \param ev - Output - eigenvalues in increasing order at each data point
353    
354     */
355 woo409 757 ESCRIPT_DLL_API
356 gross 580 virtual void
357     eigenvalues(DataAbstract* ev);
358    
359     /**
360     \brief
361     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
362    
363     \param ev - Output - eigenvalues in increasing order at each data point
364     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
365     and the first nonzero component is positive.
366     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
367    
368     */
369    
370 woo409 757 ESCRIPT_DLL_API
371 gross 580 virtual void
372     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
373    
374    
375 jgs 82 protected:
376    
377     private:
378    
379     /**
380     \brief
381 jgs 117 Common initialisation called from constructors.
382 jgs 82
383     Description:
384 jgs 117 Common initialisation called from constructors.
385    
386     Resizes the underlying data array to provide sufficient storage for the
387     given shape and number of data points, and creates the corresponding
388     DataArrayView of this data.
389    
390 jgs 82 \param shape - Input - The shape of the point data.
391     \param noSamples - Input - number of samples.
392 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
393 jgs 82 */
394 jgs 102 void
395     initialise(const DataArrayView::ShapeType& shape,
396     int noSamples,
397     int noDataPointsPerSample);
398 jgs 82
399     /**
400     \brief
401 jgs 126 Copy the given data point value to all data points in this object.
402 jgs 82
403     Description:
404 jgs 117 Copy the given data point to all data points in this object.
405    
406     \param value Input - A single data point value.
407 jgs 82 */
408 jgs 102 void
409     copy(const DataArrayView& value);
410 jgs 82
411 jgs 126 /**
412     \brief
413     Copy the given data point value given a numarray object to all data points in this object.
414    
415     Description:
416     Copy the given data point value given a numarray object to all data points in this object.
417    
418     \param value Input - A single data point value.
419     */
420 jgs 102 void
421     copy(const boost::python::numeric::array& value);
422    
423 jgs 126 /**
424     \brief
425     Copy the numarray object to the data points in this object.
426    
427     Description:
428     Copy the numarray object to the data points in this object.
429    
430     \param value Input - new values for the data points
431     */
432     void
433     copyAll(const boost::python::numeric::array& value);
434    
435 gross 921 /**
436     \brief
437 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
438    
439     Description:
440     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
441    
442     \param sampleNo Input - sample number
443     \param dataPointNo Input - data point of the sample
444     \param value Input - new values for the data point
445     */
446     ESCRIPT_DLL_API
447     virtual void
448     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
449    
450    
451     /**
452     \brief
453 gross 921 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
454    
455     Description:
456     Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
457    
458     \param sampleNo Input - sample number
459     \param dataPointNo Input - data point of the sample
460     \param value Input - new values for the data point
461     */
462     void
463     copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
464    
465 jgs 82 //
466 jgs 117 // The main data storage array, a 2D array of data blocks.
467     // noSamples * noDataPointsPerSample
468 jgs 82 DataBlocks2D m_data;
469    
470     };
471    
472     } // end of namespace
473 jgs 102
474 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26