///|
fn matrix_size(n : Int, m : Array[Complex]) -> Unit raise {
  if n < 1 || n > 32 || m.length() != n * n {
    raise Failure("expected square row-major matrix with 1..32 ports")
  }
  for z in m {
    ignore(checked(z))
  }
}

///|
fn identity(n : Int) -> Array[Complex] {
  Array::makei(n * n, i => complex(if i / n == i % n { 1.0 } else { 0.0 }))
}

///|
fn product(
  n : Int,
  a : Array[Complex],
  b : Array[Complex],
) -> Array[Complex] raise {
  Array::makei(n * n, ij => {
    let i = ij / n
    let j = ij % n
    let mut sum = complex(0.0)
    for k in 0.. Array[Complex] raise {
  matrix_size(n, matrix)
  let a = matrix.copy()
  let b = identity(n)
  let scales = Array::makei(n, r => {
    let mut scale = 0.0
    for c in 0.. score {
        score = ratio
        pivot = row
      }
    }
    if score <= 1.0e-12 {
      raise Failure("singular or numerically unsafe matrix")
    }
    if pivot != col {
      for k in 0.. Array[Complex] raise {
  matrix_size(n, a)
  matrix_size(n, b)
  product(n, a, b)
}