Remove the quad code from matrix

Also add more documentation on the matrices functions
Add more documentation