/[escript]/trunk/escript/py_src/test_util_unary_with_tagged_data.py
ViewVC logotype

Diff of /trunk/escript/py_src/test_util_unary_with_tagged_data.py

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

revision 586 by gross, Fri Feb 17 03:20:53 2006 UTC revision 587 by gross, Fri Mar 10 02:26:50 2006 UTC
# Line 1730  class Test_util_unary_with_tagged_data(T Line 1730  class Test_util_unary_with_tagged_data(T
1730        self.failUnless(isinstance(res,Data),"wrong type of result.")        self.failUnless(isinstance(res,Data),"wrong type of result.")
1731        self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")        self.failUnlessEqual(res.getShape(),(2, 3, 2, 3),"wrong shape of result.")
1732        self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")        self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
1733       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1734       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case0(self):
1735          arg=Data(numarray.array([[0.0, 0.0], [0.0, 0.0]]),self.functionspace)
1736          arg.setTaggedValue(1,numarray.array([[-1.0, 0.0], [0.0, -1.0]]))
1737          res=eigenvalues_and_eigenvectors(arg)
1738          ref_ev=Data(numarray.array([0.0, 0.0]),self.functionspace)
1739          ref_ev.setTaggedValue(1,numarray.array([-1.0, -1.0]))
1740          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1741          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1742          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1743          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1744          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1745          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1746          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1747          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")
1748       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1749       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case5(self):
1750          arg=Data(numarray.array([[-0.99999999999999967, -6.4606252205695602e-16], [-6.4606252205695602e-16, -0.99999999999999967]]),self.functionspace)
1751          arg.setTaggedValue(1,numarray.array([[0.0, 0.0], [0.0, 0.0001]]))
1752          res=eigenvalues_and_eigenvectors(arg)
1753          ref_ev=Data(numarray.array([-1.0, -1.0]),self.functionspace)
1754          ref_ev.setTaggedValue(1,numarray.array([0.0, 0.0001]))
1755          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1756          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1757          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1758          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1759          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1760          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1761          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1762          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")
1763       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1764       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case7(self):
1765          arg=Data(numarray.array([[0.0001, 0.0], [0.0, 0.0]]),self.functionspace)
1766          arg.setTaggedValue(1,numarray.array([[6.0598371831785722e-06, 2.3859213977648625e-05], [2.3859213977648629e-05, 9.3940162816821425e-05]]))
1767          res=eigenvalues_and_eigenvectors(arg)
1768          ref_ev=Data(numarray.array([0.0, 0.0001]),self.functionspace)
1769          ref_ev.setTaggedValue(1,numarray.array([0.0, 0.0001]))
1770          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1771          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1772          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1773          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1774          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1775          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1776          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1777          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")
1778       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1779       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case9(self):
1780          arg=Data(numarray.array([[1.0, 0.0], [0.0, 2.0]]),self.functionspace)
1781          arg.setTaggedValue(1,numarray.array([[2.0, 0.0], [0.0, 1.0]]))
1782          res=eigenvalues_and_eigenvectors(arg)
1783          ref_ev=Data(numarray.array([1.0, 2.0]),self.functionspace)
1784          ref_ev.setTaggedValue(1,numarray.array([1.0, 2.0]))
1785          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1786          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1787          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1788          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1789          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1790          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1791          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1792          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")
1793       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1794       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case11(self):
1795          arg=Data(numarray.array([[1.0605983718317855, 0.23859213977648688], [0.23859213977648688, 1.9394016281682138]]),self.functionspace)
1796          arg.setTaggedValue(1,numarray.array([[1.0, 0.0], [0.0, 1000000.0]]))
1797          res=eigenvalues_and_eigenvectors(arg)
1798          ref_ev=Data(numarray.array([1.0, 2.0]),self.functionspace)
1799          ref_ev.setTaggedValue(1,numarray.array([1.0, 1000000.0]))
1800          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1801          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1802          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1803          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1804          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1805          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1806          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1807          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")
1808       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1809       def test_eigenvalues_and_eigenvectors_taggedData_dim2_case13(self):
1810          arg=Data(numarray.array([[1000000.0, 0.0], [0.0, 1.0]]),self.functionspace)
1811          arg.setTaggedValue(1,numarray.array([[60599.311233413886, 238591.90118434647], [238591.90118434647, 939401.68876658613]]))
1812          res=eigenvalues_and_eigenvectors(arg)
1813          ref_ev=Data(numarray.array([1.0, 1000000.0]),self.functionspace)
1814          ref_ev.setTaggedValue(1,numarray.array([1.0, 1000000.0]))
1815          self.failUnless(isinstance(res[0],Data),"wrong type of result for eigenvalues.")
1816          self.failUnlessEqual(res[0].getShape(),(2,),"wrong shape of result for eigenvalues.")
1817          self.failUnless(isinstance(res[1],Data),"wrong type of result for eigenvectors.")
1818          self.failUnlessEqual(res[1].getShape(),(2, 2),"wrong shape of result for eigenvectors.")
1819          self.failUnless(Lsup(res[0]-ref_ev)<=self.RES_TOL*Lsup(ref_ev),"wrong eigenvalues")
1820          self.failUnless(Lsup(matrixmult(arg,res[1][:,0])-res[0][0]*res[1][:,0])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 0")
1821          self.failUnless(Lsup(matrixmult(arg,res[1][:,1])-res[0][1]*res[1][:,1])<=self.RES_TOL*Lsup(res[0]),"wrong eigenvector 1")
1822          self.failUnless(Lsup(matrixmult(transpose(res[1]),res[1])-kronecker(2))<=self.RES_TOL,"eigenvectors are not orthonormal")

Legend:
Removed from v.586  
changed lines
  Added in v.587

  ViewVC Help
Powered by ViewVC 1.1.26