Not sure if it isn't better to return an array ref. That would allow us to use $matrix->size->[0] and $matrix->size->[1].
Or then, use wantarray. Let me know your thoughts and I'll adapt.