/[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

trunk/esys2/escript/src/Data/DataTagged.h revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataTagged.h revision 1799 by jfenwick, Wed Sep 17 06:33:18 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /* $Id$ */
3   ******************************************************************************  
4   *                                                                            *  /*******************************************************
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *
6   *                                                                            *   *           Copyright 2003-2007 by ACceSS MNRF
7   * This software is the property of ACcESS. No part of this code              *   *       Copyright 2007 by University of Queensland
8   * may be copied in any form or by any means without the expressed written    *   *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *                http://esscc.uq.edu.au
10   * by any unauthorised person is illegal unless that person has a software    *   *        Primary Business: Queensland, Australia
11   * license agreement with ACcESS.                                             *   *  Licensed under the Open Software License version 3.0
12   *                                                                            *   *     http://www.opensource.org/licenses/osl-3.0.php
13   ******************************************************************************   *
14  */   *******************************************************/
15                                                                              
16  #if !defined escript_DataTagged_20040615_H  #if !defined escript_DataTagged_20040615_H
17  #define escript_DataTagged_20040615_H  #define escript_DataTagged_20040615_H
18    #include "system_dep.h"
19    
20  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
21  #include "escript/Data/DataArray.h"  #include "DataTypes.h"
 #include "escript/Data/DataArrayView.h"  
22    
23  #include <vector>  #include <vector>
24  #include <map>  #include <map>
# Line 29  class DataConstant; Line 29  class DataConstant;
29    
30  /**  /**
31     \brief     \brief
32     Creates the illusion of a full dataset accessible via sampleNo and dataPointNo.     Simulates a full dataset accessible via sampleNo and dataPointNo.
33    
34     Description:     Description:
35     Creates the illusion of a full dataset accessible via sampleNo and     Each data-point has an associated tag number, and a given tag can represent a
36     dataPointNo. In reality a much smaller number of data-points is stored.     range of dataPointNo and sampleNo. Each tag indexes only a single data-point.
    Each data-point has an associated key, thus a given key represents a specific  
    range of dataPointNo and sampleNo. Each key indexes a single data-point.  
37     Thus only a single data-point needs to be stored for a range of sampleNo and     Thus only a single data-point needs to be stored for a range of sampleNo and
38     dataPointNo values.     dataPointNo values.
39  */  */
# Line 44  class DataTagged : public DataAbstract { Line 42  class DataTagged : public DataAbstract {
42    
43   public:   public:
44    
45    typedef std::vector<int> TagListType;    //
46    typedef std::vector<DataArrayView> ValueListType;    // Types for the lists of tags and values.
47      typedef std::vector<int>           TagListType;
48    //  typedef std::vector<DataArrayView> ValueListType;
49      typedef DataTypes::ValueType   ValueType;
50      typedef std::vector<ValueType::ElementType> ValueBatchType;
51    
52    //    //
53    // Map type, maps the key to an array offset.    // Map from a tag to an offset into the data array.
54    typedef std::map<int, int> DataMapType;    typedef std::map<int, int> DataMapType;
55    
56    /**    /**
# Line 57  class DataTagged : public DataAbstract { Line 59  class DataTagged : public DataAbstract {
59    
60       Description:       Description:
61       Default constructor for DataTagged. Creates a DataTagged object for which       Default constructor for DataTagged. Creates a DataTagged object for which
62       the default data-point is a scalar data-point with value 0.0. Any given tag       the default data-point is a scalar data-point with value 0.0, and no other
63       will map to this data-point.       tag values are stored.
64        T
65    */    */
66      ESCRIPT_DLL_API
67    DataTagged();    DataTagged();
68    
69    //  /**
70    //      \brief
71    //      Constructor for DataTagged.
72    //
73    //      Description:
74    //      Constructor for DataTagged.
75    //      \param tagKeys - Input - A vector of integer tags.
76    //      \param values - Input - A vector of DataArrayViews. If this is empty
77    //                      all tag values will be assigned a scalar data-point of value
78    //                      0. If it contains one value all tag values will be assigned
79    //           this value. Otherwise consecutive tags will be assigned
80    //                      consecutive values.  If there is a mismatch between  the
81    //           number of keys and the number of values an exception
82    //           will be generated.
83    //      \param defaultValue - Input - Value returned if a requested tag doesn't exist.
84    //      \param what - Input - A description of what this data represents.
85    //     T
86    //  */
87    //   ESCRIPT_DLL_API
88    //   DataTagged(const TagListType& tagKeys,
89    //              const ValueListType& values,
90    //       const DataArrayView& defaultValue,
91    //       const FunctionSpace& what);
92    
93    /**    /**
94       \brief       \brief
95       Constructor for DataTagged.       Alternative Constructor for DataTagged.
96    
97         Description:
98         Alternative Constructor for DataTagged.
99         \param what - Input - A description of what this data object represents.
100         \param shape - Input - The shape of each data-point.
101         \param tags - Input - An array of tags, one for each sample number (starts at tag[1]).
102         \param data - The data values for each tag.
103        NB: no unit testing yet
104      */
105      ESCRIPT_DLL_API
106      DataTagged(const FunctionSpace& what,
107                 const DataTypes::ShapeType &shape,
108                 const int tags[],
109                 const ValueType& data);
110    
111     /**
112         \brief
113         Alternative Constructor for DataTagged.
114    
115         Description:
116         Alternative Constructor for DataTagged.
117         \param what - Input - A description of what this data object represents.
118         \param shape - Input - The shape of each data-point.
119         \param tags - Input - An vector of tags, one for each sample number.
120         \param data - The data values for each tag.
121    TODO Make sure to document the relationship between tags and data, ie: data also contains the default value
122     */
123      ESCRIPT_DLL_API
124      DataTagged(const FunctionSpace& what,
125                 const DataTypes::ShapeType &shape,
126                 const TagListType& tags,
127                 const ValueType& data);
128    
129       Description:    /**
130       Constructor for DataTagged.       \brief
131       \param tagKeys - Input - A vector of integer keys.       Copy Constructor for DataTagged.
132       \param values - Input - A vector of DataArrayViews. If this is empty       Performs a deep copy from the given DataTagged object.
133                     all tag values will be assigned a value of zero. If      T
                    it contains one value all tag values will be assigned the  
            same value. Otherwise if there is a mismatch between  
            the number of keys and the number of values an exception  
            will be generated.  
      \param defaultValue - Input - Value returned if a requested tag doesn't exist.  
      \param what - Input - A description of what this data represents.  
134    */    */
135    DataTagged(const TagListType& tagKeys,    ESCRIPT_DLL_API
136               const ValueListType& values,    DataTagged(const DataTagged& other);
          const DataArrayView& defaultValue,  
          const FunctionSpace& what);  
137    
138    /**    /**
139       \brief       \brief
140       Slice constructor for DataTagged.       Copy Constructor for DataTagged.
141         Construct a DataTagged object from a DataConstant object.
142       Description:       The default value will be the value of the DataConstant object.
143       Slice constructor for DataTagged.      T
      Copies a slice from another DataTagged object.  
      \param other - Input - DataTagged object to copy from.  
      \param region - Input - region to copy.  
144    */    */
145    DataTagged(const DataTagged& other,    ESCRIPT_DLL_API
146           const DataArrayView::RegionType& region);    DataTagged(const DataConstant& other);
147    
148    /**    /**
149       \brief       \brief
150       Copy constructorfor DataTagged.       Copies the tags from a DataTagged into a new Data Tagged and assigns them the default value. ** Not unit tested **
151       Performs a deep copy from the given DataTagged object.  
152         This is different from a deep copy because we are not copying shape or other information, just tags.
153         \param what - Input - FunctionSpace for the new DataTagged
154         \param shape - Input - Shape for points in the new DataTagged
155         \param defaultvalue - Input - Default value for new DataTagged
156         \param tagsource - Input - A DataTagged object which supplies the tags.
157    */    */
158    DataTagged(const DataTagged& other);    ESCRIPT_DLL_API
159      DataTagged(const FunctionSpace& what,
160                 const DataTypes::ShapeType& shape,
161             const DataTypes::ValueType& defaultvalue,
162                 const DataTagged* tagsource=0);
163    
164    /**    /**
165       \brief       \brief
166       Construct a tagged data from a DataConstant object.       Destructor
      The default data-point will be that held by the DataConstant object.  
167    */    */
168    DataTagged(const DataConstant& other);    ESCRIPT_DLL_API
169      inline virtual
170      ~DataTagged() {};
171    
172      /**
173         \brief Return a deep copy of the current object.
174      */
175      ESCRIPT_DLL_API
176      virtual
177      DataAbstract*
178      deepCopy();
179    
180    
181    /**    /**
182       \brief       \brief
183       getSampleDataByTag       getSampleDataByTag
184    
185       Description:       Description:
186       Return the data-point for the given tag. All of the data for the entire       Return the data-point for the given tag. All of the data for the
187       sample should be visable via the returned pointer. This provides an       sample will be visible via the returned pointer.
188       interface into the data suitable for legacy C code.  
189         ** This provides an interface into the data suitable for legacy C code.
190         ** NB: need to do array bounds checking when accessing returned value!
191        T
192    */    */
193      ESCRIPT_DLL_API
194    virtual    virtual
195    double*    double*
196    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
# Line 128  class DataTagged : public DataAbstract { Line 200  class DataTagged : public DataAbstract {
200       Write the data as a string.       Write the data as a string.
201       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
202       associated with each tag.       associated with each tag.
203        T
204    */    */
205      ESCRIPT_DLL_API
206    virtual    virtual
207    std::string    std::string
208    toString() const;    toString() const;
209     /**
210         \brief
211         dumps the object into a netCDF file
212      */
213      ESCRIPT_DLL_API
214      virtual
215      void
216      dump(const std::string fileName) const;
217    
218     /**
219         \brief
220        sets all values to zero
221      */
222      ESCRIPT_DLL_API
223      virtual
224      void
225      setToZero();
226    
227      /**
228         \brief
229         Return the tag number associated with the given data-point number
230         according to the associated function space.
231        T
232      */
233      ESCRIPT_DLL_API
234      virtual
235      int
236      getTagNumber(int dpno);
237    
238    /**    /**
239       \brief       \brief
240       getPointOffset       getPointOffset
241    
242       Description:       Description:
243       Return the offset to the given data-point. This is somewhat artificial,       Return the offset to the given data-point value in the underlying
244       but returns the offset for the given point in the DataTagged object.       data vector.
      Only really necessary to avoid many DataArrayView objects.  
245    
246       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
247       \param dataPointNo - Input - data-point number.       \param dataPointNo - Input - data-point number.
248     */      T
249      */
250      ESCRIPT_DLL_API
251    virtual    virtual
252    DataArrayView::ValueType::size_type    ValueType::size_type
253    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
254                   int dataPointNo) const;                   int dataPointNo) const;
255    
256    /**  
257    
258    //  /**
259    //      \brief
260    //      addTaggedValues
261    //
262    //      Description:
263    //      Add the given tags and values to this DataTagged object.
264    //      \param tagKeys - Input - A vector of integer tags.
265    //      \param values - Input - A vector of DataArrayViews. If this is empty
266    //                      all tag values will be assigned a scalar data-point of value
267    //                      0. If it contains one value all tag values will be assigned
268    //           this value. Otherwise consecutive tags will be assigned
269    //                      consecutive values.  If there is a mismatch between  the
270    //           number of keys and the number of values an exception
271    //           will be generated.
272    //     T
273    //  */
274    //   ESCRIPT_DLL_API
275    //   void
276    //   addTaggedValues(const TagListType& tagKeys,
277    //                   const ValueListType& values);  
278    
279    //  /**
280    //      \brief
281    //      addTaggedValue
282    //
283    //      Description:
284    //      Add a single tag and value to this DataTagged object. If this tag already has
285    //      a value associated with it, setTaggedValue will be used to update this value.
286    //      \param tagKey - Input - Integer tag.
287    //      \param value - Input - Single DataArrayView value to be assigned to the tag.
288    //     T
289     // */
290    //   ESCRIPT_DLL_API
291    //   void
292    //   addTaggedValue(int tagKey,
293    //                  const DataArrayView& value);
294    
295    
296    
297     /**
298       \brief       \brief
299       addTaggedValues       addTaggedValues
300    
301       Description:       Description:
302       Add the given tags and values to this DataTagged object.       Add the given tags and values to this DataTagged object.
303       \param tagKeys - Input - A vector of integer keys.       \param tagKeys - Input - A vector of integer tags.
304       \param values - Input - A vector of DataArrayViews. If this is empty       \param values - Input - A vector of doubles. If this is empty, the default value for
305                     then all given tags will be assigned a value of zero. If                       this DataTagged will be used for all tags.
306                     it contains one value all tags will be assigned the same value.                       If it contains one value all tag values will be assigned
307                     Otherwise if there is a mismatch between the number of tags and               this value. Otherwise consecutive tags will be assigned
308                     the number of values an exception will be generated.                       consecutive values.  If there is a mismatch between  the
309       NB: If a tag given here already exists in this object, this attempt to add the given               number of keys and the number of values an exception
310       value will have no effect. setTaggedValues is more versatile and should be               will be generated.
311       used in most cases in preference to addTaggedValues.       \param vShape - shape of the datapoints in "values"
312        T
313     */
314      ESCRIPT_DLL_API
315      void
316      addTaggedValues(const TagListType& tagKeys,
317                                const ValueBatchType& values,
318                                const ShapeType& vShape);
319    
320    
321      /**
322       Description:
323       Add the given tags and values to this DataTagged object.
324       \param tagKeys - Input - A vector of integer tags.
325       \param values - Input - A DataVector containing the datapoints.
326                 If this is empty, the default value for
327                         this DataTagged will be used for all tags.
328                         If it contains one value all tag values will be assigned
329                 this value. Otherwise consecutive tags will be assigned
330                         consecutive values.  If there is a mismatch between  the
331                 number of keys and the number of values an exception
332                 will be generated.
333        \param vShape - shape of the datapoints in "values"
334    
335       TODO Makesure this is properly unit tested
336    */    */
337      ESCRIPT_DLL_API
338    void    void
339    addTaggedValues(const TagListType& tagKeys,    addTaggedValues(const TagListType& tagKeys,
340                    const ValueListType& values);                                const ValueType& values,
341                                const ShapeType& vShape);
342    
343    
344    
345    
346    /**    /**
347       \brief       \brief
348       addTaggedValue       addTaggedValue
349    
350       Description:       Description:
351       Add a single tag and value to this DataTagged object.       Add a single tag and value to this DataTagged object. If this tag already has
352       \param tagKey - Input - Integer key.       a value associated with it, setTaggedValue will be used to update this value.
353       \param value - Input - DataArrayView.       \param tagKey - Input - Integer tag.
354       NB: If this tag already exists in this object, this attempt to add the given       \param pointshape - Shape of the value parameter
355       value will have no effect. setTaggedValue is more versatile and should be       \param value - Input - Single DataArrayView value to be assigned to the tag.
356       used in most cases in preference to addTaggedValue.       \param dataOffset - Input - Offset of the beginning of the point in the value parameter
357    */    */
358      ESCRIPT_DLL_API
359    void    void
360    addTaggedValue(int tagKey,    addTaggedValue(int tagKey,
361                   const DataArrayView& value);           const DataTypes::ShapeType& pointshape,
362                     const ValueType& value,
363             int dataOffset=0);
364    
365    /**    /**
366       \brief       \brief
367       setTaggedValues       addTag - does not modify the default value for this object. ** Not unit tested **
368    
369       Description:       Description:
370       Assign the given values to the tags listed.       Add a single tag. The default value for this DataTagged will be associated with the tag.
371       \param tagKeys - Input - A vector of integer keys.       If this tag already has a value associated with it, then no change will be made.
372       \param values - Input - A vector of DataArrayViews. If this is empty       \param tagKey - Input - Integer tag.
373                        then all given tags will be assigned a value of zero. If      TODO: Make sure this is unit tested
                       it contains one value all tag values will be assigned the same value.  
                       Otherwise if there is a mismatch between the number of keys and  
                       the number of values an exception will be generated.  
      NB: If a given tag does not yet exist in this DataTagged object, it will be added.  
374    */    */
375      ESCRIPT_DLL_API
376    void    void
377    setTaggedValues(const TagListType& tagKeys,    addTag(int tagKey);
378                    const ValueListType& values);  
379    
380    //  /**
381    //      \brief
382    //      setTaggedValues
383    //
384    //      Description:
385    //      Set the given tags to the given values in this DataTagged object.
386    //      \param tagKeys - Input - A vector of integer tag.
387    //      \param values - Input - A vector of DataArrayViews. If this is empty
388    //                      all tag values will be assigned a scalar data-point of value
389    //                      0. If it contains one value all tag values will be assigned
390    //           this value. Otherwise consecutive tags will be assigned
391    //                      consecutive values.  If there is a mismatch between  the
392    //           number of keys and the number of values an exception
393    //           will be generated.
394    //     T
395    //  */
396    //   ESCRIPT_DLL_API
397    //   void
398    //   setTaggedValues(const TagListType& tagKeys,
399    //                   const ValueListType& values);
400    
401    //  /**
402    //      \brief
403    //      setTaggedValue
404    //
405    //      Description:
406    //      Assign the given value to the given tag.
407    //      \param tagKey - Input - Integer tag.
408    //      \param value - Input - Single DataArrayView value to be assigned to the tag.
409    //     T
410    //  */
411    //   ESCRIPT_DLL_API
412    //   virtual
413    //   void
414    //   setTaggedValue(int tagKey,
415    //                  const DataArrayView& value);
416    
417    /**    /**
418       \brief       \brief
# Line 210  class DataTagged : public DataAbstract { Line 420  class DataTagged : public DataAbstract {
420    
421       Description:       Description:
422       Assign the given value to the given tag.       Assign the given value to the given tag.
423       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer tag.
424       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param pointshape - the shape of the value parameter
425       NB: If the given tag does not yet exist in this DataTagged object, it will be added.       \param value - Input - Vector storing the datapoint to be assigned to the tag.
426         \param dataOffset - beginning of the datapoint within "value".
427        T
428    */    */
429    virtual    ESCRIPT_DLL_API
430    void    void
431    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
432                   const DataArrayView& value);           const DataTypes::ShapeType& pointshape,
433                     const ValueType& value,
434             int dataOffset=0);
435    
436    
437    //  /**
438    //      \brief
439    //      getDataPointByTag
440    //
441    //      Description:
442    //      Return data-point associated with the given tag as a DataArrayView.
443    //      \param tag - Input - Integer key.
444    //     T
445    //  */
446    //   ESCRIPT_DLL_API
447    //   DataArrayView
448    //   getDataPointByTag(int tag) const;
449    
450    /**    /**
451       \brief       \brief
452       getDataPointByTag       getDataByTag
453    
454       Description:       Return a pointer to the beginning of the datapoint with the specified tag.
455       Return a view into the data-point associated with the given tag.       TODO Eventually these should be inlined.
456       \param tag - Input - Integer key.       \param tag - Input - Integer key.
457         \param i - position in the underlying datastructure
458        T
459    */    */
460    DataArrayView    ESCRIPT_DLL_API
461    getDataPointByTag(int tag) const;    DataTypes::ValueType::const_reference
462      getDataByTag(int tag, DataTypes::ValueType::size_type i) const;
463    
464      ESCRIPT_DLL_API
465      DataTypes::ValueType::reference
466      getDataByTag(int tag, DataTypes::ValueType::size_type i);
467    
468    
469      /**
470          \brief
471          getOffsetForTag
472    
473          \param tag
474          \return the offset of the beginning of the datapoint corresponding to tag.
475    
476          Note: If the tag is not valid, the offset of the default value is returned instead.
477      */
478      ESCRIPT_DLL_API
479      DataTypes::ValueType::size_type
480      getOffsetForTag(int tag) const;
481    
482    //  /**
483    //      \brief
484    //      getDataPoint
485    //
486    //      Description:
487    //      Return the data-point specified by the given sample and data-point
488    //      numbers as a DataArrayView.
489    //      \param sampleNo - Input.
490    //      \param dataPointNo - Input.
491    //     T
492    //  */
493    //   ESCRIPT_DLL_API
494    //   virtual
495    //   DataArrayView
496    //   getDataPoint(int sampleNo,
497    //                int dataPointNo);
498    
499    
500      /**
501         \brief
502         Return a reference to the underlying DataVector.
503      */
504    
505      ESCRIPT_DLL_API
506      DataTypes::ValueType&
507      getVector();
508    
509      ESCRIPT_DLL_API
510      const DataTypes::ValueType&
511      getVector() const;
512    
513    
514    
515    /**    /**
516       \brief       \brief
517       getDataPoint       getData
518    
519       Description:       Description:
520       Return a view into the data-point specified by the given sample       Return pointer to the data
521       and data-point numbers.      T
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation.  
      \param sampleNo - Input.  
      \param dataPointNo - Input.  
522    */    */
523    virtual  //   ESCRIPT_DLL_API
524    DataArrayView  //   const DataTypes::ValueType::ElementType*
525    getDataPoint(int sampleNo,  //   getData() const;
                int dataPointNo);  
