<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def as_quat_array(a):
 """View a float array as an array of quaternions The input array must have a final dimension whose size is divisible by four (or better yet *is* 4), because successive indices in that last dimension will be considered successive components of the output quaternion. This function is usually fast (of order 1 microsecond) because no data is copied; the returned quantity is just a "view" of the original. However, if the input array is not C-contiguous (basically, as you increment the index into the last dimension of the array, you just move to the neighboring float in memory), the data will need to be copied which may be quite slow. Therefore, you should try to ensure that the input array is in that order. Slices and transpositions will frequently break that rule. We will not convert back from a two-spinor array because there is no unique convention for them, so I don't want to mess with that. Also, we want to discourage users from the slow, memory-copying process of swapping columns required for useful definitions of the two-spinors. """

    a = np.asarray(a, dtype=np.double)

    # fast path
    if a.shape == (4,):
        return quaternion(a[0], a[1], a[2], a[3])

    # view only works if the last axis is C-contiguous
    if not a.flags['C_CONTIGUOUS'] or a.strides[-1] != a.itemsize:
        a = a.copy(order='C')
    try:
        av = a.view(np.quaternion)
    except ValueError as e:
        message = (str(e) + '\n            '
                   + 'Failed to view input data as a series of quaternions.  '
                   + 'Please ensure that the last dimension has size divisible by 4.\n            '
                   + 'Input data has shape {0} and dtype {1}.'.format(a.shape, a.dtype))
        raise ValueError(message)

    # special case: don't create an axis for a single quaternion, to
    # match the output of `as_float_array`
    if av.shape[-1] == 1:
        av = av.reshape(a.shape[:-1])

    return av