[PyX-checkins] pyx/pyx helper.py,1.17,1.18 From: Michael Schindler - 2005-09-06 21:05:08 ```Update of /cvsroot/pyx/pyx/pyx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9983/pyx Modified Files: helper.py Log Message: stabilize root-checking a bit in realpolyroots Index: helper.py =================================================================== RCS file: /cvsroot/pyx/pyx/pyx/helper.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** helper.py 5 Sep 2005 14:04:05 -0000 1.17 --- helper.py 6 Sep 2005 21:05:00 -0000 1.18 *************** *** 51,54 **** --- 51,58 ---- roots = realpolyroots(coeffs[:-1], epsilon=epsilon) else: + # divide the coefficients by the maximal order + # this is to be done in the matrix, anyhow and + # makes checking more stable + coeffs = [coeff/coeffs[-1] for coeff in coeffs] N = len(coeffs) - 1 *************** *** 58,62 **** mat[i+1][i] = 1 for i in range(N): ! mat[0][i] = -coeffs[N-1-i] / coeffs[N] # find the eigenvalues of the matrix (== the roots of the polynomial) roots = [complex(root) for root in LinearAlgebra.eigenvalues(mat)] --- 62,66 ---- mat[i+1][i] = 1 for i in range(N): ! mat[0][i] = -coeffs[N-1-i] # find the eigenvalues of the matrix (== the roots of the polynomial) roots = [complex(root) for root in LinearAlgebra.eigenvalues(mat)] ```
 [PyX-checkins] pyx/pyx helper.py,1.17,1.18 From: Michael Schindler - 2005-09-06 21:05:08 ```Update of /cvsroot/pyx/pyx/pyx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9983/pyx Modified Files: helper.py Log Message: stabilize root-checking a bit in realpolyroots Index: helper.py =================================================================== RCS file: /cvsroot/pyx/pyx/pyx/helper.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** helper.py 5 Sep 2005 14:04:05 -0000 1.17 --- helper.py 6 Sep 2005 21:05:00 -0000 1.18 *************** *** 51,54 **** --- 51,58 ---- roots = realpolyroots(coeffs[:-1], epsilon=epsilon) else: + # divide the coefficients by the maximal order + # this is to be done in the matrix, anyhow and + # makes checking more stable + coeffs = [coeff/coeffs[-1] for coeff in coeffs] N = len(coeffs) - 1 *************** *** 58,62 **** mat[i+1][i] = 1 for i in range(N): ! mat[0][i] = -coeffs[N-1-i] / coeffs[N] # find the eigenvalues of the matrix (== the roots of the polynomial) roots = [complex(root) for root in LinearAlgebra.eigenvalues(mat)] --- 62,66 ---- mat[i+1][i] = 1 for i in range(N): ! mat[0][i] = -coeffs[N-1-i] # find the eigenvalues of the matrix (== the roots of the polynomial) roots = [complex(root) for root in LinearAlgebra.eigenvalues(mat)] ```