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

bundles / numpy latest / numpy / linalg / _linalg / _multi_dot_matrix_chain_order

function

numpy.linalg._linalg:_multi_dot_matrix_chain_order

source: build-install/usr/lib/python3.14/site-packages/numpy/linalg/_linalg.py :3005

Signature

def   _multi_dot_matrix_chain_order ( arrays return_costs = False )

Summary

Return a np.array that encodes the optimal order of multiplications.

Extended Summary

The optimal order array is then used by _multi_dot() to do the multiplication.

Also return the cost matrix if return_costs is True

The implementation CLOSELY follows Cormen, "Introduction to Algorithms", Chapter 15.2, p. 370-378. Note that Cormen uses 1-based indices.

cost[i, j] = min([

cost[prefix] + cost[suffix] + cost_mult(prefix, suffix) for k in range(i, j)])

Aliases

  • numpy.linalg._linalg._multi_dot_matrix_chain_order