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

Diff of /trunk/escript/src/DataTagged.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 496 by jgs, Tue Feb 7 01:27:14 2006 UTC revision 580 by gross, Wed Mar 8 05:45:51 2006 UTC
# Line 58  class DataTagged : public DataAbstract { Line 58  class DataTagged : public DataAbstract {
58    
59       Description:       Description:
60       Default constructor for DataTagged. Creates a DataTagged object for which       Default constructor for DataTagged. Creates a DataTagged object for which
61       the only data-point is a scalar data-point with value 0.0. All tags       the default data-point is a scalar data-point with value 0.0, and no other
62       will map to this single data-point.       tag values are stored.
63        T
64    */    */
65    DataTagged();    DataTagged();
66    
# Line 69  class DataTagged : public DataAbstract { Line 70  class DataTagged : public DataAbstract {
70    
71       Description:       Description:
72       Constructor for DataTagged.       Constructor for DataTagged.
73       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tags.
74       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
75                       all tag values will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
76                       it contains one value all tag values will be assigned the                       0. If it contains one value all tag values will be assigned
77               same value. Otherwise if there is a mismatch between               this value. Otherwise consecutive tags will be assigned
78               the number of keys and the number of values an exception                       consecutive values.  If there is a mismatch between  the
79                 number of keys and the number of values an exception
80               will be generated.               will be generated.
81       \param defaultValue - Input - Value returned if a requested tag doesn't exist.       \param defaultValue - Input - Value returned if a requested tag doesn't exist.
82       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
83        T
84    */    */
85    DataTagged(const TagListType& tagKeys,    DataTagged(const TagListType& tagKeys,
86               const ValueListType& values,               const ValueListType& values,
# Line 94  class DataTagged : public DataAbstract { Line 97  class DataTagged : public DataAbstract {
97       \param shape - Input - The shape of each data-point.       \param shape - Input - The shape of each data-point.
98       \param tags - Input - An array of tags, one for each sample number.       \param tags - Input - An array of tags, one for each sample number.
99       \param data - The data values for each tag.       \param data - The data values for each tag.
100        NB: no unit testing yet
101    */    */
102    DataTagged(const FunctionSpace& what,    DataTagged(const FunctionSpace& what,
103               const DataArrayView::ShapeType &shape,               const DataArrayView::ShapeType &shape,
104               const int tags[],               const int tags[],
105               const ValueType &data);               const ValueType& data);
   
   /**  
      \brief  
      Slice Constructor for DataTagged.  
   
      Description:  
      Slice Constructor for DataTagged.  
      Copies a slice from another DataTagged object.  
      \param other - Input - DataTagged object to copy from.  
      \param region - Input - Region to copy.  
   */  
   DataTagged(const DataTagged& other,  
          const DataArrayView::RegionType& region);  
106    
107    /**    /**
108       \brief       \brief
109       Copy Constructor for DataTagged.       Copy Constructor for DataTagged.
110       Performs a deep copy from the given DataTagged object.       Performs a deep copy from the given DataTagged object.
111        T
112    */    */
113    DataTagged(const DataTagged& other);    DataTagged(const DataTagged& other);
114    
115    /**    /**
116       \brief       \brief
117       Copy Constructor for DataTagged.       Copy Constructor for DataTagged.
118       Construct a tagged data from a DataConstant object.       Construct a DataTagged object from a DataConstant object.
119       The default value will be that held by the DataConstant object.       The default value will be the value of the DataConstant object.
120        T
121    */    */
122    DataTagged(const DataConstant& other);    DataTagged(const DataConstant& other);
123    
# Line 137  class DataTagged : public DataAbstract { Line 130  class DataTagged : public DataAbstract {
130       sample will be visible via the returned pointer.       sample will be visible via the returned pointer.
131    
132       ** This provides an interface into the data suitable for legacy C code.       ** This provides an interface into the data suitable for legacy C code.
133         ** NB: need to do array bounds checking when accessing returned value!
134        T
135    */    */
136    virtual    virtual
137    double*    double*
# Line 147  class DataTagged : public DataAbstract { Line 142  class DataTagged : public DataAbstract {
142       Write the data as a string.       Write the data as a string.
143       Writes out each tag, including the default, and the data-point which is       Writes out each tag, including the default, and the data-point which is
144       associated with each tag.       associated with each tag.
145        T
146    */    */
147    virtual    virtual
148    std::string    std::string
# Line 156  class DataTagged : public DataAbstract { Line 152  class DataTagged : public DataAbstract {
152       \brief       \brief
153       Return the tag number associated with the given data-point number       Return the tag number associated with the given data-point number
154       according to the associated function space.       according to the associated function space.
155        T
156    */    */
157    virtual    virtual
158    int    int
# Line 171  class DataTagged : public DataAbstract { Line 168  class DataTagged : public DataAbstract {
168    
169       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
170       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
171     */      T
172      */
173    virtual    virtual
174    ValueType::size_type    ValueType::size_type
175    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 182  class DataTagged : public DataAbstract { Line 180  class DataTagged : public DataAbstract {
180       addTaggedValues       addTaggedValues
181    
182       Description:       Description:
183       Add the given tags and values to this DataTagged object, by repeatedly       Add the given tags and values to this DataTagged object.
184       using addTaggedValue for each given tag/value pair.       \param tagKeys - Input - A vector of integer tags.
      \param tagKeys - Input - A vector of integer keys.  
185       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
186                        then all given tags will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
187                        it contains one value all tags will be assigned the same value.                       0. If it contains one value all tag values will be assigned
188                        Otherwise if there is a mismatch between the number of tags and               this value. Otherwise consecutive tags will be assigned
189                        the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
190                 number of keys and the number of values an exception
191                 will be generated.
192        T
193    */    */
194    void    void
195    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
# Line 202  class DataTagged : public DataAbstract { Line 202  class DataTagged : public DataAbstract {
202       Description:       Description:
203       Add a single tag and value to this DataTagged object. If this tag already has       Add a single tag and value to this DataTagged object. If this tag already has
204       a value associated with it, setTaggedValue will be used to update this value.       a value associated with it, setTaggedValue will be used to update this value.
205       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer tag.
206       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
207        T
208    */    */
209    void    void
210    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
# Line 214  class DataTagged : public DataAbstract { Line 215  class DataTagged : public DataAbstract {
215       setTaggedValues       setTaggedValues
216    
217       Description:       Description:
218       Set the given tags to the given values in this DataTagged object, by repeatedly       Set the given tags to the given values in this DataTagged object.
219       using setTaggedValue for each given tag/value pair.       \param tagKeys - Input - A vector of integer tag.
      \param tagKeys - Input - A vector of integer keys.  
220       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of DataArrayViews. If this is empty
221                        then all given tags will be assigned a value of zero. If                       all tag values will be assigned a scalar data-point of value
222                        it contains one value all tag values will be assigned the same value.                       0. If it contains one value all tag values will be assigned
223                        Otherwise if there is a mismatch between the number of keys and               this value. Otherwise consecutive tags will be assigned
224                        the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
225                 number of keys and the number of values an exception
226                 will be generated.
227        T
228    */    */
229    void    void
230    setTaggedValues(const TagListType& tagKeys,    setTaggedValues(const TagListType& tagKeys,
# Line 232  class DataTagged : public DataAbstract { Line 235  class DataTagged : public DataAbstract {
235       setTaggedValue       setTaggedValue
236    
237       Description:       Description:
238       Assign the given value to the given tag. If this tag does not already have a value       Assign the given value to the given tag.
239       associated with it, addTaggedValue will be used to add this tag/value pair.       \param tagKey - Input - Integer tag.
      \param tagKey - Input - Integer key.  
240       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
241        T
242    */    */
243    virtual    virtual
244    void    void
# Line 247  class DataTagged : public DataAbstract { Line 250  class DataTagged : public DataAbstract {
250       getDataPointByTag       getDataPointByTag
251    
252       Description:       Description:
253       Return a view into the data-point associated with the given tag.       Return data-point associated with the given tag as a DataArrayView.
254       \param tag - Input - Integer key.       \param tag - Input - Integer key.
255        T
256    */    */
257    DataArrayView    DataArrayView
258    getDataPointByTag(int tag) const;    getDataPointByTag(int tag) const;
# Line 258  class DataTagged : public DataAbstract { Line 262  class DataTagged : public DataAbstract {
262       getDataPoint       getDataPoint
263    
264       Description:       Description:
265       Return a view into the data-point specified by the given sample       Return the data-point specified by the given sample and data-point
266       and data-point numbers.       numbers as a DataArrayView.
267       \param sampleNo - Input.       \param sampleNo - Input.
268       \param dataPointNo - Input.       \param dataPointNo - Input.
269        T
270    */    */
271    virtual    virtual
272    DataArrayView    DataArrayView
# Line 274  class DataTagged : public DataAbstract { Line 279  class DataTagged : public DataAbstract {
279    
280       Description:       Description:
281       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
282        T
283    */    */
284    const DataMapType&    const DataMapType&
285    getTagLookup() const;    getTagLookup() const;
# Line 285  class DataTagged : public DataAbstract { Line 291  class DataTagged : public DataAbstract {
291       Description:       Description:
292       Return true if the given tag exists within the DataTagged tag map.       Return true if the given tag exists within the DataTagged tag map.
293    
294       NOTE: The DataTagged tag map does not necessarily coincide with the tag       *** NB: The DataTagged tag map does not necessarily coincide with the tag
295       keys in the associated function space.       keys in the associated function space.
296     */      T
297      */
298    bool    bool
299    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
300    
# Line 298  class DataTagged : public DataAbstract { Line 305  class DataTagged : public DataAbstract {
305       Description:       Description:
306       Return the default value. This value is associated with any tag which       Return the default value. This value is associated with any tag which
307       is not explicitly recorded in this DataTagged object's tag map.       is not explicitly recorded in this DataTagged object's tag map.
308        T
309    */    */
310    DataArrayView&    DataArrayView&
311    getDefaultValue();    getDefaultValue();
# Line 310  class DataTagged : public DataAbstract { Line 318  class DataTagged : public DataAbstract {
318       getLength       getLength
319    
320       Description:       Description:
321       Return the number of doubles stored for the Data.       Return the total number of doubles stored for this DataTagged object.
322        T
323    */    */
324    virtual    virtual
325    ValueType::size_type    ValueType::size_type
# Line 321  class DataTagged : public DataAbstract { Line 330  class DataTagged : public DataAbstract {
330       getSlice       getSlice
331    
332       Description:       Description:
333       Factory method that returns a newly created DataTagged object.       Factory method that returns a newly created DataTagged object generated
334       The caller is reponsible for managing the object created.       by taking the specified slice from this DataTagged object.
335         The caller is reponsible for managing the returned object.
336        T
337    */    */
338    virtual    virtual
339    DataAbstract*    DataAbstract*
# Line 330  class DataTagged : public DataAbstract { Line 341  class DataTagged : public DataAbstract {
341    
342    /**    /**
343       \brief       \brief
344         Slice Constructor for DataTagged.
345    
346         Description:
347         Creates a DataTagged object which is the specified slice
348         from the given DataTagged object.
349         \param other - Input - DataTagged object to slice from.
350         \param region - Input - Region to slice.
351        T
352      */
353      DataTagged(const DataTagged& other,
354             const DataArrayView::RegionType& region);
355    
356      /**
357         \brief
358       setSlice       setSlice
359    
360       Description:       Description:
361       Copy the specified region from the given value into this object.       Copy the given Data object into the specified region in this object.
362       \param value - Input - Data to copy from.       \param other - Input - Data object to copy from.
363       \param region - Input - Region to copy.       \param region - Input - Region to copy into (NB: must have same shape as other!).
364        T
365    */    */
366    virtual    virtual
367    void    void
368    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* other,
369             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
370    
371    /**    /**
# Line 347  class DataTagged : public DataAbstract { Line 373  class DataTagged : public DataAbstract {
373       reshapeDataPoint       reshapeDataPoint
374    
375       Description:       Description:
376       Reshape the data point only if the data-point is currently rank 0.       Reshape each data-point in this object to the given shape, only
377       An exception is thrown if the data-point has rank other than 0.       if current data-points are scalars. An exception is thrown if
378       The original data point value is used for all values of the new       the current data-points have rank other than 0.
379       data point.       The original values of the data-points are used for all values
380         of the new data-points.
381        T
382    */    */
383    void    void
384    reshapeDataPoint(const DataArrayView::ShapeType& shape);    reshapeDataPoint(const DataArrayView::ShapeType& shape);
385    
386    /**    /**
387      \brief       \brief
388      Archive the underlying data values to the file referenced       Archive the underlying data values to the file referenced
389      by ofstream. A count of the number of values expected to be written       by ofstream. A count of the number of values expected to be written
390      is provided as a cross-check.       is provided as a cross-check.
391    
392      The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
393    */    */
394    int    int
395    archiveData(std::ofstream& archiveFile,    archiveData(std::ofstream& archiveFile,
396                const DataArrayView::ValueType::size_type noValues) const;                const DataArrayView::ValueType::size_type noValues) const;
397    
398    /**    /**
399      \brief       \brief
400      Extract the number of values specified by noValues from the file       Extract the number of values specified by noValues from the file
401      referenced by ifstream to the underlying data structure.       referenced by ifstream to the underlying data structure.
402    
403      The return value indicates success (0) or otherwise (1).       The return value indicates success (0) or otherwise (1).
404    */    */
405    int    int
406    extractData(std::ifstream& archiveFile,    extractData(std::ifstream& archiveFile,
407                const DataArrayView::ValueType::size_type noValues);                const DataArrayView::ValueType::size_type noValues);
408    
409      /**
410         \brief
411         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
412    
413         \param ev - Output - eigenvalues in increasing order at each data point
414    
415      */
416      virtual void
417      eigenvalues(DataAbstract* ev);
418    
419      /**
420         \brief
421         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
422    
423         \param ev - Output - eigenvalues in increasing order at each data point
424         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
425                             and the first nonzero component is positive.
426         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
427    
428      */
429    
430      virtual void
431      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
432    
433    
434   protected:   protected:
435    
436   private:   private:

Legend:
Removed from v.496  
changed lines
  Added in v.580

  ViewVC Help
Powered by ViewVC 1.1.26