Godtone (talk | contribs)
m →My Python 3 code: minor correction to avoid unnecessary spam in output
Godtone (talk | contribs)
→My Python 3 code: temp coordinates and interval mappings (using cents for this for now as i didnt want to make the code too complex/didnt wanna generalise prematurely and using other measurements can be done manually still using "temp_gen_iv" and "steps")
Line 944: Line 944:
)
)
return currentharmonics
return currentharmonics
# below is not well tested! consider yourself warned.
def scalar_mul_fact( s, f ):
return [ s*entry for entry in f ]
def temp_coord_iv( tmp, gens, x ):
monzo = convert(x,list)
return mul_fact(*[ scalar_mul_fact(monzo[i],tmp[i]) for i in range(len(monzo)) ])
def temp_gen_iv( tmp, gens, x ):
return sum([ temp_coord_iv(tmp,gens,x)[i]*gens[i] for i in range(len(gens)) ])
def temp_max_err( tmp, gens, ol ):
worstiv = (1,1)
maxerr = 0.0
for x in ol:
e = temp_gen_iv( tmp, gens, x ) - steps(as_float(x),ed(1200))
if abs(e) > abs(maxerr):
maxerr = e
worstiv = x
print(striv(worstiv),str(maxerr)+'c')
def temp_err( tmp, gens, ol ):
worstupperiv = (1,1)
maxerr = 0.0
worstloweriv = (1,1)
minerr = 0.0
for x in ol:
e = temp_gen_iv( tmp, gens, x ) - steps(as_float(x),ed(1200))
if e > maxerr:
maxerr = e
worstupperiv = x
if e < minerr:
minerr = e
worstloweriv = x
print( striv(worstupperiv), str(maxerr)+'c' )
print( striv(worstloweriv), '-'+str(-minerr)+'c' )
</syntaxhighlight>
</syntaxhighlight>