<commit_before>import numpy as np
import scipy.linalg

'''
Extension to scipy.linalg module developed for PBC branch.
'''

method = 'arnoldi'
#method = 'davidson'

VERBOSE = True

def eigs(matvec,size,nroots,Adiag=None):
    '''Davidson diagonalization method to solve A c = E c
    when A is not Hermitian.
    '''

    # We don't pass args
    def matvec_args(vec, args=None):
        return matvec(vec)

    nroots = min(nroots,size)

    if method == 'arnoldi':
        # Currently not used:
        x = np.ones((size,1))
        P = np.ones((size,1))
        arnold = Arnoldi(matvec_args, x, P, nroots=nroots)
        return arnold.solve()
    else:
        david = Davidson()
        david.ndim = size
        david.neig = nroots
        david.diag = matvec(np.ones(size))
        david.matvec = matvec

        return david.solve_iter()


class Arnoldi(object):
    def __init__(self,matr_multiply,xStart,inPreCon,nroots=1,tol=1e-8):
        self.matrMultiply = matr_multiply
        self.size = xStart.shape[0]
        self.nEigen = min(nroots, self.size)
        self.maxM = min(30, self.size)
        self.maxOuterLoop = 10<commit_msg>Turn off verbose in davidson, and lower tol<commit_after>import numpy as np
import scipy.linalg

'''
Extension to scipy.linalg module developed for PBC branch.
'''

method = 'arnoldi'
#method = 'davidson'

VERBOSE = False 

def eigs(matvec,size,nroots,Adiag=None):
    '''Davidson diagonalization method to solve A c = E c
    when A is not Hermitian.
    '''

    # We don't pass args
    def matvec_args(vec, args=None):
        return matvec(vec)

    nroots = min(nroots,size)

    if method == 'arnoldi':
        # Currently not used:
        x = np.ones((size,1))
        P = np.ones((size,1))
        arnold = Arnoldi(matvec_args, x, P, nroots=nroots)
        return arnold.solve()
    else:
        david = Davidson()
        david.ndim = size
        david.neig = nroots
        david.diag = matvec(np.ones(size))
        david.matvec = matvec

        return david.solve_iter()


class Arnoldi(object):
    def __init__(self,matr_multiply,xStart,inPreCon,nroots=1,tol=1e-10):
        self.matrMultiply = matr_multiply
        self.size = xStart.shape[0]
        self.nEigen = min(nroots, self.size)
        self.maxM = min(30, self.size)
        self.maxOuterLoop = 10
{'fraction_non_alphanumeric': 0.11579853637537667, 'fraction_numerical': 0.009040034438226431, 'mean_word_length': 2.5808936825885977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5866933', 'n_tokens_mistral': 873, 'n_tokens_neox': 825, 'n_words': 192}