<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def quattodcm(quat):
 """Convert quaternion to DCM This function will convert a quaternion to the equivalent rotation matrix, or direction cosine matrix. Parameters: quat - (4,) numpy array Array defining a quaterion where the quaternion is defined in terms of a vector and a scalar part. The vector is related to the eigen axis and equivalent in both reference frames [x y z w] Returns: -------- dcm - (3,3) numpy array Numpy rotation matrix which defines a rotation from the b to a frame """


    dcm = (quat[-1]**2-np.inner(quat[0:3], quat[0:3]))*np.eye(3,3) + 2*np.outer(quat[0:3],quat[0:3]) + 2*quat[-1]*hat_map(quat[0:3])

    return dcm