haven't you tried just `<< mat1.size()` ?