/[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 826 by gross, Tue Aug 29 09:12:33 2006 UTC revision 854 by gross, Thu Sep 21 05:29:42 2006 UTC
# Line 422  Data::tag() Line 422  Data::tag()
422    }    }
423  }  }
424    
425  void  Data
426  Data::reshapeDataPoint(const DataArrayView::ShapeType& shape)  Data::oneOver() const
427  {  {
428    m_data->reshapeDataPoint(shape);  #if defined DOPROF
429      profData->where++;
430    #endif
431      return escript::unaryOp(*this,bind1st(divides<double>(),1.));
432  }  }
433    
434  Data  Data
# Line 1646  Data::operator+=(const Data& right) Line 1649  Data::operator+=(const Data& right)
1649    if (isProtected()) {    if (isProtected()) {
1650          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
1651    }    }
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1652    binaryOp(right,plus<double>());    binaryOp(right,plus<double>());
1653    return (*this);    return (*this);
1654  }  }
# Line 1656  Data::operator+=(const Data& right) Line 1656  Data::operator+=(const Data& right)
1656  Data&  Data&
1657  Data::operator+=(const boost::python::object& right)  Data::operator+=(const boost::python::object& right)
1658  {  {
1659    if (isProtected()) {    Data tmp(right,getFunctionSpace(),false);
1660          throw DataException("Error - attempt to update protected Data object.");    binaryOp(tmp,plus<double>());
   }  
 #if defined DOPROF  
   profData->binary++;  
 #endif  
   binaryOp(right,plus<double>());  
1661    return (*this);    return (*this);
1662  }  }
1663    
# Line 1672  Data::operator-=(const Data& right) Line 1667  Data::operator-=(const Data& right)
1667    if (isProtected()) {    if (isProtected()) {
1668          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
1669    }    }
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1670    binaryOp(right,minus<double>());    binaryOp(right,minus<double>());
1671    return (*this);    return (*this);
1672  }  }
# Line 1682  Data::operator-=(const Data& right) Line 1674  Data::operator-=(const Data& right)
1674  Data&  Data&
1675  Data::operator-=(const boost::python::object& right)  Data::operator-=(const boost::python::object& right)
1676  {  {
1677    if (isProtected()) {    Data tmp(right,getFunctionSpace(),false);
1678          throw DataException("Error - attempt to update protected Data object.");    binaryOp(tmp,minus<double>());
   }  
 #if defined DOPROF  
   profData->binary++;  
 #endif  
   binaryOp(right,minus<double>());  
1679    return (*this);    return (*this);
1680  }  }
1681    
# Line 1698  Data::operator*=(const Data& right) Line 1685  Data::operator*=(const Data& right)
1685    if (isProtected()) {    if (isProtected()) {
1686          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
1687    }    }
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1688    binaryOp(right,multiplies<double>());    binaryOp(right,multiplies<double>());
1689    return (*this);    return (*this);
1690  }  }
# Line 1708  Data::operator*=(const Data& right) Line 1692  Data::operator*=(const Data& right)
1692  Data&  Data&
1693  Data::operator*=(const boost::python::object& right)  Data::operator*=(const boost::python::object& right)
1694  {  {
1695    if (isProtected()) {    Data tmp(right,getFunctionSpace(),false);
1696          throw DataException("Error - attempt to update protected Data object.");    binaryOp(tmp,multiplies<double>());
   }  
 #if defined DOPROF  
   profData->binary++;  
 #endif  
   binaryOp(right,multiplies<double>());  
1697    return (*this);    return (*this);
1698  }  }
1699    
# Line 1724  Data::operator/=(const Data& right) Line 1703  Data::operator/=(const Data& right)
1703    if (isProtected()) {    if (isProtected()) {
1704          throw DataException("Error - attempt to update protected Data object.");          throw DataException("Error - attempt to update protected Data object.");
1705    }    }
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1706    binaryOp(right,divides<double>());    binaryOp(right,divides<double>());
1707    return (*this);    return (*this);
1708  }  }
# Line 1734  Data::operator/=(const Data& right) Line 1710  Data::operator/=(const Data& right)
1710  Data&  Data&
1711  Data::operator/=(const boost::python::object& right)  Data::operator/=(const boost::python::object& right)
1712  {  {
1713    if (isProtected()) {    Data tmp(right,getFunctionSpace(),false);
1714          throw DataException("Error - attempt to update protected Data object.");    binaryOp(tmp,divides<double>());
   }  
 #if defined DOPROF  
   profData->binary++;  
 #endif  
   binaryOp(right,divides<double>());  
1715    return (*this);    return (*this);
1716  }  }
1717    
1718  Data  Data
1719  Data::rpowO(const boost::python::object& left) const  Data::rpowO(const boost::python::object& left) const
1720  {  {
   if (isProtected()) {  
         throw DataException("Error - attempt to update protected Data object.");  
   }  
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1721    Data left_d(left,*this);    Data left_d(left,*this);
1722    return left_d.powD(*this);    return left_d.powD(*this);
1723  }  }
# Line 1760  Data::rpowO(const boost::python::object& Line 1725  Data::rpowO(const boost::python::object&
1725  Data  Data
1726  Data::powO(const boost::python::object& right) const  Data::powO(const boost::python::object& right) const
1727  {  {
1728  #if defined DOPROF    Data tmp(right,getFunctionSpace(),false);
1729    profData->binary++;    return powD(tmp);
 #endif  
   Data result;  
   result.copy(*this);  
   result.binaryOp(right,(Data::BinaryDFunPtr)::pow);  
   return result;  
1730  }  }
1731    
1732  Data  Data
1733  Data::powD(const Data& right) const  Data::powD(const Data& right) const
1734  {  {
 #if defined DOPROF  
   profData->binary++;  
 #endif  
1735    Data result;    Data result;
1736    result.copy(*this);    if (getDataPointRank()<right.getDataPointRank()) {
1737    result.binaryOp(right,(Data::BinaryDFunPtr)::pow);       result.copy(right);
1738         result.binaryOp(*this,escript::rpow);
1739      } else {
1740         result.copy(*this);
1741         result.binaryOp(right,(Data::BinaryDFunPtr)::pow);
1742      }
1743    return result;    return result;
1744  }  }
1745    
# Line 1790  escript::operator+(const Data& left, con Line 1752  escript::operator+(const Data& left, con
1752    Data result;    Data result;
1753    //    //
1754    // perform a deep copy    // perform a deep copy
1755    result.copy(left);    if (left.getDataPointRank()<right.getDataPointRank()) {
1756    result+=right;       result.copy(right);
1757         result+=left;
1758      } else {
1759         result.copy(left);
1760         result+=right;
1761      }
1762    return result;    return result;
1763  }  }
1764    
# Line 1803  escript::operator-(const Data& left, con Line 1770  escript::operator-(const Data& left, con
1770    Data result;    Data result;
1771    //    //
1772    // perform a deep copy    // perform a deep copy
1773    result.copy(left);    if (left.getDataPointRank()<right.getDataPointRank()) {
1774    result-=right;       result=right.neg();
1775         result+=left;
1776      } else {
1777         result.copy(left);
1778         result-=right;
1779      }
1780    return result;    return result;
1781  }  }
1782    
# Line 1816  escript::operator*(const Data& left, con Line 1788  escript::operator*(const Data& left, con
1788    Data result;    Data result;
1789    //    //
1790    // perform a deep copy    // perform a deep copy
1791    result.copy(left);    if (left.getDataPointRank()<right.getDataPointRank()) {
1792    result*=right;       result.copy(right);
1793         result*=left;
1794      } else {
1795         result.copy(left);
1796         result*=right;
1797      }
1798    return result;    return result;
1799  }  }
1800    
# Line 1829  escript::operator/(const Data& left, con Line 1806  escript::operator/(const Data& left, con
1806    Data result;    Data result;
1807    //    //
1808    // perform a deep copy    // perform a deep copy
1809    result.copy(left);    if (left.getDataPointRank()<right.getDataPointRank()) {
1810    result/=right;       result=right.oneOver();
1811         result*=left;
1812      } else {
1813         result.copy(left);
1814         result/=right;
1815      }
1816    return result;    return result;
1817  }  }
1818    
# Line 1839  escript::operator/(const Data& left, con Line 1821  escript::operator/(const Data& left, con
1821  Data  Data
1822  escript::operator+(const Data& left, const boost::python::object& right)  escript::operator+(const Data& left, const boost::python::object& right)
1823  {  {
1824    //    return left+Data(right,left.getFunctionSpace(),false);
   // Convert to DataArray format if possible  
   DataArray temp(right);  
   Data result;  
   //  
   // perform a deep copy  
   result.copy(left);  
   result+=right;  
   return result;  
1825  }  }
1826    
1827  //  //
# Line 1855  escript::operator+(const Data& left, con Line 1829  escript::operator+(const Data& left, con
1829  Data  Data
1830  escript::operator-(const Data& left, const boost::python::object& right)  escript::operator-(const Data& left, const boost::python::object& right)
1831  {  {
1832    //    return left-Data(right,left.getFunctionSpace(),false);
   // Convert to DataArray format if possible  
   DataArray temp(right);  
   Data result;  
   //  
   // perform a deep copy  
   result.copy(left);  
   result-=right;  
   return result;  
1833  }  }
1834    
1835  //  //
# Line 1871  escript::operator-(const Data& left, con Line 1837  escript::operator-(const Data& left, con
1837  Data  Data
1838  escript::operator*(const Data& left, const boost::python::object& right)  escript::operator*(const Data& left, const boost::python::object& right)
1839  {  {
1840    //    return left*Data(right,left.getFunctionSpace(),false);
   // Convert to DataArray format if possible  
   DataArray temp(right);  
   Data result;  
   //  
   // perform a deep copy  
   result.copy(left);  
   result*=right;  
   return result;  
1841  }  }
1842    
1843  //  //
# Line 1887  escript::operator*(const Data& left, con Line 1845  escript::operator*(const Data& left, con
1845  Data  Data
1846  escript::operator/(const Data& left, const boost::python::object& right)  escript::operator/(const Data& left, const boost::python::object& right)
1847  {  {
1848    //    return left/Data(right,left.getFunctionSpace(),false);
   // Convert to DataArray format if possible  
   DataArray temp(right);  
   Data result;  
   //  
   // perform a deep copy  
   result.copy(left);  
   result/=right;  
   return result;  
1849  }  }
1850    
1851  //  //
# Line 1903  escript::operator/(const Data& left, con Line 1853  escript::operator/(const Data& left, con
1853  Data  Data
1854  escript::operator+(const boost::python::object& left, const Data& right)  escript::operator+(const boost::python::object& left, const Data& right)
1855  {  {
1856    //    return Data(left,right.getFunctionSpace(),false)+right;
   // Construct the result using the given value and the other parameters  
   // from right  
   Data result(left,right);  
   result+=right;  
   return result;  
1857  }  }
1858    
1859  //  //
# Line 1916  escript::operator+(const boost::python:: Line 1861  escript::operator+(const boost::python::
1861  Data  Data
1862  escript::operator-(const boost::python::object& left, const Data& right)  escript::operator-(const boost::python::object& left, const Data& right)
1863  {  {
1864    //    return Data(left,right.getFunctionSpace(),false)-right;
   // Construct the result using the given value and the other parameters  
   // from right  
   Data result(left,right);  
   result-=right;  
   return result;  
1865  }  }
1866    
1867  //  //
# Line 1929  escript::operator-(const boost::python:: Line 1869  escript::operator-(const boost::python::
1869  Data  Data
1870  escript::operator*(const boost::python::object& left, const Data& right)  escript::operator*(const boost::python::object& left, const Data& right)
1871  {  {
1872    //    return Data(left,right.getFunctionSpace(),false)*right;
   // Construct the result using the given value and the other parameters  
   // from right  
   Data result(left,right);  
   result*=right;  
   return result;  
1873  }  }
1874    
1875  //  //
# Line 1942  escript::operator*(const boost::python:: Line 1877  escript::operator*(const boost::python::
1877  Data  Data
1878  escript::operator/(const boost::python::object& left, const Data& right)  escript::operator/(const boost::python::object& left, const Data& right)
1879  {  {
1880    //    return Data(left,right.getFunctionSpace(),false)/right;
   // Construct the result using the given value and the other parameters  
   // from right  
   Data result(left,right);  
   result/=right;  
   return result;  
1881  }  }
1882    
1883  //  //

Legend:
Removed from v.826  
changed lines
  Added in v.854

  ViewVC Help
Powered by ViewVC 1.1.26