Constructing mathematical objects in Nemo
Constructing objects in Julia
In Julia, one constructs objects of a given type by calling a type constructor. This is simply a function with the same name as the type itself. For example, to construct a BigInt
object in Julia, we simply call the BigInt
constructor:
n = BigInt("1234567898765434567898765434567876543456787654567890")
Julia also uses constructors to convert between types. For example, to convert an Int
to a BigInt
:
m = BigInt(123)
How we construct objects in Nemo
As we explained in the previous section, Julia types don't contain enough information to properly model the ring of integers modulo for a multiprecision modulus . Instead of using types to construct objects, we use special objects that we refer to as parent objects. They behave a lot like Julia types.
Consider the following simple example, to create a Flint multiprecision integer:
n = ZZ("12345678765456787654567890987654567898765678909876567890")
Here ZZ
is not a Julia type, but a callable object. However, for most purposes one can think of such a parent object ZZ
as though it were a type.
Constructing parent objects
For more complicated groups, rings, fields, etc., one first needs to construct the parent object before one can use it to construct element objects.
Nemo provides a set of functions for constructing such parent objects. For example, to create a parent object for polynomials over the integers, we use the PolynomialRing
parent object constructor.
R, x = PolynomialRing(ZZ, "x")
f = x^3 + 3x + 1
g = R(12)
In this example, R
is the parent object and we use it to convert the Int
value to an element of the polynomial ring .
List of parent object constructors
For convenience, we provide a list of all the parent object constructors in Nemo and explain what domains they represent.
Mathematics  Nemo constructor 

R = ZZ 

R = QQ 

R, a = FiniteField(p, n, "a") 

R = ResidueRing(ZZ, n) 

S, x = PolynomialRing(R, "x") 

(to precision )  S, x = PowerSeriesRing(R, n, "x") 
S = FractionField(R) 

S = ResidueRing(R, f) 

S = MatrixSpace(R, m, n) 

S, a = NumberField(f, "a") 

S = MaximalOrder(K) 

ideal of  I = Ideal(O, gens, ...) 