def cast_to_dtype(array, dtype):
    """
    Cast the given numpy array to the given dtype and returns the result.
    If the input array dtype is already equal to the given dtype, the input array is returned.

    :param array: a numpy array
    :param dtype: a numpy dtype
    :return: a numpy array
    """
    if array.dtype != dtype:
        array = array.astype(dtype)
    return array
