This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / linalg / _special_matrices / fiedler

function

scipy.linalg._special_matrices:fiedler

source: build-install/usr/lib/python3.14/site-packages/scipy/linalg/_special_matrices.py:939

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

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
✓
array([[ 0,  3, 11, 44, 76],
       [ 3,  0,  8, 41, 73],
       [11,  8,  0, 33, 65],
       [44, 41, 33,  0, 32],
       [76, 73, 65, 32,  0]])
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])
✗
np.int64(15409152)

See also

circulant
toeplitz

Aliases

  • scipy.linalg.fiedler

Referenced by