def copy_to_out(result, out):
    """A helper function, that copies a computation result into an array, that
    is passed for returning a value through call by reference.
    This is used in the terms, if they use a :mod:`numpy` function, that does not have
    a ``out`` parameter.

    :param result: the computation result
    :param out: None or an :func:`numpy.array`, into which the result shall be copied
    :returns: ``out``, if the result has been copied, ``result`` otherwise
    """
    if out is None:
        return result
    else:
        out[:] = result
        return out
