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

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

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

trunk/esys2/escript/src/Data/DataTagged.cpp revision 119 by jgs, Tue Apr 12 04:45:05 2005 UTC trunk/escript/src/DataTagged.cpp revision 615 by elspeth, Wed Mar 22 02:12:00 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2    
3  /*  /*
4   ******************************************************************************   ************************************************************
5   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
6   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
7   *                                                                            *   *              http://www.access.edu.au                    *
8   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
9   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
10   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
11   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
12   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
13  */  */
14    
15  #include "escript/Data/DataTagged.h"  #include "DataTagged.h"
 #include "escript/Data/DataConstant.h"  
 #include "escript/Data/DataExpanded.h"  
 #include "escript/Data/DataException.h"  
16    
17  #include <sstream>  #include "DataConstant.h"
18    #include "DataException.h"
19    
20  using namespace std;  using namespace std;
21    
22  namespace escript {  namespace escript {
23    
24  DataTagged::DataTagged():  DataTagged::DataTagged()
25    DataAbstract(FunctionSpace())    : DataAbstract(FunctionSpace())
26  {  {
27    //    // default constructor
28    
29    // create a scalar default value    // create a scalar default value
30    m_data.push_back(0.0);    m_data.resize(1,0.,1);
31    DataArrayView temp(m_data,DataArrayView::ShapeType());    DataArrayView temp(m_data,DataArrayView::ShapeType());
32    setPointDataView(temp);    setPointDataView(temp);
33  }  }
# Line 40  DataTagged::DataTagged(const TagListType Line 38  DataTagged::DataTagged(const TagListType
38                 const FunctionSpace& what)                 const FunctionSpace& what)
39    : DataAbstract(what)    : DataAbstract(what)
40  {  {
41    //    // constructor
42    // Initialise the array of data values  
43    // The default value is always the first item in the values list    // initialise the array of data values
44    m_data.insert(m_data.end(), &defaultValue.getData(0), &defaultValue.getData(defaultValue.noValues()) );    // the default value is always the first item in the values list
45      int len = defaultValue.noValues();
46      m_data.resize(len,0.,len);
47      for (int i=0; i<defaultValue.noValues(); i++) {
48        m_data[i]=defaultValue.getData(i);
49      }
50    
51    // create the data view    // create the data view
52    DataArrayView temp(m_data,defaultValue.getShape());    DataArrayView temp(m_data,defaultValue.getShape());
53    setPointDataView(temp);    setPointDataView(temp);
54    
55    // add remaining tags and values    // add remaining tags and values
56    addTaggedValues(tagKeys,values);    addTaggedValues(tagKeys,values);
57  }  }
# Line 54  DataTagged::DataTagged(const TagListType Line 59  DataTagged::DataTagged(const TagListType
59  DataTagged::DataTagged(const FunctionSpace& what,  DataTagged::DataTagged(const FunctionSpace& what,
60                         const DataArrayView::ShapeType &shape,                         const DataArrayView::ShapeType &shape,
61                         const int tags[],                         const int tags[],
62                         const DataArrayView::ValueType &data)                         const ValueType& data)
63    : DataAbstract(what)    : DataAbstract(what)
64  {  {
65    //    // alternative constructor
66    // copy the data in the correct format    // not unit_tested tested yet
67    
68      // copy the data
69    m_data=data;    m_data=data;
70    //  
71    // create the view of the data    // create the view of the data
72    DataArrayView tempView(m_data,shape);    DataArrayView tempView(m_data,shape);
73    setPointDataView(tempView);    setPointDataView(tempView);
74    //  
75    // create the tag lookup map    // create the tag lookup map
76    for (int sampleNo=0; sampleNo<getNumSamples(); sampleNo++) {    for (int sampleNo=0; sampleNo<getNumSamples(); sampleNo++) {
77      m_offsetLookup.insert(DataMapType::value_type(sampleNo,tags[sampleNo]));      m_offsetLookup.insert(DataMapType::value_type(sampleNo,tags[sampleNo]));
# Line 76  DataTagged::DataTagged(const DataTagged& Line 83  DataTagged::DataTagged(const DataTagged&
83    m_data(other.m_data),    m_data(other.m_data),
84    m_offsetLookup(other.m_offsetLookup)    m_offsetLookup(other.m_offsetLookup)
85  {  {
86      // copy constructor
87    
88    // create the data view    // create the data view
89    DataArrayView temp(m_data,other.getPointDataView().getShape());    DataArrayView temp(m_data,other.getPointDataView().getShape());
90    setPointDataView(temp);    setPointDataView(temp);
# Line 84  DataTagged::DataTagged(const DataTagged& Line 93  DataTagged::DataTagged(const DataTagged&
93  DataTagged::DataTagged(const DataConstant& other)  DataTagged::DataTagged(const DataConstant& other)
94    : DataAbstract(other.getFunctionSpace())    : DataAbstract(other.getFunctionSpace())
95  {  {
96    //    // copy constructor
97    // Fill the default value with the constant value item from other  
98      // fill the default value with the constant value item from "other"
99    const DataArrayView& value=other.getPointDataView();    const DataArrayView& value=other.getPointDataView();
100    m_data.insert(m_data.end(), &value.getData(0), &value.getData(value.noValues()) );    int len = value.noValues();
101    // create the data view    m_data.resize(len,0.,len);
102    DataArrayView temp(m_data,value.getShape());    for (int i=0; i<value.noValues(); i++) {
103    setPointDataView(temp);      m_data[i]=value.getData(i);
104  }    }
105    
 DataTagged::DataTagged(const DataTagged& other,  
                const DataArrayView::RegionType& region)  
   : DataAbstract(other.getFunctionSpace())  
 {  
   //  
   // get the shape of the slice to copy from other  
   DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));  
   DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);  
   // allocate enough space for all values  
   m_data.resize(DataArrayView::noValues(shape)*(other.m_offsetLookup.size()+1));  
106    // create the data view    // create the data view
107    DataArrayView temp(m_data,shape);    DataArrayView temp(m_data,value.getShape());
108    setPointDataView(temp);    setPointDataView(temp);
   // copy the default value  
   getDefaultValue().copySlice(other.getDefaultValue(),region_loop_range);  
   //  
   // Loop through the tag values copying these  
   DataMapType::const_iterator pos;  
   DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();  
   for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();++pos){  
     getPointDataView().copySlice(tagOffset,other.getPointDataView(), pos->second,region_loop_range);  
     m_offsetLookup.insert(DataMapType::value_type(pos->first,tagOffset));  
     tagOffset+=getPointDataView().noValues();  
   }  
109  }  }
110    
111  void  void
112  DataTagged::reshapeDataPoint(const DataArrayView::ShapeType& shape)  DataTagged::reshapeDataPoint(const DataArrayView::ShapeType& shape)
113  {  {
   //  
114    // can only reshape a rank zero data point    // can only reshape a rank zero data point
115    if (getPointDataView().getRank()!=0) {    if (getPointDataView().getRank()!=0) {
116      stringstream temp;      stringstream temp;
# Line 131  DataTagged::reshapeDataPoint(const DataA Line 119  DataTagged::reshapeDataPoint(const DataA
119       << getPointDataView().getRank();       << getPointDataView().getRank();
120      throw DataException(temp.str());      throw DataException(temp.str());
121    }    }
122    //  
123    // allocate enough space for all values    // allocate enough space for all values
124    DataArrayView::ValueType newData(DataArrayView::noValues(shape)*(m_offsetLookup.size()+1));    DataArrayView::ValueType newData(DataArrayView::noValues(shape)*(m_offsetLookup.size()+1));
125    DataArrayView newView(newData,shape);    DataArrayView newView(newData,shape);
126    newView.copy(0,getDefaultValue()());    newView.copy(0,getDefaultValue()());
127    //  
128    // Loop through the tag values    // loop through the tag values
129    DataMapType::iterator pos;    DataMapType::iterator pos;
130    DataArrayView::ValueType::size_type tagOffset=DataArrayView::noValues(shape);    DataArrayView::ValueType::size_type tagOffset=DataArrayView::noValues(shape);
131    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();++pos){    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();pos++){
132      newView.copy(tagOffset,m_data[pos->second]);      newView.copy(tagOffset,m_data[pos->second]);
133      pos->second=tagOffset;      pos->second=tagOffset;
134      tagOffset+=DataArrayView::noValues(shape);      tagOffset+=DataArrayView::noValues(shape);
# Line 153  DataTagged::reshapeDataPoint(const DataA Line 141  DataTagged::reshapeDataPoint(const DataA
141  DataAbstract*  DataAbstract*
142  DataTagged::getSlice(const DataArrayView::RegionType& region) const  DataTagged::getSlice(const DataArrayView::RegionType& region) const
143  {  {
144    return new DataTagged(*this,region);    return new DataTagged(*this, region);
145    }
146    
147    DataTagged::DataTagged(const DataTagged& other,
148                   const DataArrayView::RegionType& region)
149      : DataAbstract(other.getFunctionSpace())
150    {
151      // slice constructor
152    
153      // get the shape of the slice to copy from other
154      DataArrayView::ShapeType regionShape(DataArrayView::getResultSliceShape(region));
155      DataArrayView::RegionLoopRangeType regionLoopRange=getSliceRegionLoopRange(region);
156    
157      // allocate enough space in this for all values
158      // (need to add one to allow for the default value)
159      int len = DataArrayView::noValues(regionShape)*(other.m_offsetLookup.size()+1);
160      m_data.resize(len,0.0,len);
161    
162      // create the data view
163      DataArrayView temp(m_data,regionShape);
164      setPointDataView(temp);
165    
166      // copy the default value from other to this
167      getDefaultValue().copySlice(other.getDefaultValue(), regionLoopRange);
168    
169      // loop through the tag values copying these
170      DataMapType::const_iterator pos;
171      DataArrayView::ValueType::size_type tagOffset=getPointDataView().noValues();
172      for (pos=other.m_offsetLookup.begin();pos!=other.m_offsetLookup.end();pos++){
173        getPointDataView().copySlice(tagOffset,other.getPointDataView(),pos->second,regionLoopRange);
174        m_offsetLookup.insert(DataMapType::value_type(pos->first,tagOffset));
175        tagOffset+=getPointDataView().noValues();
176      }
177  }  }
178    
179  void  void
180  DataTagged::setSlice(const DataAbstract* value,  DataTagged::setSlice(const DataAbstract* other,
181                       const DataArrayView::RegionType& region)                       const DataArrayView::RegionType& region)
182  {  {
183    const DataTagged* tempDataTag=dynamic_cast<const DataTagged*>(value);  
184    if (tempDataTag==0) {    // other must be another DataTagged object
185      // Data:setSlice implementation should ensure this
186      const DataTagged* otherTemp=dynamic_cast<const DataTagged*>(other);
187      if (otherTemp==0) {
188      throw DataException("Programming error - casting to DataTagged.");      throw DataException("Programming error - casting to DataTagged.");
189    }    }
190    //  
191    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));    // determine shape of the specified region
192    DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region);    DataArrayView::ShapeType regionShape(DataArrayView::getResultSliceShape(region));
193    //  
194      // modify region specification as needed to match rank of this object
195      DataArrayView::RegionLoopRangeType regionLoopRange=getSliceRegionLoopRange(region);
196    
197      // ensure rank/shape of this object is compatible with specified region
198    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
199      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
200    }    }
201    if (tempDataTag->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {    if (otherTemp->getPointDataView().getRank()>0 and !other->getPointDataView().checkShape(regionShape)) {
202      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (other->getPointDataView().createShapeErrorMessage(
203                  "Error - Couldn't copy slice due to shape mismatch.",shape));                           "Error - Couldn't copy slice due to shape mismatch.",regionShape));
204    }    }
205    //  
206    getDefaultValue().copySliceFrom(tempDataTag->getDefaultValue(),region_loop_range);    // copy slice from other default value to this default value
207    //    getDefaultValue().copySliceFrom(otherTemp->getDefaultValue(), regionLoopRange);
208    // Loop through the tag values  
209      // loop through tag values in other, adding any which aren't in this, using default value
210    DataMapType::const_iterator pos;    DataMapType::const_iterator pos;
211    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();++pos){    for (pos=otherTemp->m_offsetLookup.begin();pos!=otherTemp->m_offsetLookup.end();pos++) {
212      getDataPointByTag(pos->first).copySliceFrom(tempDataTag->getDataPointByTag(pos->first),region_loop_range);      if (!isCurrentTag(pos->first)) {
213    }        addTaggedValue(pos->first,getDefaultValue());
214        }
215      }
216    
217      // loop through the tag values copying slices from other to this
218      for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();pos++) {
219        getDataPointByTag(pos->first).copySliceFrom(otherTemp->getDataPointByTag(pos->first), regionLoopRange);
220      }
221    
222  }  }
223    
224  void  int
225  DataTagged::setTaggedValue(int tagKey,  DataTagged::getTagNumber(int dpno)
                            const DataArrayView& value)  
