<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def matrix(mat):
 """Convert a ROOT TMatrix into a NumPy matrix. Parameters mat : ROOT TMatrixT A ROOT TMatrixD or TMatrixF Returns ------- mat : numpy.matrix A NumPy matrix Examples -------- matrix([[ 0., 0., 0., 0.], [ 0., 0., 2., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.]]) """

    import ROOT
    if isinstance(mat, (ROOT.TMatrixD, ROOT.TMatrixDSym)):
        return _librootnumpy.matrix_d(ROOT.AsCObject(mat))
    elif isinstance(mat, (ROOT.TMatrixF, ROOT.TMatrixFSym)):
        return _librootnumpy.matrix_f(ROOT.AsCObject(mat))
    raise TypeError(
        "unable to convert object of type {0} "
        "into a numpy matrix".format(type(mat)))