MCPcopy Create free account
hub / github.com/numpy/numpy / hermecompanion

Function hermecompanion

numpy/polynomial/hermite_e.py:1399–1442  ·  view source on GitHub ↗

Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is an HermiteE basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guarantee

(c)

Source from the content-addressed store, hash-verified

1397
1398
1399def hermecompanion(c):
1400 """
1401 Return the scaled companion matrix of c.
1402
1403 The basis polynomials are scaled so that the companion matrix is
1404 symmetric when `c` is an HermiteE basis polynomial. This provides
1405 better eigenvalue estimates than the unscaled case and for basis
1406 polynomials the eigenvalues are guaranteed to be real if
1407 `numpy.linalg.eigvalsh` is used to obtain them.
1408
1409 Parameters
1410 ----------
1411 c : array_like
1412 1-D array of HermiteE series coefficients ordered from low to high
1413 degree.
1414
1415 Returns
1416 -------
1417 mat : ndarray
1418 Scaled companion matrix of dimensions (deg, deg).
1419
1420 Notes
1421 -----
1422
1423 .. versionadded:: 1.7.0
1424
1425 """
1426 # c is a trimmed copy
1427 [c] = pu.as_series([c])
1428 if len(c) < 2:
1429 raise ValueError('Series must have maximum degree of at least 1.')
1430 if len(c) == 2:
1431 return np.array([[-c[0]/c[1]]])
1432
1433 n = len(c) - 1
1434 mat = np.zeros((n, n), dtype=c.dtype)
1435 scl = np.hstack((1., 1./np.sqrt(np.arange(n - 1, 0, -1))))
1436 scl = np.multiply.accumulate(scl)[::-1]
1437 top = mat.reshape(-1)[1::n+1]
1438 bot = mat.reshape(-1)[n::n+1]
1439 top[...] = np.sqrt(np.arange(1, n))
1440 bot[...] = top
1441 mat[:, -1] -= scl*c[:-1]/c[-1]
1442 return mat
1443
1444
1445def hermeroots(c):

Callers 2

hermerootsFunction · 0.85
hermegaussFunction · 0.85

Calls 2

accumulateMethod · 0.80
reshapeMethod · 0.80

Tested by

no test coverage detected