'Mult val to the diagonal of self. If a target
is provided, it is used to store the result instead of self.'

def mult_diagonal(self, val, target=None):

    if (not target):
        target = self
    assert (self.shape[0] == self.shape[1]), 'self    must    be    a    square    matrix'
    if isinstance(val, EigenMatrix):
        err_code = _eigenmat.mult_diagonal(self.p_mat, val.p_mat, target.p_mat)
    elif isinstance(val, (int, float)):
        err_code = _eigenmat.mult_diagonal_scalar(self.p_mat, ct.c_float(val), target.p_mat)
    else:
        raise ValueError, 'Value    must    be    of    type    EigenMatrix,    int,    or    float.'
    if err_code:
        raise generate_exception(err_code)
    return target
