/[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 2037 by jfenwick, Thu Nov 13 06:17:12 2008 UTC revision 2084 by jfenwick, Fri Nov 21 05:20:42 2008 UTC
# Line 26  Line 26 
26  #include "EscriptParams.h"  #include "EscriptParams.h"
27    
28  extern "C" {  extern "C" {
29  #include "escript/blocktimer.h"  #include "esysUtils/blocktimer.h"
30  }  }
31    
32  #include <fstream>  #include <fstream>
# Line 1324  Data::tanh() const Line 1324  Data::tanh() const
1324  Data  Data
1325  Data::erf() const  Data::erf() const
1326  {  {
1327  #ifdef _WIN32  #if defined (_WIN32) && !defined(__INTEL_COMPILER)
1328    throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");    throw DataException("Error - Data:: erf function is not supported on _WIN32 platforms.");
1329  #else  #else
1330    if (isLazy())    if (isLazy())
# Line 1344  Data::asinh() const Line 1344  Data::asinh() const
1344      DataLazy* c=new DataLazy(borrowDataPtr(),ASINH);      DataLazy* c=new DataLazy(borrowDataPtr(),ASINH);
1345      return Data(c);      return Data(c);
1346    }    }
1347  #ifdef _WIN32  #if defined (_WIN32) && !defined(__INTEL_COMPILER)
1348    return C_TensorUnaryOperation(*this, escript::asinh_substitute);    return C_TensorUnaryOperation(*this, escript::asinh_substitute);
1349  #else  #else
1350    return C_TensorUnaryOperation(*this, ::asinh);    return C_TensorUnaryOperation(*this, ::asinh);
# Line 1359  Data::acosh() const Line 1359  Data::acosh() const
1359      DataLazy* c=new DataLazy(borrowDataPtr(),ACOSH);      DataLazy* c=new DataLazy(borrowDataPtr(),ACOSH);
1360      return Data(c);      return Data(c);
1361    }    }
1362  #ifdef _WIN32  #if defined (_WIN32) && !defined(__INTEL_COMPILER)
1363    return C_TensorUnaryOperation(*this, escript::acosh_substitute);    return C_TensorUnaryOperation(*this, escript::acosh_substitute);
1364  #else  #else
1365    return C_TensorUnaryOperation(*this, ::acosh);    return C_TensorUnaryOperation(*this, ::acosh);
# Line 1374  Data::atanh() const Line 1374  Data::atanh() const
1374      DataLazy* c=new DataLazy(borrowDataPtr(),ATANH);      DataLazy* c=new DataLazy(borrowDataPtr(),ATANH);
1375      return Data(c);      return Data(c);
1376    }    }
1377  #ifdef _WIN32  #if defined (_WIN32) && !defined(__INTEL_COMPILER)
1378    return C_TensorUnaryOperation(*this, escript::atanh_substitute);    return C_TensorUnaryOperation(*this, escript::atanh_substitute);
1379  #else  #else
1380    return C_TensorUnaryOperation(*this, ::atanh);    return C_TensorUnaryOperation(*this, ::atanh);
# Line 1722  Data::nonsymmetric() const Line 1722  Data::nonsymmetric() const
1722       }       }
1723  }  }
1724    
   
 // Doing a lazy version of this would require some thought.  
 // First it needs a parameter (which DataLazy doesn't support at the moment).  
 // (secondly although it does not apply to trace) we can't handle operations which return  
 // multiple results (like eigenvectors_values) or return values of different shapes to their input  
 // (like eigenvalues).  
