import 'dart:math';
double CalculateNormal(List<List<int>>matrix) {
var normal = 0;
for (var i = 0; i < matrix.length; i++) {
for (var j = 0; j < matrix.length; j++) {
normal += matrix[i][j] * matrix[i][j];
}
}
return sqrt(normal);
}
int CalculateTrace(List<List<int>>matrix) {
var trace = 0;
for (var i = 0; i < matrix.length; i++) {
trace += matrix[i][i];
}
return trace;
}
void main() {
List<List<int>> matrix = [[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2],
[3, 3, 3, 3, 3],
[4, 4, 4, 4, 4],
[5, 5, 5, 5, 5]];
print(CalculateTrace(matrix));
print(CalculateNormal(matrix));
}
/*
run:
15
16.583123951777
*/