Creation Functions

Contents

Creation of Structures

The ring of integers is automatically created when Magma is first loaded. The ring may be formally created (and, if desired, assigned to a variable) using the function IntegerRing(). Subrings of Z are always ideals; see the section on ideals for details.

IntegerRing() : -> RngInt
Integers() : -> RngInt
RingOfIntegers() : -> RngInt
IntegerRing(Q) : FldRat -> RngInt
Integers(Q) : FldRat -> RngInt
RingOfIntegers(Q) : FldRat -> RngInt
Create the ring of integers Z.

Creation of Elements

Since the ring of integers is present when Magma is started up, integers typed into Magma without any explicit context will be regarded as elements of the ring of integers. Integers can be specified using both decimal and hexadecimal notation.

One(Z) : RngInt -> RngIntElt
Identity(Z) : RngInt -> RngIntElt
Zero(Z) : RngInt -> RngIntElt
Representative(Z) : RngInt -> RngIntElt

These generic functions create 1, 1, 0, and 0 respectively, in the integer ring Z.

a1a2...ar
Given a succession of decimal digits a1, ..., ar, create the corresponding integer. Leading zeros will be ignored.
0xa1a2...ar
Given a succession of hexadecimal digits a1, ..., ar, create the corresponding integer. Leading zeros will be ignored.
elt< Z | a1a2...ar > : RngInt, RngIntElt -> RngIntElt
Given a succession of decimal digits a1, ..., ar, create the corresponding integer as an element of Z.
elt< Z | 0xa1a2...ar > : RngInt, RngIntElt -> RngIntElt
Given a succession of hexadecimal digits a1, ..., ar, create the corresponding integer as an element of Z.
Z ! a : RngInt, RngElt -> RngIntElt
Z ! [a] : RngInt, [RngElt] -> RngIntElt
Coerce the ring element a into the ring of integers Z. The element a is allowed to be an element of the ring of integers modulo m (in which case the result r satisfies 0 ≤r < m), or an element of a finite field (in which case the result r satisfies 0 ≤r < p if a is in the prime field, of characteristic p, and an error otherwise), or an element of the integers, rationals, a quadratic field, a cyclotomic field or a number field (in which cases the result is the obvious integer if a is integral and an error otherwise).

Example RngInt_Integers (H19E2)

> Z := IntegerRing();
> n := 1234567890;
> n in Z;
true
> m := elt< Z | 1234567890 >;
> m eq n;
true
> l := Z ! elt< QuadraticField(3) | 1234567890, 0>;
> l;
1234567890
> k := elt< Z | 0x499602D2 >;
1234567890

Printing of Elements

Magma supports the printing of integers in both decimal and hexadecimal form. The default print method is to print integers in base 10; base 16 printing is performed using the Hex print level.

Example RngInt_Printing (H19E3)

> n := 1234567890;
> n;
1234567890
> n:Hex;
0x499602D2

Element Conversions

FactorizationToInteger(s) : [ <RngIntElt, RngIntElt> ] -> RngIntElt
FactorisationToInteger(s) : [ <RngIntElt, RngIntElt> ] -> RngIntElt
Facint(s) : [ <RngIntElt, RngIntElt> ] -> RngIntElt
Given a sequence of two-element tuples s=[ <p1, k1>, ..., <pr, kr> ] containing pairs of integers <pi, ki>, 1 ≤i ≤r, with ki non-negative, this function returns the integer p1k1 ... prkr. It is normally used for converting a factorization sequence to the corresponding integer.
IntegerToSequence(n, b) : RngIntElt, RngIntElt -> [RngIntElt]
Intseq(n, b) : RngIntElt, RngIntElt -> [RngIntElt]
Given a non-negative integer n and a positive integer b≥2, return the unique base b representation of n in the form of a sequence Q. That is, if n = a0b0 + a1b1 + ... + ak - 1bk - 1 with 0≤ai<b and ak - 1> 0, then Q = [ a0, a1, ..., ak - 1 ]. (If n=0, then Q=[ ].)
SequenceToInteger(s, b) : [RngIntElt], RngIntElt -> RngIntElt
Seqint(s, b) : [RngIntElt], RngIntElt -> RngIntElt
Given a positive integer b≥2 and a sequence Q = [ a0, ..., ak - 1 ] of non-negative integers such that 0 ≤ai < b, return the integer n = a0b0 + a1b1 + ... + ak - 1bk - 1. If Q is the empty sequence, the integer zero is returned. This function performs the inverse operation of the base b representation.
IntegerToString(n) : RngIntElt -> ModStgElt
Create the string consisting of the decimal digits of the integer n. In the case in which n is negative the first character will be the minus sign.
IntegerToString(n, b) : RngIntElt, RngIntElt -> ModStgElt
Create the string consisting of the digits of the integer n in base b. In the case in which n is negative the first character will be the minus sign. The base b can be between 2 and 36. For b ≤10, the digits are represented numerically. For b > 10, the digits are represented both numerically and alphabetically, so that, 10 is `A', 11 is `B', et cetera.
Eltseq(n) : RngIntElt -> [RngIntElt]
The sequence [n] which can be coerced back into Z.
Denominator(n) : RngIntElt -> RngIntElt
The denominator of n, ie. 1.
V2.28, 13 July 2023