def __iter__(self):
        dim = self.wrt.shape[0]
        I = scipy.eye(dim)

        # Square root of covariance matrix.
        A = scipy.eye(dim)
        center = self.wrt.copy()
        n_evals = 0
        best_wrt = None
        best_x = float('-inf')
        for i, (args, kwargs) in enumerate(self.args):
            # Draw samples, evaluate and update best solution if a better one
            # was found.
            samples = scipy.random.standard_normal((self.batch_size, dim))
            samples = scipy.dot(samples, A) + center
            fitnesses = [self.f(samples[j], *args, **kwargs)
                         for j in range(samples.shape[0])]
            fitnesses = scipy.array(fitnesses).flatten()

            if fitnesses.max() > best_x:
                best_loss = fitnesses.max()
                self.wrt[:] = samples[fitnesses.argmax()]

            # Update center and variances.
            utilities = self.compute_utilities(fitnesses)
            center += scipy.dot(scipy.dot(utilities, samples), A)
            # TODO: vectorize this
            cov_gradient = sum([u * (scipy.outer(s, s) - I)
                                for (s, u) in zip(samples, utilities)])
            update = scipy.linalg.expm2(A * cov_gradient * self.step_rate * 0.5)
            A[:] = scipy.dot(A, update)

            yield dict(loss=-best_x, n_iter=i)
dataset/ETHPy150Open BRML/climin/climin/nes.py/Xnes.__iter__/original