def test_eigen_circular_ensemble_02(self):
     mseeds = [2963416, 235124, 786134]
     ce = Circular()
     e_cue = ce.eigen_circular_ensemble(seeds=mseeds,
                                        N=5,
                                        nchunks=3,
                                        ensemble='CUE',
                                        parallel=True)
     e_coe = ce.eigen_circular_ensemble(seeds=mseeds,
                                        N=5,
                                        nchunks=3,
                                        ensemble='COE',
                                        parallel=True)
     e_cse = ce.eigen_circular_ensemble(seeds=mseeds,
                                        N=5,
                                        nchunks=3,
                                        ensemble='CSE',
                                        parallel=True)
     e_cse2 = ce.eigen_circular_ensemble(seeds=mseeds,
                                         N=5,
                                         nchunks=3,
                                         ensemble='CSE',
                                         parallel=True,
                                         adir="upper")
     n_cue = np.imag(e_cue['c_eigen']).sum()
     n_coe = np.imag(e_coe['c_eigen']).sum()
     n_cse = np.imag(e_cse['c_eigen']).sum()
     n_cse2 = np.imag(e_cse2['c_eigen']).sum()
     self.assertTrue(n_cue - 62.284496117511054 < self.epsilon)
     self.assertTrue(n_coe + 21.810798433338746 < self.epsilon)
     self.assertTrue(np.abs(n_cse) < self.epsilon)
     self.assertTrue(np.abs(n_cse2) < self.epsilon)
Exemple #2
0
 def test_spectral_density_01(self):
     ce          = Circular()
     mseed       = [123,125,124]       
     Ns          = [5, 10, 15]
     cSize       = 2
     nChunks     = 3
     eigen_data5 = ce.eigen_circular_ensemble(
                                              Ns[0], 
                                              cSize=cSize, 
                                              nchunks=nChunks, 
                                              seeds=mseed, 
                                              parallel=False
                                             )
     eigen_data10 = ce.eigen_circular_ensemble(
                                               Ns[1], 
                                               cSize=cSize, 
                                               nchunks=nChunks, 
                                               seeds=mseed, 
                                               parallel=False
                                              )
     eigen_data15 = ce.eigen_circular_ensemble(
                                               Ns[2], 
                                               cSize=cSize, 
                                               nchunks=nChunks, 
                                               seeds=mseed, 
                                               parallel=False
                                              )
     ensemble_size = cSize*nChunks 
     eigen_data    = {
                      "N5":eigen_data5, 
                      "N10":eigen_data10,
                      "N15":eigen_data15
                     }
     ergo = Ergodicity()
     Dse  = ergo.approach_se(
                             Ns=Ns,
                             ensemble_size=ensemble_size,
                             eigen_data=eigen_data
                            )
     self.assertTrue(len(Dse) == 2)
     d0 = -12.287133235052062 
     d1 = -8.3998021593200445
     self.assertTrue(Dse[0]+d0 < self.epsilon)
     self.assertTrue(Dse[1]+d1 < self.epsilon)
 def test_eigen_circular_ensemble_02(self):
     mseeds  = [2963416, 235124, 786134]
     ce      = Circular()
     e_cue   = ce.eigen_circular_ensemble(
                                          seeds=mseeds,
                                          N=5,
                                          nchunks=3,
                                          ensemble='CUE', 
                                          parallel=True
                                         )  
     e_coe   = ce.eigen_circular_ensemble(
                                          seeds=mseeds, 
                                          N=5,
                                          nchunks=3,
                                          ensemble='COE', 
                                          parallel=True
                                         )    
     e_cse   = ce.eigen_circular_ensemble(
                                          seeds=mseeds, 
                                          N=5,
                                          nchunks=3,
                                          ensemble='CSE', 
                                          parallel=True
                                         )
     e_cse2  = ce.eigen_circular_ensemble(
                                          seeds=mseeds, 
                                          N=5,
                                          nchunks=3,
                                          ensemble='CSE', 
                                          parallel=True,
                                          adir="upper"
                                         )
     n_cue   = np.imag(e_cue['c_eigen']).sum()
     n_coe   = np.imag(e_coe['c_eigen']).sum()
     n_cse   = np.imag(e_cse['c_eigen']).sum()
     n_cse2  = np.imag(e_cse2['c_eigen']).sum()
     self.assertTrue(n_cue-234.6608021786007 < self.epsilon)
     self.assertTrue(n_coe+61.25284251132706 < self.epsilon)
     self.assertTrue(np.abs(n_cse)  < self.epsilon) 
     self.assertTrue(np.abs(n_cse2) < self.epsilon)
 def test_test_thirumalai_mountain_01(self):
     ce = Circular()
     mseed = 2963416
     # 5, 10x10 matrices from CUE
     N = 10
     cSize = 2
     nchunks = 5
     ensemble_size = cSize * nchunks
     eseeds = [978712, 34687, 43124, 67831, 1234]
     e_cue = ce.eigen_circular_ensemble(N=N,
                                        ensemble='CUE',
                                        seeds=eseeds,
                                        cSize=cSize,
                                        nchunks=nchunks)
     c_eigen_ensemble = e_cue['c_eigen']
     ergo = Ergodicity()
     tm = ergo.thirumalai_mountain(c_eigen_ensemble, ensemble_size, N)
     self.assertTrue(tm.shape == (31, ))
     self.assertTrue(tm[6:11].sum() - 0.104 < self.epsilon)
