You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
951 B

2 months ago
  1. from . import _config
  2. if not _config.CARL_WITH_CLN:
  3. raise ImportError("CLN is not available in the configured carl library! Did you configure carl with -DUSE_CLN_NUMBERS=ON?")
  4. from . import cln
  5. from .cln import *
  6. def numerator(x):
  7. if type(x) == cln.RationalFunction or type(x) == cln.Rational or type(x) == cln.FactorizedRationalFunction:
  8. return x.numerator
  9. else:
  10. return x
  11. def denominator(x):
  12. if type(x) == cln.RationalFunction or type(x) == cln.Rational or type(x) == cln.FactorizedRationalFunction:
  13. return x.denominator
  14. else:
  15. return 1
  16. def expand(x):
  17. if type(x) == cln.FactorizedRationalFunction:
  18. return x.rational_function()
  19. if type(x) == cln.FactorizedPolynomial:
  20. return x.polynomial()
  21. return x
  22. factorization_cache = cln._FactorizationCache()
  23. def create_factorized_polynomial(polynomial):
  24. return cln.FactorizedPolynomial(polynomial, factorization_cache)