## "Fossies" - the Fresh Open Source Software Archive

### Source code changes of the file "mpmath/matrices/linalg.py" betweenmpmath-1.0.0.tar.gz and mpmath-1.1.0.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

linalg.py  (mpmath-1.0.0):linalg.py  (mpmath-1.1.0)
skipping to change at line 341 skipping to change at line 341
""" """
if not isinstance(A, ctx.matrix): if not isinstance(A, ctx.matrix):
raise TypeError("A should be a type of ctx.matrix") raise TypeError("A should be a type of ctx.matrix")
m = A.rows m = A.rows
n = A.cols n = A.cols
if m < n - 1: if m < n - 1:
raise RuntimeError("Columns should not be less than rows") raise RuntimeError("Columns should not be less than rows")
# calculate Householder matrix # calculate Householder matrix
p = [] p = []
for j in xrange(0, n - 1): for j in xrange(0, n - 1):
s = ctx.fsum((A[i,j])**2 for i in xrange(j, m)) s = ctx.fsum(abs(A[i,j])**2 for i in xrange(j, m))
if not abs(s) > ctx.eps: if not abs(s) > ctx.eps:
raise ValueError('matrix is numerically singular') raise ValueError('matrix is numerically singular')
p.append(-ctx.sign() * ctx.sqrt(s)) p.append(-ctx.sign(ctx.re(A[j,j])) * ctx.sqrt(s))
kappa = ctx.one / (s - p[j] * A[j,j]) kappa = ctx.one / (s - p[j] * A[j,j])
A[j,j] -= p[j] A[j,j] -= p[j]
for k in xrange(j+1, n): for k in xrange(j+1, n):
y = ctx.fsum(kappa y = ctx.fsum(ctx.conj(A[i,j]) * A[i,k] for i in xrange(j, m)) * kappa
for i in xrange(j, m): for i in xrange(j, m):
A[i,k] -= A[i,j] * y A[i,k] -= A[i,j] * y
# solve Rx = c1 # solve Rx = c1
x = [A[i,n - 1] for i in xrange(n - 1)] x = [A[i,n - 1] for i in xrange(n - 1)]
for i in xrange(n - 2, -1, -1): for i in xrange(n - 2, -1, -1):
x[i] -= ctx.fsum(A[i,j] * x[j] for j in xrange(i + 1, n - 1)) x[i] -= ctx.fsum(A[i,j] * x[j] for j in xrange(i + 1, n - 1))
x[i] /= p[i] x[i] /= p[i]
# calculate residual # calculate residual
if not m == n - 1: if not m == n - 1:
r = [A[m-1-i, n-1] for i in xrange(m - n + 1)] r = [A[m-1-i, n-1] for i in xrange(m - n + 1)]
End of changes. 3 change blocks.
3 lines changed or deleted 3 lines changed or added