'Add a multiple of the sums of the matrix mat along the given dimension
to self.'

def add_sums(self, mat, axis, mult=1.0):

    m = _cudamat.get_leading_dimension(mat.p_mat)
    n = _cudamat.get_nonleading_dimension(mat.p_mat)
    if (axis == 0):
        left = CUDAMatrix.ones.slice(0, m)
        left.set_trans(True)
        right = mat
    elif (axis == 1):
        left = mat
        right = CUDAMatrix.ones.slice(0, n)
    err_code = _cudamat.dot(left.p_mat, right.p_mat, self.p_mat, ct.c_float(1.0), ct.c_float(mult))
    if err_code:
        raise generate_exception(err_code)
    return self
