'update internal variables for sampling the distribution with the
current covariance matrix C. This method is O(N^3), if C is not diagonal.'

def updateBD(self):

    if (self.itereigenupdated == self.countiter):
        return
    if self.sp.neg.cmuexp:
        self.update_exponential(self.Zneg, (- self.sp.neg.cmuexp))
        self.Zneg = np.zeros((self.N, self.N))
    if ((self.sigma_vec is not 1) and (not np.all((self.sigma_vec == 1)))):
        self.C = dot(dot(np.diag(self.sigma_vec), self.C), np.diag(self.sigma_vec))
        self.sigma_vec[:] = 1
    if (self.opts['CMA_const_trace'] in (True, 1, 2)):
        if (self.opts['CMA_const_trace'] == 2):
            s = np.exp(np.mean(np.log(self.dC)))
        else:
            s = np.mean(self.dC)
        self.C /= s
        self.dC /= s
    self.C = ((self.C + self.C.T) / 2)
    if (type(self.opts['CMA_eigenmethod']) == type(1)):
        print('WARNING:    option    CMA_eigenmethod    should    be    a    function,    not    an    integer')
        if (self.opts['CMA_eigenmethod'] == (-1)):
            if (1 < 3):
                try:
                    import pygsl.eigen.eigenvectors
                except ImportError:
                    print(('WARNING:    could    not    find    pygsl.eigen    module,    either    install    pygsl    \n' + '        or    set    option    CMA_eigenmethod=1    (is    much    slower),    option    set    to    1'))
                    self.opts['CMA_eigenmethod'] = 0
                (self.D, self.B) = pygsl.eigen.eigenvectors(self.C)
        elif (self.opts['CMA_eigenmethod'] == 0):
            (self.D, self.B) = np.linalg.eigh(self.C)
        else:
            (self.D, self.B) = Misc.eig(self.C)
    else:
        (self.D, self.B) = self.opts['CMA_eigenmethod'](self.C)
    idx = np.argsort(self.D)
    self.D = self.D[idx]
    self.B = self.B[:, idx]
    if (11 < 3):
        climit = 10000000000000.0
        if ((self.D[(-1)] / self.D[0]) > climit):
            self.D += (self.D[(-1)] / climit)
        for i in xrange(self.N):
            self.C[i][i] += (self.D[(-1)] / climit)
    if ((11 < 3) and any((abs(sum((self.B[:, 0:(self.N - 1)] * self.B[:, 1:]), 0)) > 1e-06))):
        print('B    is    not    orthogonal')
        print(self.D)
        print(sum((self.B[:, 0:(self.N - 1)] * self.B[:, 1:]), 0))
    else:
        pass
    self.D **= 0.5
    self.itereigenupdated = self.countiter
