fixed a bug with certain singular derivatives.
fixed a bug with empty matrix multiplies
added a cast.
handling a case where power matrix is a single row.
Basic support for trigonometric poly.
another helper fun. for trig. poly