is_trimatu() and is_trimatl() fails for 2x2 matrices
The is_trimatu()
and is_trimatl()
member functions of arma::Mat<T>
fail for 2x2 matrices.
A quick test program to demonstrate this:
#include <armadillo>
#include <cassert>
int main() {
assert( arma::eye(3,3).is_trimatu() ); // OK
assert( arma::eye(2,2).is_trimatu() ); // Fails
assert( arma::eye(3,3).is_trimatl() ); // OK
assert( arma::eye(2,2).is_trimatl() ); // Fails
}
This will print test_arma.cpp:6: int main(): Assertion 'arma::eye(2,2).is_trimatu()' failed.
If I comment out line 6 I get test_arma.cpp:9: int main(): Assertion 'arma::eye(2,2).is_trimatl()' failed.
I think the issue is in https://gitlab.com/conradsnicta/armadillo-code/-/blob/10.7.x/include/armadillo_bits/trimat_helper.hpp#L49 and https://gitlab.com/conradsnicta/armadillo-code/-/blob/10.7.x/include/armadillo_bits/trimat_helper.hpp#L91 where the lower/upper 3 corner elements are checked for non-zeroness before looping through all the elements. For 2x2 matrices this will check the elements on the main diagonal as well, which tend to be non-zero.
Edit: Fix formatting