/[escript]/branches/arrexp_2137_win/escript/src/DataTagged.cpp
ViewVC logotype

Diff of /branches/arrexp_2137_win/escript/src/DataTagged.cpp

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

revision 519 by jgs, Tue Feb 14 05:30:50 2006 UTC revision 757 by woo409, Mon Jun 26 13:12:56 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 "DataTagged.h"  #include "DataTagged.h"
# Line 80  DataTagged::DataTagged(const FunctionSpa Line 78  DataTagged::DataTagged(const FunctionSpa
78    }    }
79  }  }
80    
81    DataTagged::DataTagged(const FunctionSpace& what,
82                           const DataArrayView::ShapeType &shape,
83                           const TagListType& tags,
84                           const ValueType& data)
85      : DataAbstract(what)
86    {
87      // alternative constructor
88      // not unit_tested tested yet
89    
90      // copy the data
91      m_data=data;
92    
93      // create the view of the data
94      DataArrayView tempView(m_data,shape);
95      setPointDataView(tempView);
96    
97      // create the tag lookup map
98      for (int sampleNo=0; sampleNo<getNumSamples(); sampleNo++) {
99        m_offsetLookup.insert(DataMapType::value_type(sampleNo,tags[sampleNo]));
100      }
101    }
102    
103    
104  DataTagged::DataTagged(const DataTagged& other)  DataTagged::DataTagged(const DataTagged& other)
105    : DataAbstract(other.getFunctionSpace()),    : DataAbstract(other.getFunctionSpace()),
106    m_data(other.m_data),    m_data(other.m_data),
# Line 200  DataTagged::setSlice(const DataAbstract* Line 221  DataTagged::setSlice(const DataAbstract*
221    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
222      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
223    }    }
224    if (otherTemp->getPointDataView().getRank()>0 and !other->getPointDataView().checkShape(regionShape)) {    if (otherTemp->getPointDataView().getRank()>0 && !other->getPointDataView().checkShape(regionShape)) {
225      throw DataException (other->getPointDataView().createShapeErrorMessage(      throw DataException (other->getPointDataView().createShapeErrorMessage(
226                           "Error - Couldn't copy slice due to shape mismatch.",regionShape));                           "Error - Couldn't copy slice due to shape mismatch.",regionShape));
227    }    }
# Line 208  DataTagged::setSlice(const DataAbstract* Line 229  DataTagged::setSlice(const DataAbstract*
229    // copy slice from other default value to this default value    // copy slice from other default value to this default value
230    getDefaultValue().copySliceFrom(otherTemp->getDefaultValue(), regionLoopRange);    getDefaultValue().copySliceFrom(otherTemp->getDefaultValue(), regionLoopRange);
231    
232    // loop through the tag values copying slices from other to this    // loop through tag values in other, adding any which aren't in this, using default value
233    DataMapType::const_iterator pos;    DataMapType::const_iterator pos;
234      for (pos=otherTemp->m_offsetLookup.begin();pos!=otherTemp->m_offsetLookup.end();pos++) {
235        if (!isCurrentTag(pos->first)) {
236          addTaggedValue(pos->first,getDefaultValue());
237        }
238      }
239    
240      // loop through the tag values copying slices from other to this
241    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();pos++) {    for (pos=m_offsetLookup.begin();pos!=m_offsetLookup.end();pos++) {
242      getDataPointByTag(pos->first).copySliceFrom(otherTemp->getDataPointByTag(pos->first), regionLoopRange);      getDataPointByTag(pos->first).copySliceFrom(otherTemp->getDataPointByTag(pos->first), regionLoopRange);
243    }    }
# Line 414  DataTagged::extractData(ifstream& archiv Line 442  DataTagged::extractData(ifstream& archiv
442  {  {
443    return(m_data.extractData(archiveFile, noValues));    return(m_data.extractData(archiveFile, noValues));
444  }  }
445    void
446    DataTagged::eigenvalues(DataAbstract* ev)
447    {
448      DataTagged* temp_ev=dynamic_cast<DataTagged*>(ev);
449      if (temp_ev==0) {
450        throw DataException("Error - DataTagged::eigenvalues casting to DataTagged failed (propably a programming error).");
451      }
452      const DataTagged::DataMapType& thisLookup=getTagLookup();
453      DataTagged::DataMapType::const_iterator i;
454      DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
455      for (i=thisLookup.begin();i!=thisLookupEnd;i++) {
456          temp_ev->addTaggedValue(i->first,temp_ev->getDefaultValue());
457          DataArrayView thisView=getDataPointByTag(i->first);
458          DataArrayView evView=temp_ev->getDataPointByTag(i->first);
459          DataArrayView::eigenvalues(thisView,0,evView,0);
460      }
461      DataArrayView::eigenvalues(getDefaultValue(),0,temp_ev->getDefaultValue(),0);
462    }
463    void
464    DataTagged::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
465    {
466      DataTagged* temp_ev=dynamic_cast<DataTagged*>(ev);
467      if (temp_ev==0) {
468        throw DataException("Error - DataTagged::eigenvalues_and_eigenvectors casting to DataTagged failed (propably a programming error).");
469      }
470      DataTagged* temp_V=dynamic_cast<DataTagged*>(V);
471      if (temp_V==0) {
472        throw DataException("Error - DataTagged::eigenvalues_and_eigenvectors casting to DataTagged failed (propably a programming error).");
473      }
474      const DataTagged::DataMapType& thisLookup=getTagLookup();
475      DataTagged::DataMapType::const_iterator i;
476      DataTagged::DataMapType::const_iterator thisLookupEnd=thisLookup.end();
477      for (i=thisLookup.begin();i!=thisLookupEnd;i++) {
478          temp_ev->addTaggedValue(i->first,temp_ev->getDefaultValue());
479          temp_V->addTaggedValue(i->first,temp_V->getDefaultValue());
480          DataArrayView thisView=getDataPointByTag(i->first);
481          DataArrayView evView=temp_ev->getDataPointByTag(i->first);
482          DataArrayView VView=temp_V->getDataPointByTag(i->first);
483          DataArrayView::eigenvalues_and_eigenvectors(thisView,0,evView,0,VView,0,tol);
484      }
485      DataArrayView::eigenvalues_and_eigenvectors(getDefaultValue(),0,
486                                                  temp_ev->getDefaultValue(),0,
487                                                  temp_V->getDefaultValue(),0,
488                                                  tol);
489    
490    
491    }
492    
493    
494  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.519  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC 1.1.26