{ } Raw JSON

bundles / scipy 1.17.1 / scipy / linalg / _special_matrices / fiedler

function

scipy.linalg._special_matrices:fiedler

source: /scipy/linalg/_special_matrices.py :950

Signature

def   fiedler ( a )

Summary

Returns a symmetric Fiedler matrix

Extended Summary

Given an sequence of numbers a, Fiedler matrices have the structure F[i, j] = np.abs(a[i] - a[j]), and hence zero diagonals and nonnegative entries. A Fiedler matrix has a dominant positive eigenvalue and other eigenvalues are negative. Although not valid generally, for certain inputs, the inverse and the determinant can be derived explicitly as given in [1].

Array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details.

Parameters

a : (..., n,) array_like

Coefficient array. N-dimensional arrays are treated as a batch: each slice along the last axis is a 1-D coefficient array.

Returns

F : (..., n, n) ndarray

Fiedler matrix. For batch input, each slice of shape (n, n) along the last two dimensions of the output corresponds with a slice of shape (n,) along the last dimension of the input.

Notes

Array API Standard Support

fiedler has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ✅                   
JAX                   ✅                     ✅                   
Dask                  ✅                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

import numpy as np
from scipy.linalg import det, inv, fiedler
a = [1, 4, 12, 45, 77]
n = len(a)
A = fiedler(a)
A
The explicit formulas for determinant and inverse seem to hold only for monotonically increasing/decreasing arrays. Note the tridiagonal structure and the corners.
Ai = inv(A)
Ai[np.abs(Ai) < 1e-12] = 0.  # cleanup the numerical noise for display
Ai
det(A)
(-1)**(n-1) * 2**(n-2) * np.diff(a).prod() * (a[-1] - a[0])

See also

circulant
toeplitz

Aliases

  • scipy.linalg.fiedler

Referenced by