containsIn method
Checks if the current matrix is contained in or is a subMatrix of any matrix in matrices.
matrices: A list of matrices to check against.
Returns true if the current matrix is contained in or is a subMatrix of any matrix in matrices, otherwise false.
Example:
var matrix1 = Matrix([[1, 2], [3, 4]]);
var matrix2 = Matrix([[5, 6], [7, 8]]);
var matrix3 = Matrix([[1, 2, 3], [3, 4, 5], [5, 6, 7]]);
var targetMatrix = Matrix([[1, 2], [3, 4]]);
print(targetMatrix.containsIn([matrix1, matrix2])); // Output: true
print(targetMatrix.containsIn([matrix2, matrix3])); // Output: false
Implementation
bool containsIn(List<Matrix> matrices) {
return matrices.any((matrix) => this == matrix || isSubMatrix(matrix));
}