Implement a `is_a()` method for matrices

* Use static_cast instead of dynamic_cast