fix(linalg): validate distance input lengths (#8594)