matrix_determinant

compas.geometry.matrix_determinant(M, check=True)[source]

Calculates the determinant of a square matrix M.

Parameters
  • M (list of list of float) – A square matrix of any dimension.

  • check (bool) – If True, checks if matrix is squared. Default is True.

Raises

ValueError – If the matrix is not square.

Returns

float – The determinant.

Examples

>>> M = identity_matrix(4)
>>> matrix_determinant(M)
1.0