diag function
Matrix
diag(
- Matrix input
Implementation
Matrix diag(Matrix input) {
int min = input.rowsNum;
int max = input.columnsNum;
if (min > max) {
min = input.columnsNum;
max = input.rowsNum;
}
List<double> output = [];
for (int i = 0; i < min; i++) {
output.add(input[i][i]);
}
return Matrix.fromList([output]);
}