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

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

  ViewVC Help
Powered by ViewVC 1.1.26