Refactor matrix classes and functions

Refactor Matrix classes and functions to use output arguments instead of RCP.

Major changes
===========

* `MatrixBase` is not derived from `Basic` anymore
* All the functions accepts an output argument which is used to pass back the output of operation
* Implementation of Matrix functionalities are divided across two files, `sparse_matrix.cpp` and `dense_matrix.cpp`