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

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

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

revision 474 by jgs, Mon Jan 30 04:23:44 2006 UTC revision 699 by gross, Fri Mar 31 06:27:56 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
 /*=============================================================================  
2    
3   ******************************************************************************  /*
4   *                                                                            *   ************************************************************
5   *       COPYRIGHT ACcESS 2004 -  All Rights Reserved                         *   *          Copyright 2006 by ACcESS MNRF                   *
6   *                                                                            *   *                                                          *
7   * This software is the property of ACcESS.  No part of this code             *   *              http://www.access.edu.au                    *
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                          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
11   * person has a software license agreement with ACcESS.                       *   *                                                          *
12   *                                                                            *   ************************************************************
13   ******************************************************************************  */
   
 ******************************************************************************/  
14    
15  #include "Data.h"  #include "Data.h"
16    
 #include <iostream>  
 #include <fstream>  
 #include <algorithm>  
 #include <vector>  
 #include <exception>  
 #include <functional>  
 #include <math.h>  
   
 #include <boost/python/dict.hpp>  
 #include <boost/python/str.hpp>  
 #include <boost/python/extract.hpp>  
 #include <boost/python/long.hpp>  
 #include <boost/python/tuple.hpp>  
   
 #include "DataException.h"  
17  #include "DataExpanded.h"  #include "DataExpanded.h"
18  #include "DataConstant.h"  #include "DataConstant.h"
19  #include "DataTagged.h"  #include "DataTagged.h"
20  #include "DataEmpty.h"  #include "DataEmpty.h"
21  #include "DataArray.h"  #include "DataArray.h"
22    #include "DataArrayView.h"
23  #include "DataProf.h"  #include "DataProf.h"
24  #include "FunctionSpaceFactory.h"  #include "FunctionSpaceFactory.h"
25  #include "AbstractContinuousDomain.h"  #include "AbstractContinuousDomain.h"
26  #include "UnaryFuncs.h"  #include "UnaryFuncs.h"
27    
28    #include <fstream>
29    #include <algorithm>
30    #include <vector>
31    #include <functional>
32    #include <math.h>
33    
34    #include <boost/python/dict.hpp>
35    #include <boost/python/extract.hpp>
36    #include <boost/python/long.hpp>
37    
38  using namespace std;  using namespace std;
39  using namespace boost::python;  using namespace boost::python;
40  using namespace boost;  using namespace boost;
# Line 444  Data::whereNonPositive() const Line 437  Data::whereNonPositive() const
437  }  }
438    
439  Data  Data
440  Data::whereZero() const  Data::whereZero(double tol) const
441  {  {
442  #if defined DOPROF  #if defined DOPROF
443    profData->where++;    profData->where++;
444  #endif  #endif
445    return escript::unaryOp(*this,bind2nd(equal_to<double>(),0.0));    Data dataAbs=abs();
446      return escript::unaryOp(dataAbs,bind2nd(less_equal<double>(),tol));
447  }  }
448    
449  Data  Data
450  Data::whereNonZero() const  Data::whereNonZero(double tol) const
451  {  {
452  #if defined DOPROF  #if defined DOPROF
453    profData->where++;    profData->where++;
454  #endif  #endif
455    return escript::unaryOp(*this,bind2nd(not_equal_to<double>(),0.0));    Data dataAbs=abs();
456      return escript::unaryOp(dataAbs,bind2nd(greater<double>(),tol));
457  }  }
458    
459  Data  Data
# Line 1190  Data::transpose(int axis) const Line 1185  Data::transpose(int axis) const
1185  #if defined DOPROF  #if defined DOPROF
1186    profData->reduction2++;    profData->reduction2++;
1187  #endif  #endif
1188    
1189    // not implemented    // not implemented
1190    throw DataException("Error - Data::transpose not implemented yet.");    throw DataException("Error - Data::transpose not implemented yet.");
1191    return Data();    return Data();
1192  }  }
1193    
1194    Data
1195    Data::eigenvalues() const
1196    {
1197         #if defined DOPROF
1198            profData->unary++;
1199         #endif
1200         // check input
1201         DataArrayView::ShapeType s=getDataPointShape();
1202         if (getDataPointRank()!=2)
1203            throw DataException("Error - Data::eigenvalues can only be calculated for rank 2 object.");
1204         if(s[0] != s[1])
1205            throw DataException("Error - Data::eigenvalues can only be calculated for object with equal first and second dimension.");
1206         // create return
1207         DataArrayView::ShapeType ev_shape(1,s[0]);
1208         Data ev(0.,ev_shape,getFunctionSpace());
1209         ev.typeMatchRight(*this);
1210         m_data->eigenvalues(ev.m_data.get());
1211         return ev;
1212    }
1213    
1214    const boost::python::tuple
1215    Data::eigenvalues_and_eigenvectors(const double tol) const
1216    {
1217         #if defined DOPROF
1218            profData->unary++;
1219         #endif
1220         DataArrayView::ShapeType s=getDataPointShape();
1221         if (getDataPointRank()!=2)
1222            throw DataException("Error - Data::eigenvalues and eigenvectors can only be calculated for rank 2 object.");
1223         if(s[0] != s[1])
1224            throw DataException("Error - Data::eigenvalues and eigenvectors can only be calculated for object with equal first and second dimension.");
1225         // create return
1226         DataArrayView::ShapeType ev_shape(1,s[0]);
1227         Data ev(0.,ev_shape,getFunctionSpace());
1228         ev.typeMatchRight(*this);
1229         DataArrayView::ShapeType V_shape(2,s[0]);
1230         Data V(0.,V_shape,getFunctionSpace());
1231         V.typeMatchRight(*this);
1232         m_data->eigenvalues_and_eigenvectors(ev.m_data.get(),V.m_data.get(),tol);
1233         return make_tuple(boost::python::object(ev),boost::python::object(V));
1234    }
1235    
1236  const boost::python::tuple  const boost::python::tuple
1237  Data::mindp() const  Data::mindp() const
1238  {  {
# Line 1351  Data::operator/=(const boost::python::ob Line 1389  Data::operator/=(const boost::python::ob
1389  }  }
1390    
1391  Data  Data
1392    Data::rpowO(const boost::python::object& left) const
1393    {
1394    #if defined DOPROF
1395      profData->binary++;
1396    #endif
1397      Data left_d(left,*this);
1398      return left_d.powD(*this);
1399    }
1400    
1401    Data
1402  Data::powO(const boost::python::object& right) const  Data::powO(const boost::python::object& right) const
1403  {  {
1404  #if defined DOPROF  #if defined DOPROF

Legend:
Removed from v.474  
changed lines
  Added in v.699

  ViewVC Help
Powered by ViewVC 1.1.26