Exemple #5
0
import os
import pickle
from bristol.ensembles import Circular
ce = Circular()
# seed for 4 cpu cores (or chunks if not parallel)
seed_v = [997123, 1091645, 1352, 32718]
data_cue = {}
data_coe = {}
data_cse = {}
range_n = [64, 128, 256, 512, 768, 1024]
for N in range_n:
    print("cue  N=", N)
    tic()
    data_cue['N' + str(N)] = ce.eigen_circular_ensemble(N,
                                                        cSize=10,
                                                        nchunks=4,
                                                        seeds=seed_v,
                                                        ensemble='CUE')
    toc()
    print("coe  N=", N)
    tic()
    data_coe['N' + str(N)] = ce.eigen_circular_ensemble(N,
                                                        cSize=10,
                                                        nchunks=4,
                                                        seeds=seed_v,
                                                        ensemble='COE')
    toc()
    print("cse  N=", N)
    tic()
    data_cse['N' + str(N)] = ce.eigen_circular_ensemble(N,
                                                        cSize=10,
Exemple #6
0
    def spectra_ce(
        range_N=[64, 128],
        cSize=5,
        nchunks=2,
        seeds=[997123, 1091645],
        ensemble='all',
        parallel=False,
    ):
        """

          Generate eigenvalues of matrices of different size
          drawn from a circular ensemble.


           Author: M.Suzen

           params:
           range_N   set of Size of the rectangular matrix, NxN.
           cSize     Number of random matrices to generate in a chunk.
           nchunks   number of cSize chunks.
           ensemble  One of the circular ensemble 
                     'CUE', 'COE', 'CSE', defaults to 'all'
           seeds     List of integer to use in random seed 
                     in every chunk.
           parallel  Run in multicore, number of cores as nchunks, 
                     defaults to False

          output:
          Dictionary of dictionaries. 
          * Highest level keys for ensemble `CUE`, `COE` or `CSE`.
          * Then, dictionary with keys describing size, such as 'N16. 
          * Values will be an another dictionary
            with keys `local_seed` integers for seeds 
            used in the chunk, `c_eigen` 
            numpy array of eigenvalues, `N` matrix size, 
            `M` number of matrices used to generate `c_eigen`. Note
            that `c_eigen` will be length NxM.
 
            Example:

          """
        ce = Circular()
        data_ce = {'CUE': {}, 'COE': {}, 'CSE': {}}
        for N in range_N:
            if (ensemble in ['CUE', 'all']):
                e_dict = ce.eigen_circular_ensemble(N=N,
                                                    cSize=cSize,
                                                    nchunks=nchunks,
                                                    ensemble='CUE',
                                                    seeds=seeds,
                                                    parallel=parallel)
                data_ce['CUE']['N' + str(N)] = e_dict
            if (ensemble in ['COE', 'all']):
                e_dict = ce.eigen_circular_ensemble(N=N,
                                                    cSize=cSize,
                                                    nchunks=nchunks,
                                                    ensemble='COE',
                                                    seeds=seeds,
                                                    parallel=parallel)
                data_ce['COE']['N' + str(N)] = e_dict
            if (ensemble in ['CSE', 'all']):
                e_dict = ce.eigen_circular_ensemble(N=N,
                                                    cSize=cSize,
                                                    nchunks=nchunks,
                                                    ensemble='CSE',
                                                    seeds=seeds,
                                                    parallel=parallel)
                data_ce['COE']['N' + str(N)] = e_dict
        return data_ce