private static function determineMatrixType(array $A, $vandermonde_n) : string
{
$m = count($A);
// 1-dimensional array is how we create diagonal and vandermonde matrices
$one_dimensional = count(array_filter($A, 'is_array')) === 0;
if ($one_dimensional) {
if (is_null($vandermonde_n)) {
return 'diagonal';
}
if ($m === $vandermonde_n) {
return 'vandermonde_square';
}
return 'vandermonde';
}
// Square Matrices have the same number of rows (m) and columns (n)
$n = count($A[0]);
if ($m === $n) {
if (is_callable($A[0][0])) {
return 'function_square';
}
return 'square';
}
// Non square Matrices
// First check to make sure it isn't something strange
if (is_array($A[0][0])) {
return 'unknown';
}
// Then check remaining matrix types
if (is_callable($A[0][0])) {
return 'function';
}
return 'matrix';
}