1725  Data  Data
1726  Data::trace(int axis_offset) const  Data::trace(int axis_offset) const
1727  {  {    
1728       if (isLazy())       if (isLazy())
1729       {       {
1730      Data temp(*this);   // to get around the fact that you can't resolve a const Data      DataLazy* c=new DataLazy(borrowDataPtr(),TRACE,axis_offset);
1731      temp.resolve();      return Data(c);
     return temp.trace(axis_offset);  
1732       }       }
1733       DataTypes::ShapeType s=getDataPointShape();       DataTypes::ShapeType s=getDataPointShape();
1734       if (getDataPointRank()==2) {       if (getDataPointRank()==2) {
# Line 1789  Data::transpose(int axis_offset) const Line 1782  Data::transpose(int axis_offset) const
1782  {      {    
1783       if (isLazy())       if (isLazy())
1784       {       {
1785      Data temp(*this);   // to get around the fact that you can't resolve a const Data      DataLazy* c=new DataLazy(borrowDataPtr(),TRANS,axis_offset);
1786      temp.resolve();      return Data(c);
     return temp.transpose(axis_offset);  
1787       }       }
1788       DataTypes::ShapeType s=getDataPointShape();       DataTypes::ShapeType s=getDataPointShape();
1789       DataTypes::ShapeType ev_shape;       DataTypes::ShapeType ev_shape;
# Line 1894  Data::calc_minGlobalDataPoint(int& ProcN Line 1886  Data::calc_minGlobalDataPoint(int& ProcN
1886    double next,local_min;    double next,local_min;
1887    int local_lowi=0,local_lowj=0;        int local_lowi=0,local_lowj=0;    
1888    
1889    #pragma omp parallel private(next,local_min,local_lowi,local_lowj)    #pragma omp parallel firstprivate(local_lowi,local_lowj) private(next,local_min)
1890    {    {
1891      local_min=min;      local_min=min;
1892      #pragma omp for private(i,j) schedule(static)      #pragma omp for private(i,j) schedule(static)
# Line 1921  Data::calc_minGlobalDataPoint(int& ProcN Line 1913  Data::calc_minGlobalDataPoint(int& ProcN
1913      next = temp.getDataPoint(lowi,lowj);      next = temp.getDataPoint(lowi,lowj);
1914      int lowProc = 0;      int lowProc = 0;
1915      double *globalMins = new double[get_MPISize()+1];      double *globalMins = new double[get_MPISize()+1];
1916      int error = MPI_Gather ( &next, 1, MPI_DOUBLE, globalMins, 1, MPI_DOUBLE, 0, get_MPIComm() );      int error;
1917        error = MPI_Gather ( &next, 1, MPI_DOUBLE, globalMins, 1, MPI_DOUBLE, 0, get_MPIComm() );
1918    
1919      if( get_MPIRank()==0 ){      if( get_MPIRank()==0 ){
1920          next = globalMins[lowProc];          next = globalMins[lowProc];
# Line 2512  escript::C_GeneralTensorProduct(Data& ar Line 2505  escript::C_GeneralTensorProduct(Data& ar
2505    // SM is the product of the last axis_offset entries in arg_0.getShape().    // SM is the product of the last axis_offset entries in arg_0.getShape().
2506    
2507    // deal with any lazy data    // deal with any lazy data
2508    if (arg_0.isLazy()) {arg_0.resolve();}  //   if (arg_0.isLazy()) {arg_0.resolve();}
2509    if (arg_1.isLazy()) {arg_1.resolve();}  //   if (arg_1.isLazy()) {arg_1.resolve();}
2510      if (arg_0.isLazy() || arg_1.isLazy())
2511      {
2512        DataLazy* c=new DataLazy(arg_0.borrowDataPtr(), arg_1.borrowDataPtr(), PROD, axis_offset,transpose);
2513        return Data(c);
2514      }
2515    
2516    // Interpolate if necessary and find an appropriate function space    // Interpolate if necessary and find an appropriate function space
2517    Data arg_0_Z, arg_1_Z;    Data arg_0_Z, arg_1_Z;
# Line 2923  Data::borrowReadyPtr() const Line 2921  Data::borrowReadyPtr() const
2921  std::string  std::string
2922  Data::toString() const  Data::toString() const
2923  {  {
2924      if (!m_data->isEmpty() &&      if (!m_data->isEmpty() &&
2925      getNumDataPoints()*getDataPointSize()>escriptParams.getInt("TOO_MANY_LINES"))      !m_data->isLazy() &&
2926        getLength()>escriptParams.getInt("TOO_MANY_LINES"))
2927      {      {
2928      stringstream temp;      stringstream temp;
2929      temp << "Summary: inf="<< inf_const() << " sup=" << sup_const() << " data points=" << getNumDataPoints();      temp << "Summary: inf="<< inf_const() << " sup=" << sup_const() << " data points=" << getNumDataPoints();

Legend:
Removed from v.2037  
changed lines
  Added in v.2084

  ViewVC Help
Powered by ViewVC 1.1.26