rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return threeAddrProgram, signature, tempsig, constants
return threeAddrProgram, signature, tempsig, constants, input_names
def registerMaker(node, temporary=False): reg = Register(node, temporary=temporary) reg.n = reg_num[0] reg_num[0] -= 1 return reg
ec602a115f87007a485e1c481086007213ceb93d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ec602a115f87007a485e1c481086007213ceb93d/compiler.py
threeAddrProgram, inputsig, tempsig, constants = \
threeAddrProgram, inputsig, tempsig, constants, input_names = \
def numexpr(ex, signature=(), copy_args=(), **kwargs): """Compile an expression built using E.<variable> variables to a function. ex can also be specified as a string "2*a+3*b". The order of the input variables and their types can be specified using the signature parameter, which is a list of (name, type) pairs. """ threeAddrProgram, inputsig, tempsig, constants = \ precompile(ex, signature, copy_args, **kwargs) program = compileThreeAddrForm(threeAddrProgram) return interpreter.NumExpr(inputsig, tempsig, program, constants)
ec602a115f87007a485e1c481086007213ceb93d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ec602a115f87007a485e1c481086007213ceb93d/compiler.py
return interpreter.NumExpr(inputsig, tempsig, program, constants)
return interpreter.NumExpr(inputsig, tempsig, program, constants, input_names)
def numexpr(ex, signature=(), copy_args=(), **kwargs): """Compile an expression built using E.<variable> variables to a function. ex can also be specified as a string "2*a+3*b". The order of the input variables and their types can be specified using the signature parameter, which is a list of (name, type) pairs. """ threeAddrProgram, inputsig, tempsig, constants = \ precompile(ex, signature, copy_args, **kwargs) program = compileThreeAddrForm(threeAddrProgram) return interpreter.NumExpr(inputsig, tempsig, program, constants)
ec602a115f87007a485e1c481086007213ceb93d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ec602a115f87007a485e1c481086007213ceb93d/compiler.py
r_constants = 1 + nex.n_inputs
r_constants = 1 + len(nex.signature)
def disassemble(nex): rev_opcodes = {} for op in interpreter.opcodes: rev_opcodes[interpreter.opcodes[op]] = op r_constants = 1 + nex.n_inputs r_temps = r_constants + len(nex.constants) def getArg(pc): arg = ord(nex.program[pc]) if arg == 0: return 'r0' elif arg == 255: return None elif arg < r_constants: return 'r%d[%s]' % (arg, nex.input_names[arg-1]) elif arg < r_temps: return 'c%d[%s]' % (arg, nex.constants[arg - r_constants]) else: return 't%d' % (arg,) source = [] for pc in range(0, len(nex.program), 4): op = rev_opcodes.get(ord(nex.program[pc])) dest = getArg(pc+1) arg1 = getArg(pc+2) arg2 = getArg(pc+3) source.append( (op, dest, arg1, arg2) ) return source
ec602a115f87007a485e1c481086007213ceb93d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ec602a115f87007a485e1c481086007213ceb93d/compiler.py
b = time.clock()
b = timer()
def initialize(self,reseed = 1): b = time.clock() self.test_settings(self.settings) self.gen = 0 sd = self.settings['rand_seed']; alg = self.settings['rand_alg'] if reseed: rv.initialize(seed = sd, algorithm = alg) self.settings['seed_used'] = rv.initial_seed() self._print('initializing... seed = %d' % self.settings['seed_used']) self.crossover = self.pop.model_genome.crossover # get the crossover op from the first genome self.pop.settings = self.settings #should these be shared? self.size_pop(self.settings['pop_size']) self.settings['crossover'] = string.split(str(self.crossover))[0][1:] self.settings['selector'] = string.split(str(self.pop.selector))[0][1:] self.settings['scaler'] = string.split(str(self.pop.scaler))[0][1:] self.settings['genome_type'] = string.split(str(self.pop.model_genome))[0][1:]
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
self.step_time = time.clock() - b
self.step_time = timer() - b
def initialize(self,reseed = 1): b = time.clock() self.test_settings(self.settings) self.gen = 0 sd = self.settings['rand_seed']; alg = self.settings['rand_alg'] if reseed: rv.initialize(seed = sd, algorithm = alg) self.settings['seed_used'] = rv.initial_seed() self._print('initializing... seed = %d' % self.settings['seed_used']) self.crossover = self.pop.model_genome.crossover # get the crossover op from the first genome self.pop.settings = self.settings #should these be shared? self.size_pop(self.settings['pop_size']) self.settings['crossover'] = string.split(str(self.crossover))[0][1:] self.settings['selector'] = string.split(str(self.pop.selector))[0][1:] self.settings['scaler'] = string.split(str(self.pop.scaler))[0][1:] self.settings['genome_type'] = string.split(str(self.pop.model_genome))[0][1:]
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
b = time.clock()
b = timer()
def step(self,steps=1): sz = len(self.pop) replace = int(self.settings['p_replace'] * len(self.pop)) p_crossover = self.settings['p_cross'] for st in range(steps): b = time.clock() for i in range(0,replace,2): mom,dad= self.pop.select(2) self.stats['selections'] = self.stats['selections'] + 2 if flip_coin(p_crossover): try: bro,sis = self.crossover((mom,dad)) self.stats['crossovers'] = self.stats['crossovers'] + 2 self.pop.append(bro); self.pop.append(sis) except ValueError: #crossover failed - just act as if this iteration never happened i = i - 2 #print 'crossover failure - ignoring and continuing' else: self.pop.append(mom.clone());self.pop.append(dad.clone()); if replace % 2: #we did one to many - remove the last individual del self.pop[-1] self.stats['crossovers'] = self.stats['crossovers'] - 1 e1 = time.clock(); self.stats['mutations'] = self.stats['mutations'] + self.pop[sz:].mutate()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
e1 = time.clock();
e1 = timer();
def step(self,steps=1): sz = len(self.pop) replace = int(self.settings['p_replace'] * len(self.pop)) p_crossover = self.settings['p_cross'] for st in range(steps): b = time.clock() for i in range(0,replace,2): mom,dad= self.pop.select(2) self.stats['selections'] = self.stats['selections'] + 2 if flip_coin(p_crossover): try: bro,sis = self.crossover((mom,dad)) self.stats['crossovers'] = self.stats['crossovers'] + 2 self.pop.append(bro); self.pop.append(sis) except ValueError: #crossover failed - just act as if this iteration never happened i = i - 2 #print 'crossover failure - ignoring and continuing' else: self.pop.append(mom.clone());self.pop.append(dad.clone()); if replace % 2: #we did one to many - remove the last individual del self.pop[-1] self.stats['crossovers'] = self.stats['crossovers'] - 1 e1 = time.clock(); self.stats['mutations'] = self.stats['mutations'] + self.pop[sz:].mutate()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
e2 = time.clock();
e2 = timer();
def step(self,steps=1): sz = len(self.pop) replace = int(self.settings['p_replace'] * len(self.pop)) p_crossover = self.settings['p_cross'] for st in range(steps): b = time.clock() for i in range(0,replace,2): mom,dad= self.pop.select(2) self.stats['selections'] = self.stats['selections'] + 2 if flip_coin(p_crossover): try: bro,sis = self.crossover((mom,dad)) self.stats['crossovers'] = self.stats['crossovers'] + 2 self.pop.append(bro); self.pop.append(sis) except ValueError: #crossover failed - just act as if this iteration never happened i = i - 2 #print 'crossover failure - ignoring and continuing' else: self.pop.append(mom.clone());self.pop.append(dad.clone()); if replace % 2: #we did one to many - remove the last individual del self.pop[-1] self.stats['crossovers'] = self.stats['crossovers'] - 1 e1 = time.clock(); self.stats['mutations'] = self.stats['mutations'] + self.pop[sz:].mutate()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
e3 = time.clock();
e3 = timer();
def step(self,steps=1): sz = len(self.pop) replace = int(self.settings['p_replace'] * len(self.pop)) p_crossover = self.settings['p_cross'] for st in range(steps): b = time.clock() for i in range(0,replace,2): mom,dad= self.pop.select(2) self.stats['selections'] = self.stats['selections'] + 2 if flip_coin(p_crossover): try: bro,sis = self.crossover((mom,dad)) self.stats['crossovers'] = self.stats['crossovers'] + 2 self.pop.append(bro); self.pop.append(sis) except ValueError: #crossover failed - just act as if this iteration never happened i = i - 2 #print 'crossover failure - ignoring and continuing' else: self.pop.append(mom.clone());self.pop.append(dad.clone()); if replace % 2: #we did one to many - remove the last individual del self.pop[-1] self.stats['crossovers'] = self.stats['crossovers'] - 1 e1 = time.clock(); self.stats['mutations'] = self.stats['mutations'] + self.pop[sz:].mutate()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
e = time.clock(); self.step_time = e - b
e = timer(); self.step_time = e - b
def step(self,steps=1): sz = len(self.pop) replace = int(self.settings['p_replace'] * len(self.pop)) p_crossover = self.settings['p_cross'] for st in range(steps): b = time.clock() for i in range(0,replace,2): mom,dad= self.pop.select(2) self.stats['selections'] = self.stats['selections'] + 2 if flip_coin(p_crossover): try: bro,sis = self.crossover((mom,dad)) self.stats['crossovers'] = self.stats['crossovers'] + 2 self.pop.append(bro); self.pop.append(sis) except ValueError: #crossover failed - just act as if this iteration never happened i = i - 2 #print 'crossover failure - ignoring and continuing' else: self.pop.append(mom.clone());self.pop.append(dad.clone()); if replace % 2: #we did one to many - remove the last individual del self.pop[-1] self.stats['crossovers'] = self.stats['crossovers'] - 1 e1 = time.clock(); self.stats['mutations'] = self.stats['mutations'] + self.pop[sz:].mutate()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
b = time.clock()
b = timer()
def evolve(self): b = time.clock() self.initialize() self.pre_evolve() self.p_dev = self.pop_deviation() self.iteration_output() while ( self.gen < self.settings['gens'] and self.settings['p_deviation'] < self.p_dev ): self.step() self.p_dev = self.pop_deviation() self.iteration_output() if(self.gen % self.settings['update_rate'] == 0): self.update_dbase() self.update_dbase() #enter status prior to post_evolve in dbase self.post_evolve() self.db_entry['run_time'] = time.clock() - b self.write_dbase()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
self.db_entry['run_time'] = time.clock() - b
self.db_entry['run_time'] = timer() - b
def evolve(self): b = time.clock() self.initialize() self.pre_evolve() self.p_dev = self.pop_deviation() self.iteration_output() while ( self.gen < self.settings['gens'] and self.settings['p_deviation'] < self.p_dev ): self.step() self.p_dev = self.pop_deviation() self.iteration_output() if(self.gen % self.settings['update_rate'] == 0): self.update_dbase() self.update_dbase() #enter status prior to post_evolve in dbase self.post_evolve() self.db_entry['run_time'] = time.clock() - b self.write_dbase()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
b = time.clock()
b = timer()
def initialize(self, mode = 'serial'): b = time.clock() #same as galg self.test_settings(self.settings) self.gen = 0 sd = self.settings['rand_seed']; alg = self.settings['rand_alg'] rv.initialize(seed = sd, algorithm = alg) self.settings['seed_used'] = rv.initial_seed() self._print('initializing... seed = %d' % self.settings['seed_used']) self.crossover = self.pop[0].crossover # get the crossover op from the first genome self.pop.settings = self.settings #end same as galg #set up my population to hold the best from each sub-pop self.pop._size(0) #erase any current member of the pop self.pop._size(self.settings['num_pops']) self.crossover = self.pop[0].crossover #extract the galg settings so we don't get a ton of warnings #and create the sub ga_s sub_ga_settings = {} self.GAs = [] for key in galg.valid_settings: sub_ga_settings[key] = self.settings[key] for i in range(self.settings['num_pops']): self.GAs.append(galg(self.pop.clone())) self.GAs[i].settings = sub_ga_settings.copy()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
self.step_time = time.clock() - b
self.step_time = timer() - b
def initialize(self, mode = 'serial'): b = time.clock() #same as galg self.test_settings(self.settings) self.gen = 0 sd = self.settings['rand_seed']; alg = self.settings['rand_alg'] rv.initialize(seed = sd, algorithm = alg) self.settings['seed_used'] = rv.initial_seed() self._print('initializing... seed = %d' % self.settings['seed_used']) self.crossover = self.pop[0].crossover # get the crossover op from the first genome self.pop.settings = self.settings #end same as galg #set up my population to hold the best from each sub-pop self.pop._size(0) #erase any current member of the pop self.pop._size(self.settings['num_pops']) self.crossover = self.pop[0].crossover #extract the galg settings so we don't get a ton of warnings #and create the sub ga_s sub_ga_settings = {} self.GAs = [] for key in galg.valid_settings: sub_ga_settings[key] = self.settings[key] for i in range(self.settings['num_pops']): self.GAs.append(galg(self.pop.clone())) self.GAs[i].settings = sub_ga_settings.copy()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
b = time.clock()
b = timer()
def step(self,steps=1,mode = 'serial'): for st in range(steps): b = time.clock() cnt = 0 #self.pop._size(0) # used if we keep a single pop if mode[0] == 'p' or mode[0] == 'P': """ sys.setcheckinterval(100) finished = sync.event() bar = sync.barrier(len(self.GAs)) for ga in self.GAs: thread.start_new_thread(GA_stepper,(bar,finished,ga)) finished.wait() sys.setcheckinterval(10) """ else: for ga in self.GAs: ga.step() for ga in self.GAs: #replace the worst member of the local pop self.pop[-1] = ga.pop.best() self.pop.sort() #probabaly not the fast approach to things, but... keeps an itelligent pop #for ind in ga.pop: self.pop.append(ind) self.migrate() self.gen = self.gen + 1 e = time.clock(); self.step_time = e - b self.update_stats() self.db_entry['best_scores'].append(self.stats['current']['max'])
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
e = time.clock(); self.step_time = e - b
e = timer(); self.step_time = e - b
def step(self,steps=1,mode = 'serial'): for st in range(steps): b = time.clock() cnt = 0 #self.pop._size(0) # used if we keep a single pop if mode[0] == 'p' or mode[0] == 'P': """ sys.setcheckinterval(100) finished = sync.event() bar = sync.barrier(len(self.GAs)) for ga in self.GAs: thread.start_new_thread(GA_stepper,(bar,finished,ga)) finished.wait() sys.setcheckinterval(10) """ else: for ga in self.GAs: ga.step() for ga in self.GAs: #replace the worst member of the local pop self.pop[-1] = ga.pop.best() self.pop.sort() #probabaly not the fast approach to things, but... keeps an itelligent pop #for ind in ga.pop: self.pop.append(ind) self.migrate() self.gen = self.gen + 1 e = time.clock(); self.step_time = e - b self.update_stats() self.db_entry['best_scores'].append(self.stats['current']['max'])
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
b = time.clock()
b = timer()
def evolve(self, mode = 'serial'): b = time.clock() self.initialize(mode) self.pre_evolve() self.p_dev = self.pop_deviation() self.iteration_output() while ( self.gen < self.settings['gens'] and self.settings['p_deviation'] < self.p_dev ): self.step(1,mode) self.p_dev = self.pop_deviation() self.iteration_output() self.update_dbase() #enter status prior to post_evolve in dbase self.post_evolve() self.db_entry['run_time'] = time.clock() - b self.write_dbase()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
self.db_entry['run_time'] = time.clock() - b
self.db_entry['run_time'] = timer() - b
def evolve(self, mode = 'serial'): b = time.clock() self.initialize(mode) self.pre_evolve() self.p_dev = self.pop_deviation() self.iteration_output() while ( self.gen < self.settings['gens'] and self.settings['p_deviation'] < self.p_dev ): self.step(1,mode) self.p_dev = self.pop_deviation() self.iteration_output() self.update_dbase() #enter status prior to post_evolve in dbase self.post_evolve() self.db_entry['run_time'] = time.clock() - b self.write_dbase()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
t1 = time.time()
t1 = timer()
def GA_stepper(bar,finished,GA): t1 = time.time() GA.step() t2 = time.time() print 'thread ' + `thread.get_ident()` + 'time ' + `t2-t1` + ' sec.' bar.enter() finished.post()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
t2 = time.time()
t2 = timer()
def GA_stepper(bar,finished,GA): t1 = time.time() GA.step() t2 = time.time() print 'thread ' + `thread.get_ident()` + 'time ' + `t2-t1` + ' sec.' bar.enter() finished.post()
8418b2938a491bb6a337b1fba872055375ef3547 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8418b2938a491bb6a337b1fba872055375ef3547/algorithm.py
def __init__(self, format, maxprint=MAXPRINT, allocsize=ALLOCSIZE): self.format = format
def __init__(self, maxprint=MAXPRINT, allocsize=ALLOCSIZE): self.format = self.__class__.__name__[:3] if self.format == 'spm': raise ValueError, "This class is not intended" \ " to be instantiated directly."
def __init__(self, format, maxprint=MAXPRINT, allocsize=ALLOCSIZE): self.format = format self.maxprint = maxprint self.allocsize = allocsize
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
csc = self.tocsc()
csc = self.tocsc()
def rmatvec(self, vec, conj=1):
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
spmatrix.__init__(self, 'csc')
spmatrix.__init__(self)
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csc') if isinstance(s,spmatrix): if isinstance(s, csc_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.rowind = s.rowind.copy() self.indptr = s.indptr.copy() else: self.data = s.data self.rowind = s.rowind self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape func = getattr(sparsetools,s.ftype+'transp') self.data, self.rowind, self.indptr = \ func(s.shape[1], s.data, s.colind, s.indptr) else: temp = s.tocsc() self.data = temp.data self.rowind = temp.rowind self.indptr = temp.indptr self.shape = temp.shape elif isinstance(s,type(3)): M=s N=ij self.data = zeros((nzmax,),typecode) self.rowind = zeros((nzmax,),'i') self.indptr = zeros((N+1,),'i') self.shape = (M,N) elif (isinstance(s,ArrayType) or \ isinstance(s,type([]))): s = asarray(s) if s.typecode() not in 'fdFD': s = s*1.0 if (rank(s) == 2): # converting from a full array M, N = s.shape typecode = s.typecode() func = getattr(sparsetools,_transtabl[typecode]+'fulltocsc') ierr = irow = jcol = 0 nnz = sum(ravel(s != 0.0)) a = zeros((nnz,),typecode) rowa = zeros((nnz,),'i') ptra = zeros((N+1,),'i') while 1: a, rowa, ptra, irow, jcol, ierr = \ func(s, a, rowa, ptra, irow, jcol, ierr) if (ierr == 0): break nnz = nnz + ALLOCSIZE a = resize1d(a, nnz) rowa = resize1d(rowa, nnz)
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
spmatrix.__init__(self, 'csr')
spmatrix.__init__(self)
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csr') if isinstance(s,spmatrix): if isinstance(s, csr_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.colind = s.colind.copy() self.indptr = s.indptr.copy() else: self.data = s.data self.colind = s.colind self.indptr = s.indptr elif isinstance(s, csc_matrix): self.shape = s.shape func = getattr(sparsetools,s.ftype+'transp') self.data, self.colind, self.indptr = \ func(s.shape[1], s.data, s.rowind, s.indptr) else: try: temp = s.tocsr() except AttributeError: temp = csr_matrix(s.tocsc()) self.data = temp.data self.rowind = temp.rowind self.indptr = temp.indptr self.shape = temp.shape elif isinstance(s,type(3)): M=s N=ij self.data = zeros((nzmax,),typecode) self.colind = zeros((nzmax,),'i') self.indptr = zeros((M+1,),'i') self.shape = (M,N) elif (isinstance(s,ArrayType) or \ isinstance(s,type([]))): s = asarray(s) if (rank(s) == 2): # converting from a full array ocsc = csc_matrix(transpose(s)) self.shape = ocsc.shape[1], ocsc.shape[0] self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data elif isinstance(ij, ArrayType) and (rank(ij) == 2) and (shape(ij) == (len(s),2)): ijnew = ij.copy() ijnew[:,0] = ij[:,1] ijnew[:,1] = ij[:,0] temp = coo_matrix(s,ijnew,M=M,N=N,nzmax=nzmax, typecode=typecode) temp = temp.tocsc() self.data = temp.data self.colind = temp.colind self.indptr = temp.indptr self.shape = temp.shape elif isinstance(ij, types.TupleType) and (len(ij)==2): self.data = asarray(s) self.colind = ij[0] self.indptr = ij[1] if N is None: try: N = amax(self.colind) + 1 except ValueError: N = 0 if M is None: M = len(self.indptr) - 1 if M == -1: M = 0 self.shape = (M,N) else: raise ValueError, "Unrecognized form for csr_matrix constructor." else: raise ValueError, "Unrecognized form for csr_matrix constructor."
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
spmatrix.__init__(self,'dok')
spmatrix.__init__(self)
def __init__(self,A=None): dict.__init__(self) spmatrix.__init__(self,'dok') self.shape = (0,0) self.nnz = 0 if A is not None: A = asarray(A) N,M = A.shape for n in range(N): for m in range(M): if A[n,m] != 0: self[n,m] = A[n,m]
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
spmatrix.__init__(self, 'coo')
spmatrix.__init__(self)
def __init__(self, obj, ij, M=None, N=None, nzmax=None, typecode=None): spmatrix.__init__(self, 'coo') if type(ij) is type(()) and len(ij)==2: if M is None: M = amax(ij[0]) if N is None: N = amax(ij[1]) self.row = asarray(ij[0],'i') self.col = asarray(ij[1],'i') else: aij = asarray(ij,'i') if M is None: M = amax(aij[:,0]) if N is None: N = amax(aij[:,1]) self.row = aij[:,0] self.col = aij[:,1] aobj = asarray(obj,typecode=typecode) self.shape = (M,N) if nzmax is None: nzmax = len(aobj) self.nzmax = nzmax self.data = aobj self.typecode = aobj.typecode() self._check()
2df51902e42db8054709637688b60399fcc84eff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2df51902e42db8054709637688b60399fcc84eff/Sparse.py
if N == self.numargs + 1 and loc is None:
if N == self.numargs + 1 and loc is None:
def __fix_loc_scale(self, args, loc, scale): N = len(args) if N > self.numargs: if N == self.numargs + 1 and loc is None: # loc is given without keyword loc = args[-1] if N == self.numargs + 2 and scale is None: # loc and scale given without keyword loc, scale = args[-2:] args = args[:self.numargs] if scale is None: scale = 1.0 if loc is None: loc = 0.0 return args, loc, scale
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
if N == self.numargs + 2 and scale is None:
if N == self.numargs + 2 and scale is None:
def __fix_loc_scale(self, args, loc, scale): N = len(args) if N > self.numargs: if N == self.numargs + 1 and loc is None: # loc is given without keyword loc = args[-1] if N == self.numargs + 2 and scale is None: # loc and scale given without keyword loc, scale = args[-2:] args = args[:self.numargs] if scale is None: scale = 1.0 if loc is None: loc = 0.0 return args, loc, scale
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
if N == self.numargs + 1 and loc is None:
if N == self.numargs + 1 and loc is None:
def stats(self,*args,**kwds): """Some statistics of the given RV
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
if N == self.numargs + 2 and scale is None:
if N == self.numargs + 2 and scale is None:
def stats(self,*args,**kwds): """Some statistics of the given RV
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
if N == self.numargs + 3 and moments is None:
if N == self.numargs + 3 and moments is None:
def stats(self,*args,**kwds): """Some statistics of the given RV
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
Pk = mu**k * exp(-mu) / arr(special.gamma(k+1)) return Pk
Pk = k*log(mu)-special.gammaln(k+1) - mu return exp(Pk)
def _pmf(self, k, mu): Pk = mu**k * exp(-mu) / arr(special.gamma(k+1)) return Pk
85d80ea629ce911f4461c01412686e9d330724db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/85d80ea629ce911f4461c01412686e9d330724db/distributions.py
ret_val = apply(obj, args, kw)
ret_val = apply(obj, d_args, d_kw)
def __call__(self, *args, **kw): """Performs the call to the proxied callable object by dispatching the method to the secondary thread.""" obj = self.__dont_mess_with_me_unless_you_know_what_youre_doing ret_val = None if main.in_proxy_call: ret_val = apply(obj, args, kw) else: finished = threading.Event() evt = proxy_event(obj, args, kw, finished) wxPostEvent(self.catcher, evt) finished.wait() if finished.exception_info: raise finished.exception_info[0], \ finished.exception_info[1] ret_val = finished._result return smart_return(ret_val)
e1691937fc8ea21e4aaa1dbae08595df610fdfb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/e1691937fc8ea21e4aaa1dbae08595df610fdfb9/gui_thread_guts.py
evt = proxy_event(obj, args, kw, finished)
evt = proxy_event(obj, d_args, d_kw, finished)
def __call__(self, *args, **kw): """Performs the call to the proxied callable object by dispatching the method to the secondary thread.""" obj = self.__dont_mess_with_me_unless_you_know_what_youre_doing ret_val = None if main.in_proxy_call: ret_val = apply(obj, args, kw) else: finished = threading.Event() evt = proxy_event(obj, args, kw, finished) wxPostEvent(self.catcher, evt) finished.wait() if finished.exception_info: raise finished.exception_info[0], \ finished.exception_info[1] ret_val = finished._result return smart_return(ret_val)
e1691937fc8ea21e4aaa1dbae08595df610fdfb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/e1691937fc8ea21e4aaa1dbae08595df610fdfb9/gui_thread_guts.py
exec(function)
exec function in globals(), locals()
def remap (listoflists,criterion): function = 'lines = map(lambda x: '+criterion+',listoflists)' exec(function) return lines
8038c03fb9544c1182b5e733a069f75219acccfd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8038c03fb9544c1182b5e733a069f75219acccfd/pstat.py
p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j,
p = [-.9077932138396487614720659-82196399419401501888968130.0e-27*1j, -.9077932138396487614720659+82196399419401501888968130.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j,
p = [-.9072099595087001356491337-72142113041117326028823950.0e-27*1j, -.9072099595087001356491337+72142113041117326028823950.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j,
p = [-.9067004324162775554189031-64279241063930693839360680.0e-27*1j, -.9067004324162775554189031+64279241063930693839360680.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j,
p = [-.9062570115576771146523497-57961780277849516990208850.0e-27*1j, -.9062570115576771146523497+57961780277849516990208850.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j,
p = [-.9058702269930872551848625-52774908289999045189007100.0e-27*1j, -.9058702269930872551848625+52774908289999045189007100.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j,
p = [-.9055312363372773709269407-48440066540478700874836350.0e-27*1j, -.9055312363372773709269407+48440066540478700874836350.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
-.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j,
-.9028833390228020537142561-93077131185102967450643820.0e-27*1j, -.9028833390228020537142561+93077131185102967450643820.0e-27*1j,
def besselap(N): """Return (z,p,k) zero, pole, gain for analog prototype of an Nth order Bessel filter.""" z = [] k = 1 if N == 0: p = []; elif N == 1: p = [-1] elif N == 2: p = [-.8660254037844386467637229+.4999999999999999999999996*1j, -.8660254037844386467637229-.4999999999999999999999996*1j] elif N == 3: p = [-.9416000265332067855971980, -.7456403858480766441810907-.7113666249728352680992154*1j, -.7456403858480766441810907+.7113666249728352680992154*1j] elif N == 4: p = [-.6572111716718829545787781-.8301614350048733772399715*1j, -.6572111716718829545787788+.8301614350048733772399715*1j, -.9047587967882449459642637-.2709187330038746636700923*1j, -.9047587967882449459642624+.2709187330038746636700926*1j] elif N == 5: p = [-.9264420773877602247196260, -.8515536193688395541722677-.4427174639443327209850002*1j, -.8515536193688395541722677+.4427174639443327209850002*1j, -.5905759446119191779319432-.9072067564574549539291747*1j, -.5905759446119191779319432+.9072067564574549539291747*1j] elif N == 6: p = [-.9093906830472271808050953-.1856964396793046769246397*1j, -.9093906830472271808050953+.1856964396793046769246397*1j, -.7996541858328288520243325-.5621717346937317988594118*1j, -.7996541858328288520243325+.5621717346937317988594118*1j, -.5385526816693109683073792-.9616876881954277199245657*1j, -.5385526816693109683073792+.9616876881954277199245657*1j] elif N == 7: p = [-.9194871556490290014311619, -.8800029341523374639772340-.3216652762307739398381830*1j, -.8800029341523374639772340+.3216652762307739398381830*1j, -.7527355434093214462291616-.6504696305522550699212995*1j, -.7527355434093214462291616+.6504696305522550699212995*1j, -.4966917256672316755024763-1.002508508454420401230220*1j, -.4966917256672316755024763+1.002508508454420401230220*1j] elif N == 8: p = [-.9096831546652910216327629-.1412437976671422927888150*1j, -.9096831546652910216327629+.1412437976671422927888150*1j, -.8473250802359334320103023-.4259017538272934994996429*1j, -.8473250802359334320103023+.4259017538272934994996429*1j, -.7111381808485399250796172-.7186517314108401705762571*1j, -.7111381808485399250796172+.7186517314108401705762571*1j, -.4621740412532122027072175-1.034388681126901058116589*1j, -.4621740412532122027072175+1.034388681126901058116589*1j] elif N == 9: p = [-.9154957797499037686769223, -.8911217017079759323183848-.2526580934582164192308115*1j, -.8911217017079759323183848+.2526580934582164192308115*1j, -.8148021112269012975514135-.5085815689631499483745341*1j, -.8148021112269012975514135+.5085815689631499483745341*1j, -.6743622686854761980403401-.7730546212691183706919682*1j, -.6743622686854761980403401+.7730546212691183706919682*1j, -.4331415561553618854685942-1.060073670135929666774323*1j, -.4331415561553618854685942+1.060073670135929666774323*1j] elif N == 10: p = [-.9091347320900502436826431-.1139583137335511169927714*1j, -.9091347320900502436826431+.1139583137335511169927714*1j, -.8688459641284764527921864-.3430008233766309973110589*1j, -.8688459641284764527921864+.3430008233766309973110589*1j, -.7837694413101441082655890-.5759147538499947070009852*1j, -.7837694413101441082655890+.5759147538499947070009852*1j, -.6417513866988316136190854-.8175836167191017226233947*1j, -.6417513866988316136190854+.8175836167191017226233947*1j, -.4083220732868861566219785-1.081274842819124562037210*1j, -.4083220732868861566219785+1.081274842819124562037210*1j] elif N == 11: p = [-.9129067244518981934637318, -.8963656705721166099815744-.2080480375071031919692341*1j -.8963656705721166099815744+.2080480375071031919692341*1j, -.8453044014712962954184557-.4178696917801248292797448*1j, -.8453044014712962954184557+.4178696917801248292797448*1j, -.7546938934722303128102142-.6319150050721846494520941*1j, -.7546938934722303128102142+.6319150050721846494520941*1j, -.6126871554915194054182909-.8547813893314764631518509*1j, -.6126871554915194054182909+.8547813893314764631518509*1j, -.3868149510055090879155425-1.099117466763120928733632*1j, -.3868149510055090879155425+1.099117466763120928733632*1j] elif N == 12: p = [-.9084478234140682638817772-95506365213450398415258360.0e-27*1j, -.9084478234140682638817772+95506365213450398415258360.0e-27*1j, -.8802534342016826507901575-.2871779503524226723615457*1j, -.8802534342016826507901575+.2871779503524226723615457*1j, -.8217296939939077285792834-.4810212115100676440620548*1j, -.8217296939939077285792834+.4810212115100676440620548*1j, -.7276681615395159454547013-.6792961178764694160048987*1j, -.7276681615395159454547013+.6792961178764694160048987*1j, -.5866369321861477207528215-.8863772751320727026622149*1j, -.5866369321861477207528215+.8863772751320727026622149*1j, -.3679640085526312839425808-1.114373575641546257595657*1j, -.3679640085526312839425808+1.114373575641546257595657*1j] elif N == 13: p = [-.9110914665984182781070663, -.8991314665475196220910718-.1768342956161043620980863*1j, -.8991314665475196220910718+.1768342956161043620980863*1j, -.8625094198260548711573628-.3547413731172988997754038*1j, -.8625094198260548711573628+.3547413731172988997754038*1j, -.7987460692470972510394686-.5350752120696801938272504*1j, -.7987460692470972510394686+.5350752120696801938272504*1j, -.7026234675721275653944062-.7199611890171304131266374*1j, -.7026234675721275653944062+.7199611890171304131266374*1j, -.5631559842430199266325818-.9135900338325109684927731*1j, -.5631559842430199266325818+.9135900338325109684927731*1j, -.3512792323389821669401925-1.127591548317705678613239*1j, -.3512792323389821669401925+1.127591548317705678613239*1j] elif N == 14: p = [-.9077932138396487614720659-82196399419401501888968130.0E-27*1j, -.9077932138396487614720659+82196399419401501888968130.0E-27*1j, -.8869506674916445312089167-.2470079178765333183201435*1j, -.8869506674916445312089167+.2470079178765333183201435*1j, -.8441199160909851197897667-.4131653825102692595237260*1j, -.8441199160909851197897667+.4131653825102692595237260*1j, -.7766591387063623897344648-.5819170677377608590492434*1j, -.7766591387063623897344648+.5819170677377608590492434*1j, -.6794256425119233117869491-.7552857305042033418417492*1j, -.6794256425119233117869491+.7552857305042033418417492*1j, -.5418766775112297376541293-.9373043683516919569183099*1j, -.5418766775112297376541293+.9373043683516919569183099*1j, -.3363868224902037330610040-1.139172297839859991370924*1j, -.3363868224902037330610040+1.139172297839859991370924*1j] elif N == 15: p = [-.9097482363849064167228581, -.9006981694176978324932918-.1537681197278439351298882*1j, -.9006981694176978324932918+.1537681197278439351298882*1j, -.8731264620834984978337843-.3082352470564267657715883*1j, -.8731264620834984978337843+.3082352470564267657715883*1j, -.8256631452587146506294553-.4642348752734325631275134*1j, -.8256631452587146506294553+.4642348752734325631275134*1j, -.7556027168970728127850416-.6229396358758267198938604*1j, -.7556027168970728127850416+.6229396358758267198938604*1j, -.6579196593110998676999362-.7862895503722515897065645*1j, -.6579196593110998676999362+.7862895503722515897065645*1j, -.5224954069658330616875186-.9581787261092526478889345*1j, -.5224954069658330616875186+.9581787261092526478889345*1j, -.3229963059766444287113517-1.149416154583629539665297*1j, -.3229963059766444287113517+1.149416154583629539665297*1j] elif N == 16: p = [-.9072099595087001356491337-72142113041117326028823950.0E-27*1j, -.9072099595087001356491337+72142113041117326028823950.0E-27*1j, -.8911723070323647674780132-.2167089659900576449410059*1j, -.8911723070323647674780132+.2167089659900576449410059*1j, -.8584264231521330481755780-.3621697271802065647661080*1j, -.8584264231521330481755780+.3621697271802065647661080*1j, -.8074790293236003885306146-.5092933751171800179676218*1j, -.8074790293236003885306146+.5092933751171800179676218*1j, -.7356166304713115980927279-.6591950877860393745845254*1j, -.7356166304713115980927279+.6591950877860393745845254*1j, -.6379502514039066715773828-.8137453537108761895522580*1j, -.6379502514039066715773828+.8137453537108761895522580*1j, -.5047606444424766743309967-.9767137477799090692947061*1j, -.5047606444424766743309967+.9767137477799090692947061*1j, -.3108782755645387813283867-1.158552841199330479412225*1j, -.3108782755645387813283867+1.158552841199330479412225*1j] elif N == 17: p = [-.9087141161336397432860029, -.9016273850787285964692844-.1360267995173024591237303*1j, -.9016273850787285964692844+.1360267995173024591237303*1j, -.8801100704438627158492165-.2725347156478803885651973*1j, -.8801100704438627158492165+.2725347156478803885651973*1j, -.8433414495836129204455491-.4100759282910021624185986*1j, -.8433414495836129204455491+.4100759282910021624185986*1j, -.7897644147799708220288138-.5493724405281088674296232*1j, -.7897644147799708220288138+.5493724405281088674296232*1j, -.7166893842372349049842743-.6914936286393609433305754*1j, -.7166893842372349049842743+.6914936286393609433305754*1j, -.6193710717342144521602448-.8382497252826992979368621*1j, -.6193710717342144521602448+.8382497252826992979368621*1j, -.4884629337672704194973683-.9932971956316781632345466*1j, -.4884629337672704194973683+.9932971956316781632345466*1j, -.2998489459990082015466971-1.166761272925668786676672*1j, -.2998489459990082015466971+1.166761272925668786676672*1j] elif N == 18: p = [-.9067004324162775554189031-64279241063930693839360680.0E-27*1j, -.9067004324162775554189031+64279241063930693839360680.0E-27*1j, -.8939764278132455733032155-.1930374640894758606940586*1j, -.8939764278132455733032155+.1930374640894758606940586*1j, -.8681095503628830078317207-.3224204925163257604931634*1j, -.8681095503628830078317207+.3224204925163257604931634*1j, -.8281885016242836608829018-.4529385697815916950149364*1j, -.8281885016242836608829018+.4529385697815916950149364*1j, -.7726285030739558780127746-.5852778162086640620016316*1j, -.7726285030739558780127746+.5852778162086640620016316*1j, -.6987821445005273020051878-.7204696509726630531663123*1j, -.6987821445005273020051878+.7204696509726630531663123*1j, -.6020482668090644386627299-.8602708961893664447167418*1j, -.6020482668090644386627299+.8602708961893664447167418*1j, -.4734268069916151511140032-1.008234300314801077034158*1j, -.4734268069916151511140032+1.008234300314801077034158*1j, -.2897592029880489845789953-1.174183010600059128532230*1j, -.2897592029880489845789953+1.174183010600059128532230*1j] elif N == 19: p = [-.9078934217899404528985092, -.9021937639390660668922536-.1219568381872026517578164*1j, -.9021937639390660668922536+.1219568381872026517578164*1j, -.8849290585034385274001112-.2442590757549818229026280*1j, -.8849290585034385274001112+.2442590757549818229026280*1j, -.8555768765618421591093993-.3672925896399872304734923*1j, -.8555768765618421591093993+.3672925896399872304734923*1j, -.8131725551578197705476160-.4915365035562459055630005*1j, -.8131725551578197705476160+.4915365035562459055630005*1j, -.7561260971541629355231897-.6176483917970178919174173*1j, -.7561260971541629355231897+.6176483917970178919174173*1j, -.6818424412912442033411634-.7466272357947761283262338*1j, -.6818424412912442033411634+.7466272357947761283262338*1j, -.5858613321217832644813602-.8801817131014566284786759*1j, -.5858613321217832644813602+.8801817131014566284786759*1j, -.4595043449730988600785456-1.021768776912671221830298*1j, -.4595043449730988600785456+1.021768776912671221830298*1j, -.2804866851439370027628724-1.180931628453291873626003*1j, -.2804866851439370027628724+1.180931628453291873626003*1j] elif N == 20: p = [-.9062570115576771146523497-57961780277849516990208850.0E-27*1j, -.9062570115576771146523497+57961780277849516990208850.0E-27*1j, -.8959150941925768608568248-.1740317175918705058595844*1j, -.8959150941925768608568248+.1740317175918705058595844*1j, -.8749560316673332850673214-.2905559296567908031706902*1j, -.8749560316673332850673214+.2905559296567908031706902*1j, -.8427907479956670633544106-.4078917326291934082132821*1j, -.8427907479956670633544106+.4078917326291934082132821*1j, -.7984251191290606875799876-.5264942388817132427317659*1j, -.7984251191290606875799876+.5264942388817132427317659*1j, -.7402780309646768991232610-.6469975237605228320268752*1j, -.7402780309646768991232610+.6469975237605228320268752*1j, -.6658120544829934193890626-.7703721701100763015154510*1j, -.6658120544829934193890626+.7703721701100763015154510*1j, -.5707026806915714094398061-.8982829066468255593407161*1j, -.5707026806915714094398061+.8982829066468255593407161*1j, -.4465700698205149555701841-1.034097702560842962315411*1j, -.4465700698205149555701841+1.034097702560842962315411*1j, -.2719299580251652601727704-1.187099379810885886139638*1j, -.2719299580251652601727704+1.187099379810885886139638*1j] elif N == 21: p = [-.9072262653142957028884077, -.9025428073192696303995083-.1105252572789856480992275*1j, -.9025428073192696303995083+.1105252572789856480992275*1j, -.8883808106664449854431605-.2213069215084350419975358*1j, -.8883808106664449854431605+.2213069215084350419975358*1j, -.8643915813643204553970169-.3326258512522187083009453*1j, -.8643915813643204553970169+.3326258512522187083009453*1j, -.8299435470674444100273463-.4448177739407956609694059*1j, -.8299435470674444100273463+.4448177739407956609694059*1j, -.7840287980408341576100581-.5583186348022854707564856*1j, -.7840287980408341576100581+.5583186348022854707564856*1j, -.7250839687106612822281339-.6737426063024382240549898*1j, -.7250839687106612822281339+.6737426063024382240549898*1j, -.6506315378609463397807996-.7920349342629491368548074*1j, -.6506315378609463397807996+.7920349342629491368548074*1j, -.5564766488918562465935297-.9148198405846724121600860*1j, -.5564766488918562465935297+.9148198405846724121600860*1j, -.4345168906815271799687308-1.045382255856986531461592*1j, -.4345168906815271799687308+1.045382255856986531461592*1j, -.2640041595834031147954813-1.192762031948052470183960*1j, -.2640041595834031147954813+1.192762031948052470183960*1j] elif N == 22: p = [-.9058702269930872551848625-52774908289999045189007100.0E-27*1j, -.9058702269930872551848625+52774908289999045189007100.0E-27*1j, -.8972983138153530955952835-.1584351912289865608659759*1j, -.8972983138153530955952835+.1584351912289865608659759*1j, -.8799661455640176154025352-.2644363039201535049656450*1j, -.8799661455640176154025352+.2644363039201535049656450*1j, -.8534754036851687233084587-.3710389319482319823405321*1j, -.8534754036851687233084587+.3710389319482319823405321*1j, -.8171682088462720394344996-.4785619492202780899653575*1j, -.8171682088462720394344996+.4785619492202780899653575*1j, -.7700332930556816872932937-.5874255426351153211965601*1j, -.7700332930556816872932937+.5874255426351153211965601*1j, -.7105305456418785989070935-.6982266265924524000098548*1j, -.7105305456418785989070935+.6982266265924524000098548*1j, -.6362427683267827226840153-.8118875040246347267248508*1j, -.6362427683267827226840153+.8118875040246347267248508*1j, -.5430983056306302779658129-.9299947824439872998916657*1j, -.5430983056306302779658129+.9299947824439872998916657*1j, -.4232528745642628461715044-1.055755605227545931204656*1j, -.4232528745642628461715044+1.055755605227545931204656*1j, -.2566376987939318038016012-1.197982433555213008346532*1j, -.2566376987939318038016012+1.197982433555213008346532*1j] elif N == 23: p = [-.9066732476324988168207439, -.9027564979912504609412993-.1010534335314045013252480*1j, -.9027564979912504609412993+.1010534335314045013252480*1j, -.8909283242471251458653994-.2023024699381223418195228*1j, -.8909283242471251458653994+.2023024699381223418195228*1j, -.8709469395587416239596874-.3039581993950041588888925*1j, -.8709469395587416239596874+.3039581993950041588888925*1j, -.8423805948021127057054288-.4062657948237602726779246*1j, -.8423805948021127057054288+.4062657948237602726779246*1j, -.8045561642053176205623187-.5095305912227258268309528*1j, -.8045561642053176205623187+.5095305912227258268309528*1j, -.7564660146829880581478138-.6141594859476032127216463*1j, -.7564660146829880581478138+.6141594859476032127216463*1j, -.6965966033912705387505040-.7207341374753046970247055*1j, -.6965966033912705387505040+.7207341374753046970247055*1j, -.6225903228771341778273152-.8301558302812980678845563*1j, -.6225903228771341778273152+.8301558302812980678845563*1j, -.5304922463810191698502226-.9439760364018300083750242*1j, -.5304922463810191698502226+.9439760364018300083750242*1j, -.4126986617510148836149955-1.065328794475513585531053*1j, -.4126986617510148836149955+1.065328794475513585531053*1j, -.2497697202208956030229911-1.202813187870697831365338*1j, -.2497697202208956030229911+1.202813187870697831365338*1j] elif N == 24: p = [-.9055312363372773709269407-48440066540478700874836350.0E-27*1j, -.9055312363372773709269407+48440066540478700874836350.0E-27*1j, -.8983105104397872954053307-.1454056133873610120105857*1j, -.8983105104397872954053307+.1454056133873610120105857*1j, -.8837358034555706623131950-.2426335234401383076544239*1j, -.8837358034555706623131950+.2426335234401383076544239*1j, -.8615278304016353651120610-.3403202112618624773397257*1j, -.8615278304016353651120610+.3403202112618624773397257*1j, -.8312326466813240652679563-.4386985933597305434577492*1j, -.8312326466813240652679563+.4386985933597305434577492*1j, -.7921695462343492518845446-.5380628490968016700338001*1j, -.7921695462343492518845446+.5380628490968016700338001*1j, -.7433392285088529449175873-.6388084216222567930378296*1j, -.7433392285088529449175873+.6388084216222567930378296*1j, -.6832565803536521302816011-.7415032695091650806797753*1j, -.6832565803536521302816011+.7415032695091650806797753*1j, -.6096221567378335562589532-.8470292433077202380020454*1j, -.6096221567378335562589532+.8470292433077202380020454*1j, -.5185914574820317343536707-.9569048385259054576937721*1j, -.5185914574820317343536707+.9569048385259054576937721*1j, -.4027853855197518014786978-1.074195196518674765143729*1j, -.4027853855197518014786978+1.074195196518674765143729*1j, -.2433481337524869675825448-1.207298683731972524975429*1j, -.2433481337524869675825448+1.207298683731972524975429*1j] elif N == 25: p = [-.9062073871811708652496104, -.9028833390228020537142561-93077131185102967450643820.0E-27*1j, -.9028833390228020537142561+93077131185102967450643820.0E-27*1j, -.8928551459883548836774529-.1863068969804300712287138*1j, -.8928551459883548836774529+.1863068969804300712287138*1j, -.8759497989677857803656239-.2798521321771408719327250*1j, -.8759497989677857803656239+.2798521321771408719327250*1j, -.8518616886554019782346493-.3738977875907595009446142*1j, -.8518616886554019782346493+.3738977875907595009446142*1j, -.8201226043936880253962552-.4686668574656966589020580*1j, -.8201226043936880253962552+.4686668574656966589020580*1j, -.7800496278186497225905443-.5644441210349710332887354*1j, -.7800496278186497225905443+.5644441210349710332887354*1j, -.7306549271849967721596735-.6616149647357748681460822*1j, -.7306549271849967721596735+.6616149647357748681460822*1j, -.6704827128029559528610523-.7607348858167839877987008*1j, -.6704827128029559528610523+.7607348858167839877987008*1j, -.5972898661335557242320528-.8626676330388028512598538*1j, -.5972898661335557242320528+.8626676330388028512598538*1j, -.5073362861078468845461362-.9689006305344868494672405*1j, -.5073362861078468845461362+.9689006305344868494672405*1j, -.3934529878191079606023847-1.082433927173831581956863*1j, -.3934529878191079606023847+1.082433927173831581956863*1j, -.2373280669322028974199184-1.211476658382565356579418*1j, -.2373280669322028974199184+1.211476658382565356579418*1j] else: raise ValueError, "Bessel Filter not supported for order %d" % N return z, p, k
ee6961d5910f2418dc834f4b5da829ba2be9b7d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ee6961d5910f2418dc834f4b5da829ba2be9b7d9/filter_design.py
b = io.read_array(fname,atype=N.Int)
b = io.read_array(fname,atype=a.dtypechar)
def check_integer(self): from scipy import stats a = stats.randint.rvs(1,20,size=(3,4)) fname = tempfile.mktemp('.dat') io.write_array(fname,a) b = io.read_array(fname,atype=N.Int) assert_array_equal(a,b) os.remove(fname)
c42dc01dd06910aab5fe8510056e2fc58ab5c8fa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/c42dc01dd06910aab5fe8510056e2fc58ab5c8fa/test_array_import.py
Ap = apply(approx_fhess_p,(xk,psupi,fprime,espilon)+args)
Ap = apply(approx_fhess_p,(xk,psupi,fprime,epsilon)+args)
def fmin_ncg(f, x0, fprime, fhess_p=None, fhess=None, args=(), avextol=1e-5, epsilon=1e-8, maxiter=None, full_output=0, disp=1): """Description: Minimize the function, f, whose gradient is given by fprime using the Newton-CG method. fhess_p must compute the hessian times an arbitrary vector. If it is not given, finite-differences on fprime are used to compute it. See Wright, and Nocedal 'Numerical Optimization', 1999, pg. 140. Inputs: f -- the Python function or method to be minimized. x0 -- the initial guess for the minimizer. fprime -- a function to compute the gradient of f: fprime(x, *args) fhess_p -- a function to compute the Hessian of f times an arbitrary vector: fhess_p (x, p, *args) fhess -- a function to compute the Hessian matrix of f. args -- extra arguments for f, fprime, fhess_p, and fhess (the same set of extra arguments is supplied to all of these functions). epsilon -- if fhess is approximated use this value for the step size (can be scalar or vector) Outputs: (xopt, {fopt, fcalls, gcalls, hcalls, warnflag}) xopt -- the minimizer of f fopt -- the value of the function at xopt: fopt = f(xopt) fcalls -- the number of function calls. gcalls -- the number of gradient calls. hcalls -- the number of hessian calls. warnflag -- algorithm warnings: 1 : 'Maximum number of iterations exceeded.' Additional Inputs: avextol -- Convergence is assumed when the average relative error in the minimizer falls below this amount. maxiter -- Maximum number of iterations to allow. full_output -- If non-zero return the optional outputs. disp -- If non-zero print convergence message. Remarks: Only one of fhess_p or fhess need be given. If fhess is provided, then fhess_p will be ignored. If neither fhess nor fhess_p is provided, then the hessian product will be approximated using finite differences on fprime. """ x0 = asarray(x0) fcalls = 0 gcalls = 0 hcalls = 0 if maxiter is None: maxiter = len(x0)*200 xtol = len(x0)*avextol update = [2*xtol] xk = x0 k = 0 old_fval = f(x0,*args) fcalls += 1 while (Num.add.reduce(abs(update)) > xtol) and (k < maxiter): # Compute a search direction pk by applying the CG method to # del2 f(xk) p = - grad f(xk) starting from 0. b = -apply(fprime,(xk,)+args) gcalls = gcalls + 1 maggrad = Num.add.reduce(abs(b)) eta = min([0.5,Num.sqrt(maggrad)]) termcond = eta * maggrad xsupi = 0 ri = -b psupi = -ri i = 0 dri0 = Num.dot(ri,ri) if fhess is not None: # you want to compute hessian once. A = apply(fhess,(xk,)+args) hcalls = hcalls + 1 while Num.add.reduce(abs(ri)) > termcond: if fhess is None: if fhess_p is None: Ap = apply(approx_fhess_p,(xk,psupi,fprime,espilon)+args) gcalls = gcalls + 2 else: Ap = apply(fhess_p,(xk,psupi)+args) hcalls = hcalls + 1 else: Ap = Num.dot(A,psupi) # check curvature curv = Num.dot(psupi,Ap) if (curv <= 0): if (i > 0): break else: xsupi = xsupi + dri0/curv * psupi break alphai = dri0 / curv xsupi = xsupi + alphai * psupi ri = ri + alphai * Ap dri1 = Num.dot(ri,ri) betai = dri1 / dri0 psupi = -ri + betai * psupi i = i + 1 dri0 = dri1 # update Num.dot(ri,ri) for next time. pk = xsupi # search direction is solution to system. gfk = -b # gradient at xk alphak, fc, gc, old_fval = line_search_BFGS(f,xk,pk,gfk,old_fval,args) fcalls = fcalls + fc gcalls = gcalls + gc update = alphak * pk xk = xk + update k = k + 1 if disp or full_output: fval = old_fval if k >= maxiter: warnflag = 1 if disp: print "Warning: Maximum number of iterations has been exceeded" print " Current function value: %f" % fval print " Iterations: %d" % k print " Function evaluations: %d" % fcalls print " Gradient evaluations: %d" % gcalls print " Hessian evaluations: %d" % hcalls else: warnflag = 0 if disp: print "Optimization terminated successfully." print " Current function value: %f" % fval print " Iterations: %d" % k print " Function evaluations: %d" % fcalls print " Gradient evaluations: %d" % gcalls print " Hessian evaluations: %d" % hcalls if full_output: return xk, fval, fcalls, gcalls, hcalls, warnflag else: return xk
19314b480bb5aa9c9df6e44d3dad6a778b6d183b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/19314b480bb5aa9c9df6e44d3dad6a778b6d183b/optimize.py
e = 0.0
deltax= 0.0
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if (abs(e) <= tol1): if (x>=xmid): e=a-x else: e=b-x d = _cg*e else:
if (abs(deltax) <= tol1): if (x>=xmid): deltax=a-x else: deltax=b-x rat = _cg*deltax else:
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
etemp = e e = d
dx_temp = deltax deltax= rat
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 u = x + d
if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*dx_temp))): rat = p*1.0/tmp2 u = x + rat
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if xmid-x >= 0: d = tol1 else: d = -tol1
if xmid-x >= 0: rat = tol1 else: rat = -tol1
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if (x>=xmid): e=a-x else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1
if (x>=xmid): deltax=a-x else: deltax=b-x rat = _cg*deltax if (abs(rat) < tol1): if rat >= 0: u = x + tol1
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
u = x + d fu = apply(func, (u,)+args)
u = x + rat fu = apply(func, (u,)+args)
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if (fu > fx):
if (fu > fx):
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is two numbers then they are assumed to be a starting interval for a downhill bracket search (see bracket) Uses inverse interpolation when possible to speed up convergence. """ _mintol = 1.0e-11 _cg = 0.3819660 if brack is None: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, args=args) elif len(brack) == 2: xa,xb,xc,fa,fb,fc,funcalls = bracket(func, xa=brack[0], xb=brack[1], args=args) elif len(brack) == 3: xa,xb,xc = brack if (xa > xc): # swap so xa < xc can be assumed dum = xa; xa=xc; xc=dum assert ((xa < xb) and (xb < xc)), "Not a bracketing interval." fa = apply(func, (xa,)+args) fb = apply(func, (xb,)+args) fc = apply(func, (xc,)+args) assert ((fb<fa) and (fb < fc)), "Not a bracketing interval." funcalls = 3 else: raise ValuError, "Bracketing interval must be length 2 or 3 sequence." x=w=v=xb fw=fv=fx=apply(func, (x,)+args) if (xa < xc): a = xa; b = xc else: a = xc; b = xa e = 0.0 funcalls = 1 iter = 0 while (iter < maxiter): tol1 = tol*abs(x) + _mintol tol2 = 2.0*tol1 xmid = 0.5*(a+b) if abs(x-xmid) < (tol2-0.5*(b-a)): # check for convergence xmin=x; fval=fx break if (abs(e) <= tol1): # do a parabolic fit if (x>=xmid): e=a-x else: e=b-x d = _cg*e else: tmp1 = (x-w)*(fx-fv) tmp2 = (x-v)*(fx-fw) p = (x-v)*tmp2 - (x-w)*tmp1; tmp2 = 2.0*(tmp2-tmp1) if (tmp2 > 0.0): p = -p tmp2 = abs(tmp2) etemp = e e = d # check parabolic fit if ((p > tmp2*(a-x)) and (p < tmp2*(b-x)) and (abs(p) < abs(0.5*tmp2*etemp))): d = p*1.0/tmp2 # if it's good use it. u = x + d if ((u-a) < tol2 or (b-u) < tol2): if xmid-x >= 0: d = tol1 else: d = -tol1 else: if (x>=xmid): e=a-x # if it's bad do a golden section step else: e=b-x d = _cg*e if (abs(d) < tol1): if d >= 0: u = x + tol1 else: u = x - tol1 else: u = x + d fu = apply(func, (u,)+args) funcalls += 1 if (fu > fx): if (u<x): a=u else: b=u if (fu<=fw) or (w==x): v=w; w=u; fv=fw; fw=fu elif (fu<=fv) or (v==x) or (v==w): v=u; fv=fu else: if (u >= x): a = x else: b = x v=w; w=x; x=u fv=fw; fw=fx; fx=fu xmin = x fval = fx if full_output: return xmin, fval, iter, funcalls else: return xmin
151bc0cf429941b974cff683950f0c18642f7da4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/151bc0cf429941b974cff683950f0c18642f7da4/optimize.py
if data.dtype.char == 'f' and data2.dtype.char == 'f': new = zeros(data.shape,'F') new.real = data new.imag = data2 data = new del(new) del(data2)
new = zeros(data.shape,data.dtype.char.capitalize()) new.real = data new.imag = data2 data = new del(new) del(data2)
def loadmat(name, dict=None, appendmat=1, basename='raw'): """Load the MATLAB(tm) mat file. If name is a full path name load it in. Otherwise search for the file on the sys.path list and load the first one found (the current directory is searched first). Both v4 (Level 1.0) and v6 matfiles are supported. Version 7.0 files are not yet supported. Inputs: name -- name of the mat file (don't need .mat extension if appendmat=1) dict -- the dictionary to insert into. If none the variables will be returned in a dictionary. appendmat -- non-zero to append the .mat extension to the end of the given filename. basename -- for MATLAB(tm) v5 matfiles raw data will have this basename. Outputs: If dict is None, then a dictionary of names and objects representing the stored arrays is returned. """ if appendmat and name[-4:] == ".mat": name = name[:-4] if os.sep in name: full_name = name if appendmat: full_name = name + ".mat" else: full_name = None junk,name = os.path.split(name) for path in sys.path: test_name = os.path.join(path,name) if appendmat: test_name += ".mat" try: fid = open(test_name,'rb') fid.close() full_name = test_name break except IOError: pass if full_name is None: raise IOError, "%s not found on the path." % name fid = fopen(full_name,'rb') test_vals = fid.fread(4,'byte') if not (0 in test_vals): # MATLAB version 5 format fid.rewind() thisdict = _loadv5(fid,basename) if dict is not None: dict.update(thisdict) return else: return thisdict testtype = struct.unpack('i',test_vals.tostring()) # Check to see if the number is positive and less than 5000. if testtype[0] < 0 or testtype[0] > 4999: # wrong byte-order if LittleEndian: format = 'ieee-be' else: format = 'ieee-le' else: # otherwise we are O.K. if LittleEndian: format = 'ieee-le' else: format = 'ieee-be' fid.setformat(format) length = fid.size() fid.rewind() # back to the begining defnames = [] thisdict = {} while 1: if (fid.tell() == length): break header = fid.fread(5,'int') if len(header) != 5: fid.close() print "Warning: Read error in file." break M,rest = divmod(header[0],1000) O,rest = divmod(rest,100) P,rest = divmod(rest,10) T = rest if (M > 1): fid.close() raise ValueError, "Unsupported binary format." if (O != 0): fid.close() raise ValuError, "Hundreds digit of first integer should be zero." if (T not in [0,1]): fid.close() raise ValueError, "Cannot handle sparse matrices, yet." storage = {0:'d',1:'f',2:'i',3:'h',4:'H',5:'B'}[P] varname = fid.fread(header[-1],'char')[:-1] varname = varname.tostring() defnames.append(varname) numels = header[1]*header[2] if T == 0: # Text data data = atleast_1d(fid.fread(numels,storage)) if header[3]: # imaginary data data2 = fid.fread(numels,storage) if data.dtype.char == 'f' and data2.dtype.char == 'f': new = zeros(data.shape,'F') new.real = data new.imag = data2 data = new del(new) del(data2) if len(data) > 1: data=data.reshape((header[2], header[1]) ) thisdict[varname] = transpose(squeeze(data)) else: thisdict[varname] = data else: data = atleast_1d(fid.fread(numels,storage,'char')) if len(data) > 1: data=data.reshape((header[2], header[1])) thisdict[varname] = transpose(squeeze(data)) else: thisdict[varname] = data fid.close() if dict is not None: print "Names defined = ", defnames dict.update(thisdict) else: return thisdict
e9afbd66fb9a44206df23633ca05110de268e8ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/e9afbd66fb9a44206df23633ca05110de268e8ed/mio.py
def is_numeric_array(x): try: x.typecode() in ['c','b','l','d','f','D','F'] return 1 except AttributeError: pass return 0
def is_immutable(x): """ Checks if object is completely immutable. A tuple is not considered completely immutable since it could contain references to objects that could change. Returns 1 if it is immutable or 0 if object is mutable.""" imm = () try: imm = (types.StringType, types.FloatType, types.IntType, types.ComplexType, types.NoneType, types.UnicodeType) except AttributeError: imm = (types.StringType, types.FloatType, types.IntType, types.ComplexType, type.NoneType) if type(x) in imm: return 1 else: return 0
9eacfdd57411f3055528218ed98b0b8a74727406 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/9eacfdd57411f3055528218ed98b0b8a74727406/gui_thread_guts.py
exec exec_code
exec exec_code in globals, globals
def exec_code(code,inputs,returns,global_vars,addendum=None): if addendum: inputs.update(addendum) if not returns: returns = () if type(returns) == type(''): raise TypeError, 'returns must be a sequence object - not a string' exec_code = build_globals(global_vars) exec_code = exec_code + build_inputs(inputs) exec_code = exec_code + code exec exec_code #perhaps do something here to catch errors if len(returns) == 1: results = eval(returns[0]) elif len(returns) > 1: results = [] for i in returns: results.append(eval(i)) results = tuple(results) else: results = None return results
19a34b9b8657fdfd4fccb935e57c1480dce439b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/19a34b9b8657fdfd4fccb935e57c1480dce439b1/sync_cluster.py
exec exec_code
exec exec_code in globals, globals
def loop_code(code,loop_var,inputs,returns,global_vars,addendum=None): if type(returns) == type(''): raise TypeError, 'returns must be a sequence object - not a string' if addendum: inputs.update(addendum) _loop_data = inputs[loop_var] del inputs[loop_var] #not strictly necessary exec_code = build_loop_code(code,loop_var,inputs,returns,global_vars) exec exec_code return _all_results
19a34b9b8657fdfd4fccb935e57c1480dce439b1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/19a34b9b8657fdfd4fccb935e57c1480dce439b1/sync_cluster.py
m,n (m<=n) and argument theta and phi: Y^m_n(theta,phi)
m,n (|m|<=n) and argument theta and phi: Y^m_n(theta,phi)
def _sph_harmonic(m,n,theta,phi): """inputs of (m,n,theta,phi) returns spherical harmonic of order m,n (m<=n) and argument theta and phi: Y^m_n(theta,phi) """ x = cos(phi) m,n = int(m), int(n) Pmn,Pmnd = lpmn(m,n,x) val = Pmn[m,n] val *= sqrt((2*m+1)/4.0/pi) val *= exp(0.5*gammaln(n-m+1)-gammaln(n+m+1)) val *= exp(1j*m*theta) return val
a48e27f42453f948a48fd1367655a3d0d70d943e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/a48e27f42453f948a48fd1367655a3d0d70d943e/basic.py
val *= sqrt((2*m+1)/4.0/pi)
val *= sqrt((2*n+1)/4.0/pi)
def _sph_harmonic(m,n,theta,phi): """inputs of (m,n,theta,phi) returns spherical harmonic of order m,n (m<=n) and argument theta and phi: Y^m_n(theta,phi) """ x = cos(phi) m,n = int(m), int(n) Pmn,Pmnd = lpmn(m,n,x) val = Pmn[m,n] val *= sqrt((2*m+1)/4.0/pi) val *= exp(0.5*gammaln(n-m+1)-gammaln(n+m+1)) val *= exp(1j*m*theta) return val
a48e27f42453f948a48fd1367655a3d0d70d943e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/a48e27f42453f948a48fd1367655a3d0d70d943e/basic.py
sources = ['cobyla.pyf','cobyla2.f']
sources = ['cobyla.pyf','cobyla2.f','trstlp.f']
def configuration(parent_package='',parent_path=None): package = 'optimize' config = default_config_dict(package, parent_package) local_path = get_path(__name__,parent_path) minpack = ('minpack',{'sources': glob(os.path.join(local_path,'minpack','*.f'))}) sources = ['_minpackmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(dot_join(parent_package, package, '_minpack'), sources, libraries = [minpack]) config['ext_modules'].append(ext) rootfind = glob(os.path.join(local_path,'Zeros','*.c')) roothead = os.path.join(local_path,'zeros.h') config['libraries'].append(('rootfind',{'sources':rootfind, 'headers':roothead})) sources = ['zeros.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(dot_join(parent_package, package, '_zeros'), sources, libraries=['rootfind']) config['ext_modules'].append(ext) lapack = system_info.lapack_opt_info().get_info() sources = ['lbfgsb.pyf','routines.f'] sources = [os.path.join(local_path,'lbfgsb-0.9',x) for x in sources] ext = Extension(dot_join(parent_package, package, "_lbfgsb"), sources=sources, **lapack) config['ext_modules'].append(ext) sources = ['moduleTNC.c', 'tnc.c'] sources = [os.path.join(local_path,'tnc',x) for x in sources] ext = Extension(dot_join(parent_package, package, 'moduleTNC'), sources=sources) config['ext_modules'].append(ext) sources = ['cobyla.pyf','cobyla2.f'] sources = [os.path.join(local_path,'cobyla',x) for x in sources] ext = Extension(dot_join(parent_package, package, '_cobyla'), sources=sources) config['ext_modules'].append(ext) sources = ['minpack2.pyf', 'dcsrch.f', 'dcstep.f'] sources = [os.path.join(local_path,'minpack2',x) for x in sources] ext = Extension(dot_join(parent_package, package, 'minpack2'), sources=sources) config['ext_modules'].append(ext) return config
18a46f16217dd63b1e83e0fb5f152d7fa3839db0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/18a46f16217dd63b1e83e0fb5f152d7fa3839db0/setup_optimize.py
def day(self): return self.getDate().day def day_of_week(self): return self.getDate().day_of_week def month(self): return self.getDate().month def quarter(self): return monthToQuarter(self.getDate().month) def year(self): return self.getDate().year def seconds(self): return int(self.getDate().second) def minute(self): return int(self.getDate().minute) def hour(self): return int(self.getDate().hour)
def day(self): return self.mxDate().day def day_of_week(self): return self.mxDate().day_of_week def month(self): return self.mxDate().month def quarter(self): return monthToQuarter(self.mxDate().month) def year(self): return self.mxDate().year def seconds(self): return int(self.mxDate().second) def minute(self): return int(self.mxDate().minute) def hour(self): return int(self.mxDate().hour)
def day(self): return self.getDate().day
eca0344ebf916e3728341976a91317f1fef7c124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/eca0344ebf916e3728341976a91317f1fef7c124/tsdate.py
def get_eig_func(): try: import scipy.linalg eig = scipy.linalg.eig except ImportError: try: import linalg eig = linalg.eig except ImportError: try: import LinearAlgebra eig = LinearAlgebra.eigenvectors except: raise ImportError, \ "You must have scipy.linalg or LinearAlgebra to "\ "use this function." return eig
def __init__(self, roots, weights=None, hn=1.0, An=1.0, wfunc=None, limits=None, monic=0): poly1d.__init__(self, roots, r=1)
bde258f85f96f26a52a0b9f6ccec2cf3fbabb7d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/bde258f85f96f26a52a0b9f6ccec2cf3fbabb7d4/orthogonal.py
from scipy.linalg import eig
eig = get_eig_func()
def gen_roots_and_weights(n,an_func,sqrt_bn_func,mu): """[x,w] = gen_roots_and_weights(n,an_func,sqrt_bn_func,mu) Returns the roots (x) of an nth order orthogonal polynomail, and weights (w) to use in appropriate Gaussian quadrature with that orthogonal polynomial. The polynomials have the recurrence relation P_n+1(x) = (x - A_n) P_n(x) - B_n P_n-1(x) an_func(n) should return A_n sqrt_bn_func(n) should return sqrt(B_n) mu ( = h_0 ) is the integral of the weight over the orthogonal interval """ # XXX: shouldn't import linalg inside a function from scipy.linalg import eig nn = arange(1.0,n) sqrt_bn = sqrt_bn_func(nn) an = an_func(concatenate(([0],nn))) [x,v] = eig((diag(an)+diag(sqrt_bn,1)+diag(sqrt_bn,-1))) answer = [] sortind = argsort(real(x)) answer.append(take(x,sortind)) answer.append(take(mu*v[0]**2,sortind)) return answer
bde258f85f96f26a52a0b9f6ccec2cf3fbabb7d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/bde258f85f96f26a52a0b9f6ccec2cf3fbabb7d4/orthogonal.py
lena = scipy.array(cPickle.load(f))
lena = array(cPickle.load(f))
def lena(): import cPickle, os fname = os.path.join(os.path.dirname(__file__),'plt','lena.dat') f = open(fname,'rb') lena = scipy.array(cPickle.load(f)) f.close() return lena
ffd47dc4bbee8d1b90d8f795e2475cda8d7ab117 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ffd47dc4bbee8d1b90d8f795e2475cda8d7ab117/common.py
g = Numeric.array([[5,6,4,3],[3,5,6,2],[2,3,5,6],[1,6,9,7]],'d') correct = Numeric.array([[2.16374269,3.2222222222, 2.8888888889, 1.6666666667],[2.666666667, 4.33333333333, 4.44444444444, 2.8888888888],[2.222222222, 4.4444444444, 5.4444444444, 4.801066874837],[1.33333333333, 3.92735042735, 6.0712560386, 5.0404040404]]) h = wiener(g)
g = array([[5,6,4,3],[3,5,6,2],[2,3,5,6],[1,6,9,7]],'d') correct = array([[2.16374269,3.2222222222, 2.8888888889, 1.6666666667],[2.666666667, 4.33333333333, 4.44444444444, 2.8888888888],[2.222222222, 4.4444444444, 5.4444444444, 4.801066874837],[1.33333333333, 3.92735042735, 6.0712560386, 5.0404040404]]) h = signal.wiener(g)
def check_basic(self): g = Numeric.array([[5,6,4,3],[3,5,6,2],[2,3,5,6],[1,6,9,7]],'d') correct = Numeric.array([[2.16374269,3.2222222222, 2.8888888889, 1.6666666667],[2.666666667, 4.33333333333, 4.44444444444, 2.8888888888],[2.222222222, 4.4444444444, 5.4444444444, 4.801066874837],[1.33333333333, 3.92735042735, 6.0712560386, 5.0404040404]]) h = wiener(g) assert_array_almost_equal(h,correct,decimal=6)
ce42f573a06a3c9d43c3eee5bc449f215faf14e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/ce42f573a06a3c9d43c3eee5bc449f215faf14e8/test_signaltools.py
artype = b.typecode() if artype not in ['F','D','f','d']: artype = Num.Float
artype = mintypecode((a,b))
def lp2bp(b,a,wo=1.0, bw=1.0): """Return a band-pass filter with center frequency wo and bandwidth bw from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = b.typecode() if artype not in ['F','D','f','d']: artype = Num.Float ma = max([N,D]) Np = N + ma Dp = D + ma bprime = Num.zeros(Np+1,artype) aprime = Num.zeros(Dp+1,artype) wosq = wo*wo for j in range(Np+1): val = 0.0 for i in range(0,N+1): for k in range(0,i+1): if ma-i+2*k == j: val += comb(i,k)*b[N-i]*(wosq)**(i-k) / bw**i bprime[Np-j] = val for j in range(Dp+1): val = 0.0 for i in range(0,D+1): for k in range(0,i+1): if ma-i+2*k == j: val += comb(i,k)*a[D-i]*(wosq)**(i-k) / bw**i aprime[Dp-j] = val return normalize(bprime, aprime)
eb85a014d534e66d42610f6f5ad6031ebdb93f39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/eb85a014d534e66d42610f6f5ad6031ebdb93f39/filter_design.py
artype = b.typecode() if artype not in ['F','D','f','d']: artype = Num.Float
artype = mintypecode((a,b))
def lp2bs(b,a,wo=1,bw=1): """Return a band-stop filter with center frequency wo and bandwidth bw from a low-pass filter prototype with unity cutoff frequency. """ a,b = map(atleast_1d,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = b.typecode() if artype not in ['F','D','f','d']: artype = Num.Float M = max([N,D]) Np = M + M Dp = M + M bprime = Num.zeros(Np+1,artype) aprime = Num.zeros(Dp+1,artype) wosq = wo*wo for j in range(Np+1): val = 0.0 for i in range(0,N+1): for k in range(0,M-i+1): if i+2*k == j: val += comb(M-i,k)*b[N-i]*(wosq)**(M-i-k) * bw**i bprime[Np-j] = val for j in range(Dp+1): val = 0.0 for i in range(0,D+1): for k in range(0,M-i+1): if i+2*k == j: val += comb(M-i,k)*a[D-i]*(wosq)**(M-i-k) * bw**i aprime[Dp-j] = val return normalize(bprime, aprime)
eb85a014d534e66d42610f6f5ad6031ebdb93f39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/eb85a014d534e66d42610f6f5ad6031ebdb93f39/filter_design.py
nnz = sum(ravel(s != 0.0))
nnz = (s != 0.0).sum()
def __init__(self, arg1, dims=None, nzmax=100, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: #s = asarray(arg1) s = arg1 if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): M, N = s.shape dtype = s.dtype func = getattr(sparsetools, _transtabl[dtype.char]+'fulltocsc') ierr = irow = jcol = 0 nnz = sum(ravel(s != 0.0)) a = zeros((nnz,), self.dtype) rowa = zeros((nnz,), intc) ptra = zeros((N+1,), intc) while 1: a, rowa, ptra, irow, jcol, ierr = \ func(s, a, rowa, ptra, irow, jcol, ierr) if (ierr == 0): break nnz = nnz + ALLOCSIZE a = resize1d(a, nnz) rowa = resize1d(rowa, nnz) self.data = a self.rowind = rowa self.indptr = ptra self.shape = (M, N) else: raise ValueError, "dense array must have rank 1 or 2" elif isspmatrix(arg1): s = arg1 self.dtype = getdtype(dtype, s) if isinstance(s, csc_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.rowind = s.rowind.copy() self.indptr = s.indptr.copy() else: self.data = s.data self.rowind = s.rowind self.indptr = s.indptr elif isinstance(s, csr_matrix): self.shape = s.shape func = getattr(sparsetools, s.ftype+'transp') self.data, self.rowind, self.indptr = \ func(s.shape[1], s.data, s.colind, s.indptr) else: temp = s.tocsc() self.data = temp.data self.rowind = temp.rowind self.indptr = temp.indptr self.shape = temp.shape elif type(arg1) == tuple: if isshape(arg1): self.dtype = getdtype(dtype, default=float) # It's a tuple of matrix dimensions (M, N) M, N = arg1 self.data = zeros((nzmax,), self.dtype) self.rowind = zeros((nzmax,), intc) self.indptr = zeros((N+1,), intc) self.shape = (M, N) else: try: # Try interpreting it as (data, ij) (s, ij) = arg1 assert isinstance(ij, ArrayType) and (rank(ij) == 2) and (shape(ij) == (len(s), 2)) except (AssertionError, TypeError, ValueError): try: # Try interpreting it as (data, rowind, indptr) (s, rowind, indptr) = arg1 self.dtype = getdtype(dtype, s) if copy: self.data = array(s) self.rowind = array(rowind) self.indptr = array(indptr) else: self.data = asarray(s) self.rowind = asarray(rowind) self.indptr = asarray(indptr) except: raise ValueError, "unrecognized form for csc_matrix constructor" else: # (data, ij) format self.dtype = getdtype(dtype, s) temp = coo_matrix((s, ij), dims=dims, dtype=dtype).tocsc() self.shape = temp.shape self.data = temp.data self.rowind = temp.rowind self.indptr = temp.indptr else: raise ValueError, "unrecognized form for csc_matrix constructor"
468f8a0f15a095ee7fdb71e85da826492ec51f0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/468f8a0f15a095ee7fdb71e85da826492ec51f0c/sparse.py
while True:
while True:
def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsr') b = other.data rowb = other.colind ptrb = other.indptr elif isinstance(other, csc_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr else: other = other.tocsc() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr a, b = _convert_data(a, b, dtypechar) newshape = (M, N) ptrc = zeros((N+1,), intc) nnzc = 2*max(ptra[-1], ptrb[-1]) c = zeros((nnzc,), dtypechar) rowc = zeros((nnzc,), intc) ierr = irow = kcol = 0 while True: c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, rowb, ptrb, c, rowc, ptrc, irow, kcol, ierr) if (ierr==0): break # otherwise we were too small and must resize # calculations continue where they left off... percent_to_go = 1- (1.0*kcol) / N newnnzc = int(ceil((1+percent_to_go)*nnzc)) c = resize1d(c, newnnzc) rowc = resize1d(rowc, newnnzc) nnzc = newnnzc return csc_matrix((c, rowc, ptrc), dims=(M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! return self.matmat(csc_matrix(other)) else: raise TypeError, "need a dense or sparse matrix"
468f8a0f15a095ee7fdb71e85da826492ec51f0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/468f8a0f15a095ee7fdb71e85da826492ec51f0c/sparse.py
def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsr') b = other.data rowb = other.colind ptrb = other.indptr elif isinstance(other, csc_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr else: other = other.tocsc() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr a, b = _convert_data(a, b, dtypechar) newshape = (M, N) ptrc = zeros((N+1,), intc) nnzc = 2*max(ptra[-1], ptrb[-1]) c = zeros((nnzc,), dtypechar) rowc = zeros((nnzc,), intc) ierr = irow = kcol = 0 while True: c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, rowb, ptrb, c, rowc, ptrc, irow, kcol, ierr) if (ierr==0): break # otherwise we were too small and must resize # calculations continue where they left off... percent_to_go = 1- (1.0*kcol) / N newnnzc = int(ceil((1+percent_to_go)*nnzc)) c = resize1d(c, newnnzc) rowc = resize1d(rowc, newnnzc) nnzc = newnnzc return csc_matrix((c, rowc, ptrc), dims=(M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! return self.matmat(csc_matrix(other)) else: raise TypeError, "need a dense or sparse matrix"
468f8a0f15a095ee7fdb71e85da826492ec51f0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/468f8a0f15a095ee7fdb71e85da826492ec51f0c/sparse.py
percent_to_go = 1- (1.0*kcol) / N
print "Resizing...", kcol, irow, ierr percent_to_go = 1- (1.0*kcol*M + irow) / (N*M)
def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsr') b = other.data rowb = other.colind ptrb = other.indptr elif isinstance(other, csc_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr else: other = other.tocsc() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _transtabl[dtypechar] func = getattr(sparsetools, ftype+'cscmucsc') b = other.data rowb = other.rowind ptrb = other.indptr a, b = _convert_data(a, b, dtypechar) newshape = (M, N) ptrc = zeros((N+1,), intc) nnzc = 2*max(ptra[-1], ptrb[-1]) c = zeros((nnzc,), dtypechar) rowc = zeros((nnzc,), intc) ierr = irow = kcol = 0 while True: c, rowc, ptrc, irow, kcol, ierr = func(M, a, rowa, ptra, b, rowb, ptrb, c, rowc, ptrc, irow, kcol, ierr) if (ierr==0): break # otherwise we were too small and must resize # calculations continue where they left off... percent_to_go = 1- (1.0*kcol) / N newnnzc = int(ceil((1+percent_to_go)*nnzc)) c = resize1d(c, newnnzc) rowc = resize1d(rowc, newnnzc) nnzc = newnnzc return csc_matrix((c, rowc, ptrc), dims=(M, N)) elif isdense(other): # This is SLOW! We need a more efficient implementation # of sparse * dense matrix multiplication! return self.matmat(csc_matrix(other)) else: raise TypeError, "need a dense or sparse matrix"
468f8a0f15a095ee7fdb71e85da826492ec51f0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/468f8a0f15a095ee7fdb71e85da826492ec51f0c/sparse.py
if amax(ravel(abs(new.imag))) == 0:
if abs(new.imag).max() == 0:
def toarray(self): new = zeros(self.shape, dtype=self.dtype) for key in self: ikey0 = int(key[0]) ikey1 = int(key[1]) new[ikey0, ikey1] = self[key] if amax(ravel(abs(new.imag))) == 0: new = new.real return new
468f8a0f15a095ee7fdb71e85da826492ec51f0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/468f8a0f15a095ee7fdb71e85da826492ec51f0c/sparse.py
slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd slice1[axis] = slice(1,None) slice2[axis] = slice(None,-1)
slice1 = tupleset((slice(None),)*nd, axis, slice(1, None)) slice2 = tupleset((slice(None),)*nd, axis, slice(None, -1))
def cumtrapz(y, x=None, dx=1.0, axis=-1): """Cumulatively integrate y(x) using samples along the given axis and the composite trapezoidal rule. If x is None, spacing given by dx is assumed. """ y = asarray(y) if x is None: d = dx else: d = diff(x,axis=axis) nd = len(y.shape) slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd slice1[axis] = slice(1,None) slice2[axis] = slice(None,-1) return add.accumulate(d * (y[slice1]+y[slice2])/2.0,axis)
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice0 = [slice(None)]*nd slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd
def _basic_simps(y,start,stop,x,dx,axis): nd = len(y.shape) slice0 = [slice(None)]*nd slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if start is None: start = 0 step = 2 slice0[axis] = slice(start,stop,step) slice1[axis] = slice(start+1,stop+1,step) slice2[axis] = slice(start+2,stop+2,step) if x is None: # Even spaced Simpson's rule. result = add.reduce(dx/3.0* (y[slice0]+4*y[slice1]+y[slice2]), axis) else: # Account for possibly different spacings. # Simpson's rule changes a bit. h = diff(x,axis=axis) sl0 = [slice(None)]*nd sl1 = [slice(None)]*nd sl0[axis] = slice(start,stop,step) sl1[axis] = slice(start+1,stop+1,step) h0 = h[sl0] h1 = h[sl1] hsum = h0 + h1 hprod = h0 * h1 h0divh1 = h0 / h1 result = add.reduce(hsum/6.0*(y[slice0]*(2-1.0/h0divh1) + \ y[slice1]*hsum*hsum/hprod + \ y[slice2]*(2-h0divh1)),axis) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice0[axis] = slice(start,stop,step) slice1[axis] = slice(start+1,stop+1,step) slice2[axis] = slice(start+2,stop+2,step)
all = (slice(None),)*nd slice0 = tupleset(all, axis, slice(start, stop, step)) slice1 = tupleset(all, axis, slice(start+1, stop+1, step)) slice2 = tupleset(all, axis, slice(start+2, stop+2, step))
def _basic_simps(y,start,stop,x,dx,axis): nd = len(y.shape) slice0 = [slice(None)]*nd slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if start is None: start = 0 step = 2 slice0[axis] = slice(start,stop,step) slice1[axis] = slice(start+1,stop+1,step) slice2[axis] = slice(start+2,stop+2,step) if x is None: # Even spaced Simpson's rule. result = add.reduce(dx/3.0* (y[slice0]+4*y[slice1]+y[slice2]), axis) else: # Account for possibly different spacings. # Simpson's rule changes a bit. h = diff(x,axis=axis) sl0 = [slice(None)]*nd sl1 = [slice(None)]*nd sl0[axis] = slice(start,stop,step) sl1[axis] = slice(start+1,stop+1,step) h0 = h[sl0] h1 = h[sl1] hsum = h0 + h1 hprod = h0 * h1 h0divh1 = h0 / h1 result = add.reduce(hsum/6.0*(y[slice0]*(2-1.0/h0divh1) + \ y[slice1]*hsum*hsum/hprod + \ y[slice2]*(2-h0divh1)),axis) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
sl0 = [slice(None)]*nd sl1 = [slice(None)]*nd sl0[axis] = slice(start,stop,step) sl1[axis] = slice(start+1,stop+1,step)
sl0 = tupleset(all, axis, slice(start, stop, step)) sl1 = tupleset(all, axis, slice(start+1, stop+1, step))
def _basic_simps(y,start,stop,x,dx,axis): nd = len(y.shape) slice0 = [slice(None)]*nd slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if start is None: start = 0 step = 2 slice0[axis] = slice(start,stop,step) slice1[axis] = slice(start+1,stop+1,step) slice2[axis] = slice(start+2,stop+2,step) if x is None: # Even spaced Simpson's rule. result = add.reduce(dx/3.0* (y[slice0]+4*y[slice1]+y[slice2]), axis) else: # Account for possibly different spacings. # Simpson's rule changes a bit. h = diff(x,axis=axis) sl0 = [slice(None)]*nd sl1 = [slice(None)]*nd sl0[axis] = slice(start,stop,step) sl1[axis] = slice(start+1,stop+1,step) h0 = h[sl0] h1 = h[sl1] hsum = h0 + h1 hprod = h0 * h1 h0divh1 = h0 / h1 result = add.reduce(hsum/6.0*(y[slice0]*(2-1.0/h0divh1) + \ y[slice1]*hsum*hsum/hprod + \ y[slice2]*(2-h0divh1)),axis) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd
slice1 = (slice(None),)*nd slice2 = (slice(None),)*nd
def simps(y, x=None, dx=1, axis=-1, even='avg'): """Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed. If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled as follows: even='avg': Average two results: 1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval even='first': Use Simpson's rule for the first N-2 intervals with a trapezoidal rule on the last interval. even='last': Use Simpson's rule for the last N-2 intervals with a trapezoidal rule on the first interval. For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less. """ y = asarray(y) nd = len(y.shape) N = y.shape[axis] last_dx = dx first_dx = dx returnshape = 0 if not x is None: x = asarray(x) if len(x.shape) == 1: shapex = ones(nd) shapex[axis] = x.shape[0] saveshape = x.shape returnshape = 1 x=x.reshape(tuple(shapex)) elif len(x.shape) != len(y.shape): raise ValueError, "If given, shape of x must be 1-d or the " \ "same as y." if x.shape[axis] != N: raise ValueError, "If given, length of x along axis must be the " \ "same as y." if N % 2 == 0: val = 0.0 result = 0.0 slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if not even in ['avg', 'last', 'first']: raise ValueError, \ "Parameter 'even' must be 'avg', 'last', or 'first'." # Compute using Simpson's rule on first intervals if even in ['avg', 'first']: slice1[axis] = -1 slice2[axis] = -2 if not x is None: last_dx = x[slice1] - x[slice2] val += 0.5*last_dx*(y[slice1]+y[slice2]) result = _basic_simps(y,0,N-3,x,dx,axis) # Compute using Simpson's rule on last set of intervals if even in ['avg', 'last']: slice1[axis] = 0 slice2[axis] = 1 if not x is None: first_dx = x[slice2] - x[slice1] val += 0.5*first_dx*(y[slice2]+y[slice1]) result += _basic_simps(y,1,N-2,x,dx,axis) if even == 'avg': val /= 2.0 result /= 2.0 result = result + val else: result = _basic_simps(y,0,N-2,x,dx,axis) if returnshape: x = x.reshape(saveshape) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice1[axis] = -1 slice2[axis] = -2
slice1 = tupleset(slice1, axis, -1) slice2 = tupleset(slice2, axis, -2)
def simps(y, x=None, dx=1, axis=-1, even='avg'): """Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed. If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled as follows: even='avg': Average two results: 1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval even='first': Use Simpson's rule for the first N-2 intervals with a trapezoidal rule on the last interval. even='last': Use Simpson's rule for the last N-2 intervals with a trapezoidal rule on the first interval. For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less. """ y = asarray(y) nd = len(y.shape) N = y.shape[axis] last_dx = dx first_dx = dx returnshape = 0 if not x is None: x = asarray(x) if len(x.shape) == 1: shapex = ones(nd) shapex[axis] = x.shape[0] saveshape = x.shape returnshape = 1 x=x.reshape(tuple(shapex)) elif len(x.shape) != len(y.shape): raise ValueError, "If given, shape of x must be 1-d or the " \ "same as y." if x.shape[axis] != N: raise ValueError, "If given, length of x along axis must be the " \ "same as y." if N % 2 == 0: val = 0.0 result = 0.0 slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if not even in ['avg', 'last', 'first']: raise ValueError, \ "Parameter 'even' must be 'avg', 'last', or 'first'." # Compute using Simpson's rule on first intervals if even in ['avg', 'first']: slice1[axis] = -1 slice2[axis] = -2 if not x is None: last_dx = x[slice1] - x[slice2] val += 0.5*last_dx*(y[slice1]+y[slice2]) result = _basic_simps(y,0,N-3,x,dx,axis) # Compute using Simpson's rule on last set of intervals if even in ['avg', 'last']: slice1[axis] = 0 slice2[axis] = 1 if not x is None: first_dx = x[slice2] - x[slice1] val += 0.5*first_dx*(y[slice2]+y[slice1]) result += _basic_simps(y,1,N-2,x,dx,axis) if even == 'avg': val /= 2.0 result /= 2.0 result = result + val else: result = _basic_simps(y,0,N-2,x,dx,axis) if returnshape: x = x.reshape(saveshape) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice1[axis] = 0 slice2[axis] = 1
slice1 = tupleset(slice1, axis, 0) slice2 = tupleset(slice2, axis, 1)
def simps(y, x=None, dx=1, axis=-1, even='avg'): """Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed. If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled as follows: even='avg': Average two results: 1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval even='first': Use Simpson's rule for the first N-2 intervals with a trapezoidal rule on the last interval. even='last': Use Simpson's rule for the last N-2 intervals with a trapezoidal rule on the first interval. For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less. """ y = asarray(y) nd = len(y.shape) N = y.shape[axis] last_dx = dx first_dx = dx returnshape = 0 if not x is None: x = asarray(x) if len(x.shape) == 1: shapex = ones(nd) shapex[axis] = x.shape[0] saveshape = x.shape returnshape = 1 x=x.reshape(tuple(shapex)) elif len(x.shape) != len(y.shape): raise ValueError, "If given, shape of x must be 1-d or the " \ "same as y." if x.shape[axis] != N: raise ValueError, "If given, length of x along axis must be the " \ "same as y." if N % 2 == 0: val = 0.0 result = 0.0 slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if not even in ['avg', 'last', 'first']: raise ValueError, \ "Parameter 'even' must be 'avg', 'last', or 'first'." # Compute using Simpson's rule on first intervals if even in ['avg', 'first']: slice1[axis] = -1 slice2[axis] = -2 if not x is None: last_dx = x[slice1] - x[slice2] val += 0.5*last_dx*(y[slice1]+y[slice2]) result = _basic_simps(y,0,N-3,x,dx,axis) # Compute using Simpson's rule on last set of intervals if even in ['avg', 'last']: slice1[axis] = 0 slice2[axis] = 1 if not x is None: first_dx = x[slice2] - x[slice1] val += 0.5*first_dx*(y[slice2]+y[slice1]) result += _basic_simps(y,1,N-2,x,dx,axis) if even == 'avg': val /= 2.0 result /= 2.0 result = result + val else: result = _basic_simps(y,0,N-2,x,dx,axis) if returnshape: x = x.reshape(saveshape) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
first_dx = x[slice2] - x[slice1]
first_dx = x[tuple(slice2)] - x[tuple(slice1)]
def simps(y, x=None, dx=1, axis=-1, even='avg'): """Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed. If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled as follows: even='avg': Average two results: 1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval even='first': Use Simpson's rule for the first N-2 intervals with a trapezoidal rule on the last interval. even='last': Use Simpson's rule for the last N-2 intervals with a trapezoidal rule on the first interval. For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less. """ y = asarray(y) nd = len(y.shape) N = y.shape[axis] last_dx = dx first_dx = dx returnshape = 0 if not x is None: x = asarray(x) if len(x.shape) == 1: shapex = ones(nd) shapex[axis] = x.shape[0] saveshape = x.shape returnshape = 1 x=x.reshape(tuple(shapex)) elif len(x.shape) != len(y.shape): raise ValueError, "If given, shape of x must be 1-d or the " \ "same as y." if x.shape[axis] != N: raise ValueError, "If given, length of x along axis must be the " \ "same as y." if N % 2 == 0: val = 0.0 result = 0.0 slice1 = [slice(None)]*nd slice2 = [slice(None)]*nd if not even in ['avg', 'last', 'first']: raise ValueError, \ "Parameter 'even' must be 'avg', 'last', or 'first'." # Compute using Simpson's rule on first intervals if even in ['avg', 'first']: slice1[axis] = -1 slice2[axis] = -2 if not x is None: last_dx = x[slice1] - x[slice2] val += 0.5*last_dx*(y[slice1]+y[slice2]) result = _basic_simps(y,0,N-3,x,dx,axis) # Compute using Simpson's rule on last set of intervals if even in ['avg', 'last']: slice1[axis] = 0 slice2[axis] = 1 if not x is None: first_dx = x[slice2] - x[slice1] val += 0.5*first_dx*(y[slice2]+y[slice1]) result += _basic_simps(y,1,N-2,x,dx,axis) if even == 'avg': val /= 2.0 result /= 2.0 result = result + val else: result = _basic_simps(y,0,N-2,x,dx,axis) if returnshape: x = x.reshape(saveshape) return result
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice0 = [slice(None)]*nd slice0[axis] = 0 slicem1 = [slice(None)]*nd slicem1[axis] = -1
all = (slice(None),) * nd slice0 = tupleset(all, axis, 0) slicem1 = tupleset(all, axis, -1)
def romb(y, dx=1.0, axis=-1, show=0): """Uses Romberg integration to integrate y(x) using N samples along the given axis which are assumed equally spaced with distance dx. The number of samples must be 1 + a non-negative power of two: N=2**k + 1 """ y = asarray(y) nd = len(y.shape) Nsamps = y.shape[axis] Ninterv = Nsamps-1 n = 1 k = 0 while n < Ninterv: n <<= 1 k += 1 if n != Ninterv: raise ValueError, \ "Number of samples must be one plus a non-negative power of 2." R = {} slice0 = [slice(None)]*nd slice0[axis] = 0 slicem1 = [slice(None)]*nd slicem1[axis] = -1 h = Ninterv*asarray(dx)*1.0 R[(1,1)] = (y[slice0] + y[slicem1])/2.0*h slice_R = [slice(None)]*nd start = stop = step = Ninterv for i in range(2,k+1): start >>= 1 slice_R[axis] = slice(start,stop,step) step >>= 1 R[(i,1)] = 0.5*(R[(i-1,1)] + h*add.reduce(y[slice_R],axis)) for j in range(2,i+1): R[(i,j)] = R[(i,j-1)] + \ (R[(i,j-1)]-R[(i-1,j-1)]) / ((1 << (2*(j-1)))-1) h = h / 2.0 if show: if not isscalar(R[(1,1)]): print "*** Printing table only supported for integrals" + \ " of a single data set." else: try: precis = show[0] except (TypeError, IndexError): precis = 5 try: width = show[1] except (TypeError, IndexError): width = 8 formstr = "%" + str(width) + '.' + str(precis)+'f' print "\n Richardson Extrapolation Table for Romberg Integration " print "====================================================================" for i in range(1,k+1): for j in range(1,i+1): print formstr % R[(i,j)], print print "====================================================================\n" return R[(k,k)]
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice_R = [slice(None)]*nd
slice_R = all
def romb(y, dx=1.0, axis=-1, show=0): """Uses Romberg integration to integrate y(x) using N samples along the given axis which are assumed equally spaced with distance dx. The number of samples must be 1 + a non-negative power of two: N=2**k + 1 """ y = asarray(y) nd = len(y.shape) Nsamps = y.shape[axis] Ninterv = Nsamps-1 n = 1 k = 0 while n < Ninterv: n <<= 1 k += 1 if n != Ninterv: raise ValueError, \ "Number of samples must be one plus a non-negative power of 2." R = {} slice0 = [slice(None)]*nd slice0[axis] = 0 slicem1 = [slice(None)]*nd slicem1[axis] = -1 h = Ninterv*asarray(dx)*1.0 R[(1,1)] = (y[slice0] + y[slicem1])/2.0*h slice_R = [slice(None)]*nd start = stop = step = Ninterv for i in range(2,k+1): start >>= 1 slice_R[axis] = slice(start,stop,step) step >>= 1 R[(i,1)] = 0.5*(R[(i-1,1)] + h*add.reduce(y[slice_R],axis)) for j in range(2,i+1): R[(i,j)] = R[(i,j-1)] + \ (R[(i,j-1)]-R[(i-1,j-1)]) / ((1 << (2*(j-1)))-1) h = h / 2.0 if show: if not isscalar(R[(1,1)]): print "*** Printing table only supported for integrals" + \ " of a single data set." else: try: precis = show[0] except (TypeError, IndexError): precis = 5 try: width = show[1] except (TypeError, IndexError): width = 8 formstr = "%" + str(width) + '.' + str(precis)+'f' print "\n Richardson Extrapolation Table for Romberg Integration " print "====================================================================" for i in range(1,k+1): for j in range(1,i+1): print formstr % R[(i,j)], print print "====================================================================\n" return R[(k,k)]
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
slice_R[axis] = slice(start,stop,step)
slice_R = tupleset(slice_R, slice(start,stop,step))
def romb(y, dx=1.0, axis=-1, show=0): """Uses Romberg integration to integrate y(x) using N samples along the given axis which are assumed equally spaced with distance dx. The number of samples must be 1 + a non-negative power of two: N=2**k + 1 """ y = asarray(y) nd = len(y.shape) Nsamps = y.shape[axis] Ninterv = Nsamps-1 n = 1 k = 0 while n < Ninterv: n <<= 1 k += 1 if n != Ninterv: raise ValueError, \ "Number of samples must be one plus a non-negative power of 2." R = {} slice0 = [slice(None)]*nd slice0[axis] = 0 slicem1 = [slice(None)]*nd slicem1[axis] = -1 h = Ninterv*asarray(dx)*1.0 R[(1,1)] = (y[slice0] + y[slicem1])/2.0*h slice_R = [slice(None)]*nd start = stop = step = Ninterv for i in range(2,k+1): start >>= 1 slice_R[axis] = slice(start,stop,step) step >>= 1 R[(i,1)] = 0.5*(R[(i-1,1)] + h*add.reduce(y[slice_R],axis)) for j in range(2,i+1): R[(i,j)] = R[(i,j-1)] + \ (R[(i,j-1)]-R[(i-1,j-1)]) / ((1 << (2*(j-1)))-1) h = h / 2.0 if show: if not isscalar(R[(1,1)]): print "*** Printing table only supported for integrals" + \ " of a single data set." else: try: precis = show[0] except (TypeError, IndexError): precis = 5 try: width = show[1] except (TypeError, IndexError): width = 8 formstr = "%" + str(width) + '.' + str(precis)+'f' print "\n Richardson Extrapolation Table for Romberg Integration " print "====================================================================" for i in range(1,k+1): for j in range(1,i+1): print formstr % R[(i,j)], print print "====================================================================\n" return R[(k,k)]
704696cd1cef533b4e608563919a4d4ce035a41b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/704696cd1cef533b4e608563919a4d4ce035a41b/quadrature.py
argument 'n' indicates the number of rows (observations).
argument 'nrow' indicates the number of rows (observations).
def __call__(self, *args, **kw):
6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf/formula.py
elif nrow <= 1:
elif nrow <= 1:
def __call__(self, *args, **kw):
6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf/formula.py
allvals = I(nrow=nrow)
allvals = I(nrow=nrow)
def __call__(self, *args, **kw):
6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6b8747cc05d30f8fdf74d465a68286f5b4d1cfdf/formula.py
if (nzmax>0) and (max(self.rowind[:nnz]) >= M):
if (nzmax < nnz): raise ValueError, "Nzmax must not be less than nnz." if (nnz>0) and (max(self.rowind[:nnz]) >= M):
def _check(self): M,N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind)
40c0a6da933b8818f7693a49ace1b684ee2f68a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/40c0a6da933b8818f7693a49ace1b684ee2f68a1/Sparse.py
if (len(self.colind)>0) and (max(self.colind) >= N):
if (nzmax < nnz): raise ValueError, "Nzmax must not be less than nnz." if (nnz>0) and (max(self.colind[:nnz]) >= M):
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) != M+1): raise ValueError, "Index pointer should be of length #rows + 1" if (len(self.colind)>0) and (max(self.colind) >= N): raise ValueError, "Column-values must be < N." if (self.indptr[-1] > len(self.colind)): raise ValueError, \ "Last value of index list should be less than "\ "the size of data list" self.nnz = self.indptr[-1] self.nzmax = len(self.colind) self.typecode = self.data.typecode() if self.typecode not in 'fdFD': self.typecode = 'd' self.data = self.data.astype('d') self.ftype = _transtabl[self.typecode]
40c0a6da933b8818f7693a49ace1b684ee2f68a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/40c0a6da933b8818f7693a49ace1b684ee2f68a1/Sparse.py
"""Minimze Description: Optimize the function, f, whose gradient is given by fprime using the
"""Description: Minimize the function, f, whose gradient is given by fprime using the
def fmin_ncg(f, x0, fprime, fhess_p=None, fhess=None, args=(), avextol=1e-5, maxiter=None, full_output=0, disp=1): """Minimze Description: Optimize the function, f, whose gradient is given by fprime using the Newton-CG method. fhess_p must compute the hessian times an arbitrary vector. If it is not given, finite-differences on fprime are used to compute it. See Wright, and Nocedal 'Numerical Optimization', 1999, pg. 140. Inputs: f -- the Python function or method to be minimized. x0 -- the initial guess for the minimizer. fprime -- a function to compute the gradient of f: fprime(x, *args) fhess_p -- a function to compute the Hessian of f times an arbitrary vector: fhess_p (x, p, *args) fhess -- a function to compute the Hessian matrix of f. args -- extra arguments for f, fprime, fhess_p, and fhess (the same set of extra arguments is supplied to all of these functions). Outputs: (xopt, {fopt, fcalls, gcalls, hcalls, warnflag}) xopt -- the minimizer of f fopt -- the value of the function at xopt: fopt = f(xopt) fcalls -- the number of function calls. gcalls -- the number of gradient calls. hcalls -- the number of hessian calls. warnflag -- algorithm warnings: 1 : 'Maximum number of iterations exceeded.' Additional Inputs: avextol -- Convergence is assumed when the average relative error in the minimizer falls below this amount. maxiter -- Maximum number of iterations to allow. full_output -- If non-zero return the optional outputs. disp -- If non-zero print convergence message. Remarks: Only one of fhess_p or fhess need be given. If fhess is provided, then fhess_p will be ignored. If neither fhess nor fhess_p is provided, then the hessian product will be approximated using finite differences on fprime. """ x0 = asarray(x0) fcalls = 0 gcalls = 0 hcalls = 0 if maxiter is None: maxiter = len(x0)*200 xtol = len(x0)*avextol update = [2*xtol] xk = x0 k = 0 while (Num.add.reduce(abs(update)) > xtol) and (k < maxiter): # Compute a search direction pk by applying the CG method to # del2 f(xk) p = - grad f(xk) starting from 0. b = -apply(fprime,(xk,)+args) gcalls = gcalls + 1 maggrad = Num.add.reduce(abs(b)) eta = min([0.5,Num.sqrt(maggrad)]) termcond = eta * maggrad xsupi = 0 ri = -b psupi = -ri i = 0 dri0 = Num.dot(ri,ri) if fhess is not None: # you want to compute hessian once. A = apply(fhess,(xk,)+args) hcalls = hcalls + 1 while Num.add.reduce(abs(ri)) > termcond: if fhess is None: if fhess_p is None: Ap = apply(approx_fhess_p,(xk,psupi,fprime)+args) gcalls = gcalls + 2 else: Ap = apply(fhess_p,(xk,psupi)+args) hcalls = hcalls + 1 else: Ap = Num.dot(A,psupi) # check curvature curv = Num.dot(psupi,Ap) if (curv <= 0): if (i > 0): break else: xsupi = xsupi + dri0/curv * psupi break alphai = dri0 / curv xsupi = xsupi + alphai * psupi ri = ri + alphai * Ap dri1 = Num.dot(ri,ri) betai = dri1 / dri0 psupi = -ri + betai * psupi i = i + 1 dri0 = dri1 # update Num.dot(ri,ri) for next time. pk = xsupi # search direction is solution to system. gfk = -b # gradient at xk alphak, fc, gc = line_search_BFGS(f,xk,pk,gfk,args) fcalls = fcalls + fc gcalls = gcalls + gc update = alphak * pk xk = xk + update k = k + 1 if disp or full_output: fval = apply(f,(xk,)+args) if k >= maxiter: warnflag = 1 if disp: print "Warning: Maximum number of iterations has been exceeded" print " Current function value: %f" % fval print " Iterations: %d" % k print " Function evaluations: %d" % fcalls print " Gradient evaluations: %d" % gcalls print " Hessian evaluations: %d" % hcalls else: warnflag = 0 if disp: print "Optimization terminated successfully." print " Current function value: %f" % fval print " Iterations: %d" % k print " Function evaluations: %d" % fcalls print " Gradient evaluations: %d" % gcalls print " Hessian evaluations: %d" % hcalls if full_output: return xk, fval, fcalls, gcalls, hcalls, warnflag else: return xk
a63dd27d75aee7baf1a6851a2867c8ab0ecce2ed /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/a63dd27d75aee7baf1a6851a2867c8ab0ecce2ed/optimize.py
save_file = './saved_values.py' if not os.path.exists(save_file): save_file = '../saved_values.py'
x11_info = get_x11_info() if not x11_info: return
def configuration(parent_package=''): """ gist only works with an X-windows server This will install *.gs and *.gp files to '%spython%s/site-packages/scipy/xplt' % (sys.prefix,sys.version[:3]) """ # Check for X11 libraries save_file = './saved_values.py' if not os.path.exists(save_file): save_file = '../saved_values.py' try: exec(open(save_file).read()) try: X11 = X11 except NameError: X11 = check_and_save() except IOError: X11 = check_and_save() if X11: config = default_config_dict() if parent_package: parent_package = parent_package + '.' local_path = get_path(__name__) config['packages'].append(parent_package+'xplt') from scipy_distutils.core import Extension sources = ['gistCmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(parent_package+'xplt.gistC', sources, include_dirs = ['/usr/include/X11'], library_dirs = ['/usr/X11R6/lib'], libraries = ['X11','m']) config['ext_modules'].append(ext) from glob import glob gist = glob(os.path.join(local_path,'gist','*.c')) # libraries are C static libraries config['libraries'].append(('gist',{'sources':gist, 'macros':[('STDC_HEADERS',1)]})) file_ext = ['*.gs','*.gp', '*.ps', '*.help'] xplt_files = [glob(os.path.join(local_path,x)) for x in file_ext] xplt_files = reduce(lambda x,y:x+y,xplt_files,[]) xplt_path = os.path.join(local_path,'xplt') config['data_files'].extend( [(xplt_path,xplt_files)]) return config
31e157edcd789970d7fb0cb71695464a27e75d3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/31e157edcd789970d7fb0cb71695464a27e75d3c/setup_xplt.py
try: exec(open(save_file).read()) try: X11 = X11 except NameError: X11 = check_and_save() except IOError: X11 = check_and_save() if X11: config = default_config_dict()
config = default_config_dict('xplt',parent_package) local_path = get_path(__name__) sources = ['gistCmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(dot_join(parent_package,'xplt.gistC'), sources, include_dirs = x11_info.get('include_dirs',[]), library_dirs = x11_info.get('library_dirs',[]), libraries = x11_info.get('libraries',[]) + ['m']) config['ext_modules'].append(ext) from glob import glob gist = glob(os.path.join(local_path,'gist','*.c')) config['libraries'].append(('gist',{'sources':gist, 'macros':[('STDC_HEADERS',1)]})) file_ext = ['*.gs','*.gp', '*.ps', '*.help'] xplt_files = [glob(os.path.join(local_path,x)) for x in file_ext] xplt_files = reduce(lambda x,y:x+y,xplt_files,[]) xplt_path = os.path.join(local_path,'xplt') config['data_files'].extend( [(xplt_path,xplt_files)]) return config
def configuration(parent_package=''): """ gist only works with an X-windows server This will install *.gs and *.gp files to '%spython%s/site-packages/scipy/xplt' % (sys.prefix,sys.version[:3]) """ # Check for X11 libraries save_file = './saved_values.py' if not os.path.exists(save_file): save_file = '../saved_values.py' try: exec(open(save_file).read()) try: X11 = X11 except NameError: X11 = check_and_save() except IOError: X11 = check_and_save() if X11: config = default_config_dict() if parent_package: parent_package = parent_package + '.' local_path = get_path(__name__) config['packages'].append(parent_package+'xplt') from scipy_distutils.core import Extension sources = ['gistCmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(parent_package+'xplt.gistC', sources, include_dirs = ['/usr/include/X11'], library_dirs = ['/usr/X11R6/lib'], libraries = ['X11','m']) config['ext_modules'].append(ext) from glob import glob gist = glob(os.path.join(local_path,'gist','*.c')) # libraries are C static libraries config['libraries'].append(('gist',{'sources':gist, 'macros':[('STDC_HEADERS',1)]})) file_ext = ['*.gs','*.gp', '*.ps', '*.help'] xplt_files = [glob(os.path.join(local_path,x)) for x in file_ext] xplt_files = reduce(lambda x,y:x+y,xplt_files,[]) xplt_path = os.path.join(local_path,'xplt') config['data_files'].extend( [(xplt_path,xplt_files)]) return config
31e157edcd789970d7fb0cb71695464a27e75d3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/31e157edcd789970d7fb0cb71695464a27e75d3c/setup_xplt.py
if parent_package: parent_package = parent_package + '.' local_path = get_path(__name__) config['packages'].append(parent_package+'xplt') from scipy_distutils.core import Extension sources = ['gistCmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(parent_package+'xplt.gistC', sources, include_dirs = ['/usr/include/X11'], library_dirs = ['/usr/X11R6/lib'], libraries = ['X11','m']) config['ext_modules'].append(ext) from glob import glob gist = glob(os.path.join(local_path,'gist','*.c')) config['libraries'].append(('gist',{'sources':gist, 'macros':[('STDC_HEADERS',1)]})) file_ext = ['*.gs','*.gp', '*.ps', '*.help'] xplt_files = [glob(os.path.join(local_path,x)) for x in file_ext] xplt_files = reduce(lambda x,y:x+y,xplt_files,[]) xplt_path = os.path.join(local_path,'xplt') config['data_files'].extend( [(xplt_path,xplt_files)]) return config def check_and_save(file='saved_values.py'): import commands output = commands.getoutput('find /usr -name "libX11*" -print') X11 = (output != '') fid = open(file,'a') fid.write('X11 = %d\n' % X11) fid.close() return X11
if __name__ == '__main__': from scipy_distutils.core import setup setup(**configuration())
def configuration(parent_package=''): """ gist only works with an X-windows server This will install *.gs and *.gp files to '%spython%s/site-packages/scipy/xplt' % (sys.prefix,sys.version[:3]) """ # Check for X11 libraries save_file = './saved_values.py' if not os.path.exists(save_file): save_file = '../saved_values.py' try: exec(open(save_file).read()) try: X11 = X11 except NameError: X11 = check_and_save() except IOError: X11 = check_and_save() if X11: config = default_config_dict() if parent_package: parent_package = parent_package + '.' local_path = get_path(__name__) config['packages'].append(parent_package+'xplt') from scipy_distutils.core import Extension sources = ['gistCmodule.c'] sources = [os.path.join(local_path,x) for x in sources] ext = Extension(parent_package+'xplt.gistC', sources, include_dirs = ['/usr/include/X11'], library_dirs = ['/usr/X11R6/lib'], libraries = ['X11','m']) config['ext_modules'].append(ext) from glob import glob gist = glob(os.path.join(local_path,'gist','*.c')) # libraries are C static libraries config['libraries'].append(('gist',{'sources':gist, 'macros':[('STDC_HEADERS',1)]})) file_ext = ['*.gs','*.gp', '*.ps', '*.help'] xplt_files = [glob(os.path.join(local_path,x)) for x in file_ext] xplt_files = reduce(lambda x,y:x+y,xplt_files,[]) xplt_path = os.path.join(local_path,'xplt') config['data_files'].extend( [(xplt_path,xplt_files)]) return config
31e157edcd789970d7fb0cb71695464a27e75d3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/31e157edcd789970d7fb0cb71695464a27e75d3c/setup_xplt.py
pass
def check_basic(self):
2d2964b0362ae2bdda2dfd5cdb7fa1f254a400f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/2d2964b0362ae2bdda2dfd5cdb7fa1f254a400f2/test_stats.py
cond = 1-isnan(arr1d) x = sort(compress(cond,arr1d)) return median(x)
cond = 1-isnan(arr1d) x = sort(compress(cond,arr1d)) return median(x)
def _nanmedian(arr1d): # This only works on 1d arrays cond = 1-isnan(arr1d) x = sort(compress(cond,arr1d)) return median(x)
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
"""Returns several descriptive statistics of the passed array. Axis can equal None (ravel array first), or an integer (the axis over which to operate) Returns: n, (min,max), mean, standard deviation, skew, kurtosis """ a, axis = _chk_asarray(a, axis) n = a.shape[axis] mm = (minimum.reduce(a),maximum.reduce(a)) m = mean(a,axis) v = var(a,axis) sk = skew(a,axis) kurt = kurtosis(a,axis) return n, mm, m, v, sk, kurt
"""Returns several descriptive statistics of the passed array. Axis can equal None (ravel array first), or an integer (the axis over which to operate) Returns: n, (min,max), mean, standard deviation, skew, kurtosis """ a, axis = _chk_asarray(a, axis) n = a.shape[axis] mm = (minimum.reduce(a),maximum.reduce(a)) m = mean(a,axis) v = var(a,axis) sk = skew(a,axis) kurt = kurtosis(a,axis) return n, mm, m, v, sk, kurt
def describe(a,axis=0): """Returns several descriptive statistics of the passed array. Axis can equal None (ravel array first), or an integer (the axis over which to operate) Returns: n, (min,max), mean, standard deviation, skew, kurtosis """ a, axis = _chk_asarray(a, axis) n = a.shape[axis] mm = (minimum.reduce(a),maximum.reduce(a)) m = mean(a,axis) v = var(a,axis) sk = skew(a,axis) kurt = kurtosis(a,axis) return n, mm, m, v, sk, kurt
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
""" RESTRICTS NOTHING (i.e., FULL MODEL CALCULATION). Subtracts D-variable cell-mean for each between-subj group and then calculates the SS array. """ workd = subtr_cellmeans(workd,subjslots) sserr = multivar_SScalc(workd) return sserr
""" RESTRICTS NOTHING (i.e., FULL MODEL CALCULATION). Subtracts D-variable cell-mean for each between-subj group and then calculates the SS array. """ workd = subtr_cellmeans(workd,subjslots) sserr = multivar_SScalc(workd) return sserr
def d_full_model(workd,subjslots): """ RESTRICTS NOTHING (i.e., FULL MODEL CALCULATION). Subtracts D-variable
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
""" RESTRICTS GRAND MEA Subtracts D-variable cell-mean for each between- subj group, and then adds back each D-variable's grand mean. """ errors = subtr_cellmeans(workd,subjslots) grandDmeans = expand_dims(mean(workd,0),0) errors = errors + transpose(grandDmeans) sserr = multivar_SScalc(errors) return sserr
""" RESTRICTS GRAND MEA Subtracts D-variable cell-mean for each between- subj group, and then adds back each D-variable's grand mean. """ errors = subtr_cellmeans(workd,subjslots) grandDmeans = expand_dims(mean(workd,0),0) errors = errors + transpose(grandDmeans) sserr = multivar_SScalc(errors) return sserr
def d_restrict_mean(workd,subjslots): """ RESTRICTS GRAND MEA Subtracts D-variable cell-mean for each between-
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
"""
"""
def d_restrict_source(workd,subjslots,source): """
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
global D if source > 0: sourcewithins = (source-1) & Bwithins sourcebetweens = (source-1) & Bbetweens dindex = Bwonly_sources.index(sourcewithins) all_cellmeans = transpose(DM[dindex],[-1]+range(0,len(DM[dindex].shape)-1)) all_cellns = transpose(DN[dindex],[-1]+range(0,len(DN[dindex].shape)-1)) hn = hmean(all_cellns, None) levels = D[dindex].shape[1] SSm = zeros((levels,levels),'f') tworkd = transpose(D[dindex]) RSw = zeros((levels,levels),'f') RSinter = zeros((levels,levels),PyObject) for i in range(levels): for j in range(i,levels): RSw[i,j] = RSw[j,i] = sum(tworkd[i]*tworkd[j]) cross = all_cellmeans[i] * all_cellmeans[j] multfirst = sum(cross*all_cellns[i]) RSinter[i,j] = RSinter[j,i] = asarray(multfirst) SSm[i,j] = SSm[j,i] = (mean(all_cellmeans[i],None) *
global D if source > 0: sourcewithins = (source-1) & Bwithins sourcebetweens = (source-1) & Bbetweens dindex = Bwonly_sources.index(sourcewithins) all_cellmeans = transpose(DM[dindex],[-1]+range(0,len(DM[dindex].shape)-1)) all_cellns = transpose(DN[dindex],[-1]+range(0,len(DN[dindex].shape)-1)) hn = hmean(all_cellns, None) levels = D[dindex].shape[1] SSm = zeros((levels,levels),'f') tworkd = transpose(D[dindex]) RSw = zeros((levels,levels),'f') RSinter = zeros((levels,levels),PyObject) for i in range(levels): for j in range(i,levels): RSw[i,j] = RSw[j,i] = sum(tworkd[i]*tworkd[j]) cross = all_cellmeans[i] * all_cellmeans[j] multfirst = sum(cross*all_cellns[i]) RSinter[i,j] = RSinter[j,i] = asarray(multfirst) SSm[i,j] = SSm[j,i] = (mean(all_cellmeans[i],None) *
def d_restrict_source(workd,subjslots,source): """
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py
def d_restrict_source(workd,subjslots,source): """
3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py