Merge pull request #431 from fredrik-johansson/revert-425-leftScalarMatrixMult280

Revert "Fixed scalar-matrix multiplication in iv module"
This commit is contained in:
Fredrik Johansson
2019-02-03 12:03:18 +01:00
committed by GitHub
2 changed files with 8 additions and 27 deletions
+8 -21
View File
@@ -252,41 +252,28 @@ def _binary_op(f_real, f_complex):
return g_complex(ctx, sval, tval)
def lop_real(s, t):
ctx = s.ctx
if not isinstance(t, ctx._types):
try:
t = ctx.convert(t)
except (ValueError, TypeError):
return NotImplemented
if not isinstance(t, ctx._types): t = ctx.convert(t)
if hasattr(t, "_mpi_"): return g_real(ctx, s._mpi_, t._mpi_)
if hasattr(t, "_mpci_"):
return g_complex(ctx, (s._mpi_, mpi_zero), t._mpci_)
if hasattr(t, "_mpci_"): return g_complex(ctx, (s._mpi_, mpi_zero), t._mpci_)
return NotImplemented
def rop_real(s, t):
ctx = s.ctx
if not isinstance(t, ctx._types):
try:
t = ctx.convert(t)
except (ValueError, TypeError):
return NotImplemented
if not isinstance(t, ctx._types): t = ctx.convert(t)
if hasattr(t, "_mpi_"): return g_real(ctx, t._mpi_, s._mpi_)
if hasattr(t, "_mpci_"):
return g_complex(ctx, t._mpci_, (s._mpi_, mpi_zero))
if hasattr(t, "_mpci_"): return g_complex(ctx, t._mpci_, (s._mpi_, mpi_zero))
return NotImplemented
def lop_complex(s, t):
ctx = s.ctx
if not isinstance(t, ctx._types):
if not isinstance(t, s.ctx._types):
try:
t = ctx.convert(t)
t = s.ctx.convert(t)
except (ValueError, TypeError):
return NotImplemented
return g_complex(ctx, s._mpci_, t._mpci_)
def rop_complex(s, t):
ctx = s.ctx
if not isinstance(t, ctx._types):
try:
t = ctx.convert(t)
except (ValueError, TypeError):
return NotImplemented
if not isinstance(t, s.ctx._types):
t = s.ctx.convert(t)
return g_complex(ctx, t._mpci_, s._mpci_)
return lop_real, rop_real, lop_complex, rop_complex
-6
View File
@@ -178,9 +178,3 @@ def test_matrix_numpy():
l = [[1, 2], [3, 4], [5, 6]]
a = numpy.array(l)
assert matrix(l) == matrix(a)
def test_matrix_iv():
A = iv.matrix([[1, 2], [3, 4]])
two = iv.mpf(2)
assert A*two == two*A
assert two*A == iv.matrix([[iv.mpf(2), iv.mpf(4)], [iv.mpf(6), iv.mpf(8)]])