isNilpotentMatrix method
Checks if the matrix is a nilpotent matrix.
Example:
Matrix G = Matrix([
[0, 1, 2],
[-1, 0, 1],
[-2, -1, 0]
]);
print(G.isNilpotentMatrix()); // Output: true
Implementation
bool isNilpotentMatrix({int maxIterations = 100}) {
Matrix product = copy();
for (int i = 1; i < maxIterations; i++) {
product = product * this;
if (product.isZeroMatrix()) {
return true;
}
}
return false;
}