def softmax(mat, target = None):
    """
    Apply cos to each element of the matrix mat.
    """

    if target:
      err_code = _cudamat.softmax(mat.p_mat, target.p_mat)
    else:
      err_code = _cudamat.softmax_overwrite(mat.p_mat)
      target = mat
    if err_code:
        raise generate_exception(err_code)
    return target

    Apply cos to each element of the matrix mat.
    
cudamat/cudamat.py