526    
527    /**    /**
528       \brief       \brief
# Line 253  class DataTagged : public DataAbstract { Line 530  class DataTagged : public DataAbstract {
530    
531       Description:       Description:
532       Return a reference to the tag offset lookup table.       Return a reference to the tag offset lookup table.
533        T
534    */    */
535      ESCRIPT_DLL_API
536    const DataMapType&    const DataMapType&
537    getTagLookup() const;    getTagLookup() const;
538    
# Line 262  class DataTagged : public DataAbstract { Line 541  class DataTagged : public DataAbstract {
541       isCurrentTag       isCurrentTag
542    
543       Description:       Description:
544       Return true if the given tag exists within the DataTagged tag keys.       Return true if the given tag exists within the DataTagged tag map.
545       NOTE: The DataTagged keys do not necessarily coincide with the tag  
546       keys for the function space.       *** NB: The DataTagged tag map does not necessarily coincide with the tag
547     */       keys in the associated function space.
548        T
549      */
550      ESCRIPT_DLL_API
551    bool    bool
552    isCurrentTag(int tag) const;    isCurrentTag(int tag) const;
553    
554    // /**
555    //      \brief
556    //      getDefaultValue
557    //
558    //      Description:
559    //      Return the default value. This value is associated with any tag which
560    //      is not explicitly recorded in this DataTagged object's tag map.
561    //     T
562    //  */
563    //   ESCRIPT_DLL_API
564    //   DataArrayView&
565    //   getDefaultValue();
566    //
567    //   ESCRIPT_DLL_API
568    //   const DataArrayView&
569    //   getDefaultValue() const;
570    
571    /**    /**
572       \brief       \brief
573       getDefaultValue       getDefaultValue
574    
575       Description:       Description:
576       Return the default value. This value is associated with any tag which       Return the default value. This value is associated with any tag which
577       is not explicitly recorded in this DataTagged object.       is not explicitly recorded in this DataTagged object's tag map.
578    */       \param i - position in the underlying datastructure
579    DataArrayView&      T
580    getDefaultValue();    */
581      ESCRIPT_DLL_API
582      DataTypes::ValueType::reference
583      getDefaultValue(DataTypes::ValueType::size_type i);
584    
585      ESCRIPT_DLL_API
586      DataTypes::ValueType::const_reference
587      getDefaultValue(DataTypes::ValueType::size_type i) const;
588    
589    
   /**  
      \brief  
      getDefaultValue  
590    
      Description:  
      Return the default value, const version.  
   */  
   const DataArrayView&  
   getDefaultValue() const;  
