Fix #149

Three things are changed here:

rank is replaced with ndim (numpy)

tril/diag/triu now return an array rather than a matrix, so asmatrix is
used to force matrix for consistency with other tests.

whitespace police