Class SymContext

java.lang.Object
jline.util.symbolic.SymContext

public final class SymContext extends Object
The ordered variable set a family of SymExpr values shares.

Rings fixes the number of indeterminates when the ring is built, so every expression that is to be added or multiplied has to come from ONE context. That is what this class owns: the names, their positions, and the two Rings objects derived from them.

THE FIELD IS THE FIELD OF RATIONAL FUNCTIONS over Q, not a polynomial ring, because the gld recursion divides. Every divisor there is a bare mu symbol, so a denominator is always a monomial and the normal form Rings keeps is already the smallest one; nothing here has to call gcd for correctness.

Names are compared literally and are the strings the caller printed them with, so a round trip through SymExpr.toString() names the same symbols the caller supplied. Copyright (c) 2012-2026, Imperial College London All rights reserved.

  • Method Details

    • of

      public static SymContext of(String... names)
      A context over the given variable names, in the order given.
      Parameters:
      names - the variable names, each distinct
      Returns:
      the context
    • of

      public static SymContext of(List<String> names)
      A context over the given variable names, in the order given.
      Parameters:
      names - the variable names, each distinct
      Returns:
      the context
    • var

      public SymExpr var(String name)
      The variable of the given name as an expression.
      Parameters:
      name - a name this context was built with
      Returns:
      the variable
    • constant

      public SymExpr constant(long v)
      An exact integer constant.
      Parameters:
      v - the value
      Returns:
      the constant
    • rational

      public SymExpr rational(long num, long den)
      An exact rational constant.
      Parameters:
      num - numerator
      den - denominator, non-zero
      Returns:
      the constant
    • constant

      public SymExpr constant(double v)
      A double carried in EXACTLY, as the dyadic rational it already is.

      No rounding happens here and none is wanted: a demand written 0.1 in the caller's source is the double nearest 0.1, and turning it into the rational 1/10 would answer for a model the caller did not state. The same rule the C++ num_traits<Rational>::from_double follows.

      Parameters:
      v - the value, finite
      Returns:
      the constant
    • zero

      public SymExpr zero()
      Returns:
      zero in this context
    • one

      public SymExpr one()
      Returns:
      one in this context
    • names

      public List<String> names()
      Returns:
      the variable names, in ring order
    • positionOf

      public int positionOf(String name)
      Returns:
      the position of a variable in ring order, or -1
    • ring

      public cc.redberry.rings.poly.MultivariateRing<cc.redberry.rings.poly.multivar.MultivariatePolynomial<cc.redberry.rings.bigint.BigInteger>> ring()
      Returns:
      the underlying polynomial ring
    • field

      public cc.redberry.rings.Rationals<cc.redberry.rings.poly.multivar.MultivariatePolynomial<cc.redberry.rings.bigint.BigInteger>> field()
      Returns:
      the underlying field of rational functions