226  {  {
227    DataMapType::iterator pos(m_offsetLookup.find(tagKey));    //
228    if (pos==m_offsetLookup.end()) {    // Get the number of samples and data-points per sample
229      //    int numSamples = getNumSamples();
230      // tag couldn't be found so add as a new tag    int numDataPointsPerSample = getNumDPPSample();
231      addTaggedValue(tagKey,value);    int numDataPoints = numSamples * numDataPointsPerSample;
232    } else {  
233      if (!getPointDataView().checkShape(value.getShape())) {    if (numDataPointsPerSample==0) {
234        throw DataException(getPointDataView().createShapeErrorMessage(      throw DataException("DataTagged::getTagNumber error: no data-points associated with this object.");
          "Error - Cannot setTaggedValue due to shape mismatch.", value.getShape()));  
     }  
     //  
     // copy the values into tagged data storage  
     copy(&value.getData(0), &value.getData(getPointDataView().noValues()), &m_data[pos->second]);  
235    }    }
236    
237      if (dpno<0 || dpno>numDataPoints-1) {
238        throw DataException("DataTagged::getTagNumber error: invalid data-point number supplied.");
239      }
240    
241      //
242      // Determine the sample number which corresponds to this data-point number
243      int sampleNo = dpno / numDataPointsPerSample;
244    
245      //
246      // Determine the tag number which corresponds to this sample number
247      int tagNo = getFunctionSpace().getTagFromSampleNo(sampleNo);
248    
249      //
250      // return the tag number
251      return(tagNo);
252  }  }
253    
254  void  void
255  DataTagged::setTaggedValues(const TagListType& tagKeys,  DataTagged::setTaggedValues(const TagListType& tagKeys,
256                              const ValueListType& values)                              const ValueListType& values)
257  {  {
258    for (int i=0;i<tagKeys.size();++i) {    addTaggedValues(tagKeys,values);
     setTaggedValue(tagKeys[i],values[i]);  
   }  
259  }  }
260    
261  void  void
262  DataTagged::addTaggedValue(int tagKey,  DataTagged::setTaggedValue(int tagKey,
263                             const DataArrayView& value)                             const DataArrayView& value)
264  {  {
265    if (!getPointDataView().checkShape(value.getShape())) {    if (!getPointDataView().checkShape(value.getShape())) {
266      throw DataException(getPointDataView().createShapeErrorMessage(        throw DataException(getPointDataView().createShapeErrorMessage(
267           "Error - Cannot addTaggedValue due to shape mismatch.", value.getShape()));                            "Error - Cannot setTaggedValue due to shape mismatch.", value.getShape()));
268      }
269      DataMapType::iterator pos(m_offsetLookup.find(tagKey));
270      if (pos==m_offsetLookup.end()) {
271        // tag couldn't be found so use addTaggedValue
272        addTaggedValue(tagKey,value);
273      } else {
274        // copy the values into the data array at the offset determined by m_offsetLookup
275        int offset=pos->second;
276        for (int i=0; i<getPointDataView().noValues(); i++) {
277          m_data[offset+i]=value.getData(i);
278        }
279    }    }
   //  
   // save the key and the location of its data  
   m_offsetLookup.insert( DataMapType::value_type(tagKey,m_data.size()) );  
   //  
   // insert the data given in value at the end of m_data  
   m_data.insert( m_data.end(), &(value.getData(0)), &(value.getData(value.noValues())) );  
280  }  }
281    
282  void  void
# Line 235  DataTagged::addTaggedValues(const TagLis Line 284  DataTagged::addTaggedValues(const TagLis
284                              const ValueListType& values)                              const ValueListType& values)
285  {  {
286    if (values.size()==0) {    if (values.size()==0) {
287      //      // copy the current default value for each of the tags
     // Copy the default value for each of the tags  
288      TagListType::const_iterator iT;      TagListType::const_iterator iT;
289      for (iT=tagKeys.begin();iT!=tagKeys.end();++iT) {      for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) {
       //  
290        // the point data view for DataTagged points at the default value        // the point data view for DataTagged points at the default value
291        addTaggedValue(*iT,getPointDataView());        addTaggedValue(*iT,getPointDataView());
292      }      }
293    } else if (values.size()==1 && tagKeys.size()>1) {    } else if (values.size()==1 && tagKeys.size()>1) {
294      //      // assume the one given value will be used for all tag values
     // assume the one value will be used for all tag values  
     // Copy the input data  
295      TagListType::const_iterator iT;      TagListType::const_iterator iT;
296      for (iT=tagKeys.begin();iT!=tagKeys.end();++iT) {      for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) {
297        addTaggedValue(*iT,values[0]);        addTaggedValue(*iT,values[0]);
298      }      }
299    } else {    } else {
300      if (tagKeys.size()!=values.size()) {      if (tagKeys.size()!=values.size()) {
301        stringstream temp;        stringstream temp;
302        temp << "Error - (addTaggedValue) Number of tags: " << tagKeys.size()        temp << "Error - (addTaggedValue) Number of tags: " << tagKeys.size()
303         << " doesn't match the number of values: " << values.size();         << " doesn't match number of values: " << values.size();
304        throw DataException(temp.str());        throw DataException(temp.str());
305      } else {      } else {
306        for (int i=0;i<tagKeys.size();++i) {        for (int i=0;i<tagKeys.size();i++) {
307          addTaggedValue(tagKeys[i],values[i]);          addTaggedValue(tagKeys[i],values[i]);
308        }        }
309      }      }
310    }    }
311  }  }
312    
313    void
314    DataTagged::addTaggedValue(int tagKey,
315                               const DataArrayView& value)
316    {
317      if (!getPointDataView().checkShape(value.getShape())) {
318        throw DataException(getPointDataView().createShapeErrorMessage(
319                            "Error - Cannot addTaggedValue due to shape mismatch.", value.getShape()));
320      }
321      DataMapType::iterator pos(m_offsetLookup.find(tagKey));
322      if (pos!=m_offsetLookup.end()) {
323        // tag already exists so use setTaggedValue
324        setTaggedValue(tagKey,value);
325      } else {
326        // save the key and the location of its data in the lookup tab
327        m_offsetLookup.insert(DataMapType::value_type(tagKey,m_data.size()));
328        // add the data given in "value" at the end of m_data
329        // need to make a temp copy of m_data, resize m_data, then copy
330        // all the old values plus the value to be added back into m_data
331        ValueType m_data_temp(m_data);
332        int oldSize=m_data.size();
333        int newSize=m_data.size()+value.noValues();
334        m_data.resize(newSize,0.,newSize);
335        for (int i=0;i<oldSize;i++) {
336          m_data[i]=m_data_temp[i];
337        }
338        for (int i=0;i<value.noValues();i++) {
339          m_data[oldSize+i]=value.getData(i);
340        }
341      }
342    }
343    
344  double*  double*
345  DataTagged::getSampleDataByTag(int tag)  DataTagged::getSampleDataByTag(int tag)
346  {  {
347    DataMapType::iterator pos(m_offsetLookup.find(tag));    DataMapType::iterator pos(m_offsetLookup.find(tag));
348    if (pos==m_offsetLookup.end()) {    if (pos==m_offsetLookup.end()) {
     //  
349      // tag couldn't be found so return the default value      // tag couldn't be found so return the default value
350      return &(m_data[0]);      return &(m_data[0]);
351    } else {    } else {
     //  
352      // return the data-point corresponding to the given tag      // return the data-point corresponding to the given tag
353      return &(m_data[pos->second]);      return &(m_data[pos->second]);
354    }    }
# Line 287  DataTagged::toString() const Line 361  DataTagged::toString() const
361    DataMapType::const_iterator i;    DataMapType::const_iterator i;
362    temp << "Tag(Default)" << endl;    temp << "Tag(Default)" << endl;
363    temp << getDefaultValue().toString() << endl;    temp << getDefaultValue().toString() << endl;
   //  
364    // create a temporary view as the offset will be changed    // create a temporary view as the offset will be changed
365    DataArrayView tempView(getPointDataView().getData(), getPointDataView().getShape());    DataArrayView tempView(getPointDataView().getData(), getPointDataView().getShape());
366    for (i=m_offsetLookup.begin();i!=m_offsetLookup.end();++i) {    for (i=m_offsetLookup.begin();i!=m_offsetLookup.end();++i) {
# Line 298  DataTagged::toString() const Line 371  DataTagged::toString() const
371    return temp.str();    return temp.str();
372  }  }
373    
374  DataArrayView  DataArrayView::ValueType::size_type
375  DataTagged::getDataPointByTag(int tag) const  DataTagged::getPointOffset(int sampleNo,
376                               int dataPointNo) const
377  {  {
378    DataMapType::const_iterator pos(m_offsetLookup.find(tag));    int tagKey=getFunctionSpace().getTagFromSampleNo(sampleNo);
379      DataMapType::const_iterator pos(m_offsetLookup.find(tagKey));
380    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;
381    if (pos!=m_offsetLookup.end()) {    if (pos!=m_offsetLookup.end()) {
382      offset=pos->second;      offset=pos->second;
383    }    }
384    DataArrayView temp(getPointDataView());    return offset;
   temp.setOffset(offset);  
   return temp;  
385  }  }
386    
387  DataArrayView::ValueType::size_type  DataArrayView
388  DataTagged::getPointOffset(int sampleNo,  DataTagged::getDataPointByTag(int tag) const
                            int dataPointNo) const  
389  {  {
390    int tagKey=getFunctionSpace().getTagFromSampleNo(sampleNo);    DataMapType::const_iterator pos(m_offsetLookup.find(tag));
   DataMapType::const_iterator pos(m_offsetLookup.find(tagKey));  
391    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;    DataArrayView::ValueType::size_type offset=m_defaultValueOffset;
392    if (pos!=m_offsetLookup.end()) {    if (pos!=m_offsetLookup.end()) {
393      offset=pos->second;      offset=pos->second;
394    }    }
395    return offset;    DataArrayView temp(getPointDataView());
396      temp.setOffset(offset);
397      return temp;
398  }  }
399    
400  DataArrayView  DataArrayView
# Line 333  DataTagged::getDataPoint(int sampleNo, Line 406  DataTagged::getDataPoint(int sampleNo,
406    return getDataPointByTag(tagKey);    return getDataPointByTag(tagKey);
407  }  }
408    
409  const DataTagged::DataMapType&  int
410  DataTagged::getTagLookup() const  DataTagged::archiveData(ofstream& archiveFile,
411                            const DataArrayView::ValueType::size_type noValues) const
412  {  {
413    return m_offsetLookup;    return(m_data.archiveData(archiveFile, noValues));
414  }  }
415    
416  DataArrayView::ValueType::size_type  int
417  DataTagged::getLength() const  DataTagged::extractData(ifstream& archiveFile,
418                            const DataArrayView::ValueType::size_type noValues)
419  {  {
420    return m_data.size();    return(m_data.extractData(archiveFile, noValues));
421  }  }
422    void
423    DataTagged::eigenvalues(DataAbstract* ev)
424    {
425      DataTagged* temp_ev=dynamic_cast<DataTagged*>(ev);
426      if (temp_ev==0) {
427        throw DataException("Error - DataTagged::eigenvalues casting to DataTagged failed (propably a programming error).");
428      }
429      const DataTagged::DataMapType& thisLookup=getTagLookup();
430      DataTagged::DataMapType::const_iterator i;
431      DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
432      for (i=thisLookup.begin();i!=thisLookupEnd;i++) {
433          temp_ev->addTaggedValue(i->first,temp_ev->getDefaultValue());
434          DataArrayView thisView=getDataPointByTag(i->first);
435          DataArrayView evView=temp_ev->getDataPointByTag(i->first);
436          DataArrayView::eigenvalues(thisView,0,evView,0);
437      }
438      DataArrayView::eigenvalues(getDefaultValue(),0,temp_ev->getDefaultValue(),0);
439    }
440    void
441    DataTagged::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
442    {
443      DataTagged* temp_ev=dynamic_cast<DataTagged*>(ev);
444      if (temp_ev==0) {
445        throw DataException("Error - DataTagged::eigenvalues_and_eigenvectors casting to DataTagged failed (propably a programming error).");
446      }
447      DataTagged* temp_V=dynamic_cast<DataTagged*>(V);
448      if (temp_V==0) {
449        throw DataException("Error - DataTagged::eigenvalues_and_eigenvectors casting to DataTagged failed (propably a programming error).");
450      }
451      const DataTagged::DataMapType& thisLookup=getTagLookup();
452      DataTagged::DataMapType::const_iterator i;
453      DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
454      for (i=thisLookup.begin();i!=thisLookupEnd;i++) {
455          temp_ev->addTaggedValue(i->first,temp_ev->getDefaultValue());
456          temp_V->addTaggedValue(i->first,temp_V->getDefaultValue());
457          DataArrayView thisView=getDataPointByTag(i->first);
458          DataArrayView evView=temp_ev->getDataPointByTag(i->first);
459          DataArrayView VView=temp_V->getDataPointByTag(i->first);
460          DataArrayView::eigenvalues_and_eigenvectors(thisView,0,evView,0,VView,0,tol);
461      }
462      DataArrayView::eigenvalues_and_eigenvectors(getDefaultValue(),0,
463                                                  temp_ev->getDefaultValue(),0,
464                                                  temp_V->getDefaultValue(),0,
465                                                  tol);
466    
467    
468    }
469    
470    
471  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.119  
changed lines
  Added in v.615

  ViewVC Help
Powered by ViewVC 1.1.26