[docs]defroots_rB(c,constraint):ifpoly_constraints.even_real<=constraint:assertnp.all(c[::2].imag==0)ifpoly_constraints.odd_real<=constraint:assertnp.all(c[1::2].imag==0)ifpoly_constraints.odd_imag<=constraint:assertnp.all(c[1::2].real==0)ifpoly_constraints.no_constraint==constraint:rvec=roots(c)rB=RBalgo.expect(rvec,constraint=root_constraints.no_constraint)elifpoly_constraints.eRoR==constraint:rvec=roots(c)rB=RBalgo.expect(rvec,constraint=root_constraints.mirror_real)elifpoly_constraints.eRoI==constraint:rvec=roots(c)rB=RBalgo.expect(rvec,constraint=root_constraints.mirror_imag,allow_unknown=True)iflen(rB.u)>0:warnings.warn("Unmirrored root in mirror_imag polynomial root finder (need to upgrade this algorithm)")# HACK# clear any unknownrB.u=np.array([])elifpoly_constraints.eRoZ==constraint:rvec=roots(c)rB=RBalgo.expect(rvec,constraint=root_constraints.mirror_quad)returnrB
[docs]defval_lnG(X,c,lnG=0):# the LOG2 is because the last coefficient is assumed to be scaled to one (as is done in fromroots)lnG_out=-(len(c)-2)*log2returnnp.polynomial.chebyshev.chebval(X,c),lnG+lnG_out
[docs]defvander_lnG(X,N,lnG=0):# the LOG2 is because the last coefficient is assumed to be scaled to one (as is done in fromroots)lnG_out=-(N-1)*log2returnnp.polynomial.chebyshev.chebvander(X,N),lnG+lnG_out