591    
592    /**    /**
593       \brief       \brief
594       getLength       getLength
595    
596       Description:       Description:
597       Return the number of doubles stored for the Data.       Return the total number of doubles stored for this DataTagged object.
598        T
599    */    */
600      ESCRIPT_DLL_API
601    virtual    virtual
602    ValueType::size_type    ValueType::size_type
603    getLength() const;    getLength() const;
# Line 306  class DataTagged : public DataAbstract { Line 607  class DataTagged : public DataAbstract {
607       getSlice       getSlice
608    
609       Description:       Description:
610       Factory method that returns a newly created DataTagged.       Factory method that returns a newly created DataTagged object generated
611       The caller is reponsible for managing the object created.       by taking the specified slice from this DataTagged object.
612         The caller is reponsible for managing the returned object.
613        T
614    */    */
615      ESCRIPT_DLL_API
616    virtual    virtual
617    DataAbstract*    DataAbstract*
618    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
619    
620      /**
621         \brief
622         Slice Constructor for DataTagged.
623    
624         Description:
625         Creates a DataTagged object which is the specified slice
626         from the given DataTagged object.
627         \param other - Input - DataTagged object to slice from.
628         \param region - Input - Region to slice.
629        T
630      */
631      ESCRIPT_DLL_API
632      DataTagged(const DataTagged& other,
633             const DataTypes::RegionType& region);
634    
635    /**    /**
636       \brief       \brief
637       setSlice       setSlice
638    
639       Description:       Description:
640       Copy the specified region from the given value.       Copy the given Data object into the specified region in this object.
641       \param value - Input - Data to copy from.       \param other - Input - Data object to copy from.
642       \param region - Input - Region to copy.       \param region - Input - Region to copy into (NB: must have same shape as other!).
643        T
644    */    */
645      ESCRIPT_DLL_API
646    virtual    virtual
647    void    void
648    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* other,
649             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
650    
651    
652    /**    /**
653       \brief       \brief
654       reshapeDataPoint       Computes a symmetric matrix (A + AT) / 2
655    
656         \param ev - Output - symmetric matrix
657    
      Description:  
      Reshape the data point only if the data-point is currently rank 0.  
      An exception is thrown if the data-point has rank other than 0.  
      The original data point value is used for all values of the new  
      data point.  
658    */    */
659    void    ESCRIPT_DLL_API
660    reshapeDataPoint(const DataArrayView::ShapeType& shape);    virtual void
661      symmetric(DataAbstract* ev);
662    
663      /**
664         \brief
665         Computes a nonsymmetric matrix (A - AT) / 2
666    
667         \param ev - Output - nonsymmetric matrix
668    
669      */
670      ESCRIPT_DLL_API
671      virtual void
672      nonsymmetric(DataAbstract* ev);
673    
674      /**
675         \brief
676         Computes the trace of a matrix
677    
678         \param ev - Output - the trace of a matrix
679    
680      */
681      ESCRIPT_DLL_API
682      virtual void
683      trace(DataAbstract* ev, int axis_offset);
684    
685      /**
686         \brief
687         swaps components axis0 and axis1
688    
689         \param ev - Output - swapped components
690    
691      */
692      ESCRIPT_DLL_API
693      virtual void
694      swapaxes(DataAbstract* ev, int axis0, int axis1);
695    
696      /**
697         \brief
698         Transpose each data point of this Data object around the given axis.
699    
700         \param ev - Output - the transpose of a matrix
701    
702      */
703      ESCRIPT_DLL_API
704      virtual void
705      transpose(DataAbstract* ev, int axis_offset);
706    
707      /**
708         \brief
709         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
710    
711         \param ev - Output - eigenvalues in increasing order at each data point
712    
713      */
714      ESCRIPT_DLL_API
715      virtual void
716      eigenvalues(DataAbstract* ev);
717    
718      /**
719         \brief
720         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
721    
722         \param ev - Output - eigenvalues in increasing order at each data point
723         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
724                             and the first nonzero component is positive.
725         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
726    
727      */
728    
729      ESCRIPT_DLL_API
730      virtual void
731      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
732    
733    
734      /**
735         \brief  Returns the offset in the structure which stores the default value
736      */
737      ESCRIPT_DLL_API
738      DataTypes::ValueType::size_type
739      getDefaultOffset() const;
740    
741   protected:   protected:
742    
# Line 349  class DataTagged : public DataAbstract { Line 747  class DataTagged : public DataAbstract {
747    DataMapType m_offsetLookup;    DataMapType m_offsetLookup;
748    
749    //    //
750    // The actual data    // the offset to the default value
751    DataArrayView::ValueType m_data;    static const int m_defaultValueOffset = 0;
752    
753    //    //
754    // the default value offset    // The actual data
755    static const int m_defaultValueOffset = 0;    ValueType m_data;
756    
757  };  };
758    
# Line 366  DataTagged::isCurrentTag(int tag) const Line 764  DataTagged::isCurrentTag(int tag) const
764    return (pos!=m_offsetLookup.end());    return (pos!=m_offsetLookup.end());
765  }  }
766    
767    // inline
768    // DataArrayView&
769    // DataTagged::getDefaultValue()
770    // {
771    //   // The default value is always the first value.
772    //   return getPointDataView();
773    // }
774    
775    // inline
776    // const DataArrayView&
777    // DataTagged::getDefaultValue() const
778    // {
779    //   // The default value is always the first value.
780    //   return getPointDataView();
781    // }
782    
783    
784    inline
785    DataTypes::ValueType::size_type
786    DataTagged::getDefaultOffset() const
787    {
788      return m_defaultValueOffset;  
789    }
790    
791  inline  inline
792  DataArrayView&  DataTypes::ValueType::reference
793  DataTagged::getDefaultValue()  DataTagged::getDefaultValue(DataTypes::ValueType::size_type i)
794  {  {
795    //      return getVector()[i];
   // The default value is always the first value.  
   return getPointDataView();  
796  }  }
797    
798  inline  inline
799  const DataArrayView&  DataTypes::ValueType::const_reference
800  DataTagged::getDefaultValue() const  DataTagged::getDefaultValue(DataTypes::ValueType::size_type i) const
801  {  {
802    //      return getVector()[i];
803    // The default value is always the first value.  }
804    return getPointDataView();  
805    
806    
807    
808    // inline
809    // const DataTypes::ValueType::ElementType*
810    // DataTagged::getData() const
811    // {
812    //    return &(m_data[0]);
813    // }
814    
815    inline
816    const DataTagged::DataMapType&
817    DataTagged::getTagLookup() const
818    {
819      return m_offsetLookup;
820    }
821    
822    inline
823    DataTypes::ValueType::size_type
824    DataTagged::getLength() const
825    {
826      return m_data.size();
827  }  }
828    
829  } // end of namespace  } // end of namespace

Legend:
Removed from v.100  
changed lines
  Added in v.1799

  ViewVC Help
Powered by ViewVC 1.1.26