Mentions légales du service

Skip to content
Snippets Groups Projects
Commit dd747d97 authored by hhakim's avatar hhakim
Browse files

Add FaustLazyLinearOp.real and its unit test.

parent 494a35c5
Branches
Tags
No related merge requests found
...@@ -119,7 +119,7 @@ class LazyLinearOp: ...@@ -119,7 +119,7 @@ class LazyLinearOp:
self._checkattr('transpose') self._checkattr('transpose')
new_op = self.__class__(init_lambda=lambda: new_op = self.__class__(init_lambda=lambda:
(self._lambda_stack()).transpose(), (self._lambda_stack()).transpose(),
shape=(self.shape[1], self.shape[0]), shape=self.shape,
root_obj=self._root_obj) root_obj=self._root_obj)
return new_op return new_op
...@@ -432,6 +432,20 @@ class LazyLinearOp: ...@@ -432,6 +432,20 @@ class LazyLinearOp:
root_obj=self._root_obj) root_obj=self._root_obj)
return new_op return new_op
@property
def real(self):
"""
Returns the LazyLinearOp for real.
"""
self._checkattr('real')
new_op = self.__class__(init_lambda=lambda:
(self._lambda_stack()).real,
shape=self.shape,
root_obj=self._root_obj)
return new_op
@staticmethod @staticmethod
def isLazyLinearOp(obj): def isLazyLinearOp(obj):
""" """
......
...@@ -173,5 +173,11 @@ class TestLazyLinearOpFaust(unittest.TestCase): ...@@ -173,5 +173,11 @@ class TestLazyLinearOpFaust(unittest.TestCase):
lsliceA = self.lopA[3:n1, 3:n2] lsliceA = self.lopA[3:n1, 3:n2]
self.assertAlmostEqual(LA.norm(lslice.toarray()-lsliceA), 0) self.assertAlmostEqual(LA.norm(lslice.toarray()-lsliceA), 0)
def test_real(self):
cF = pf.rand(10, 15, field='complex')
lcF = LazyLinearOp.create(cF)
lcF = lcF.real
self.assertAlmostEqual(LA.norm(lcF.toarray()-cF.real.toarray()), 0)
if '__main__' == __name__: if '__main__' == __name__:
unittest.main() unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment