Skip to content

Commit

Permalink
added LMonNP, LTermNP, LTermsNP; FactorOutGcdNP (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdwensley authored Jul 4, 2024
1 parent 1c0d51b commit 1938ac9
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 42 deletions.
43 changes: 40 additions & 3 deletions doc/examples/functions.g
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,26 @@ PrintNPList(List(LMonsNP(Lnp), q -> [[q],[1]]));

# <#/GAPDoc>

# <#GAPDoc Label="example-LTermNP">
# <E>Example:</E>
# We put two polynomials in NP format into the list <C>Lnp</C>.
# <L>
p1 := [[[1,1,2],[1]],[6,-7]];;
p2 := [[[1,2,2],[2]],[8,-9]];;
Lnp := [p1,p2];;
# </L>

# The leading term of a polynomial is returned by <C>LTermNP</C>,
# and the list of leading terms is computed by <C>LTermsNP</C>:

# <L>
LTermNP(p1);
LTnp := LTermsNP( Lnp );
PrintNPList( LTnp );
# </L>

# <#/GAPDoc>

# <#GAPDoc Label="example-MkMonicNP">
# <E>Example:</E>
# Consider the following polynomial in NP format.
Expand All @@ -479,13 +499,30 @@ p := [[[1,1,2],[]],[2,-1]];;
PrintNP(p);
# </L>

# The coefficient of the leading term is <M>2</M>. The function <C>MkMonicNP</C> finds
# this coefficient and divides all terms by it:

# The coefficient of the leading term is <M>2</M>.
# The function <C>MkMonicNP</C> finds this coefficient
# and divides every term by it:
# <L>
PrintNP(MkMonicNP(p));
# </L>
# <#/GAPDoc>

# <#GAPDoc Label="example-FactorOutGcdNP">
# <E>Example:</E>
# Consider the following polynomial in NP format.
# <L>
p := [[[1,1,2],[1,2],[1]],[30,70,105]];;
PrintNP(p);
# </L>

# The <C>Gcd</C> of the coefficients <M>[30,70,105]</M> is <M>5</M>.
# The function <C>FactorOutGcdNP</C> divides the polynomial by <M>5</M>:

# <L>
PrintNP(FactorOutGcdNP(p));
m := MkMonicNP(p);
#</L>
fm := FactorOutGcdNP(m);
# <#/GAPDoc>


Expand Down
52 changes: 50 additions & 2 deletions doc/examples/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,30 @@ gap> PrintNPList(List(LMonsNP(Lnp), q -> [[q],[1]]));

<#/GAPDoc>

<#GAPDoc Label="example-LTermNP">
<E>Example:</E>
We put two polynomials in NP format into the list <C>Lnp</C>.
<Listing><![CDATA[
gap> p1 := [[[1,1,2],[1]],[6,-7]];;
gap> p2 := [[[1,2,2],[2]],[8,-9]];;
gap> Lnp := [p1,p2];;
]]></Listing>

The leading term of a polynomial is returned by <C>LTermNP</C>,
and the list of leading terms is computed by <C>LTermsNP</C>:

<Listing><![CDATA[
gap> LTermNP(p1);
[ [ 1, 1, 2 ], [ 6 ] ]
gap> LTnp := LTermsNP( Lnp );
[ [ [ [ 1, 1, 2 ] ], [ 6 ] ], [ [ [ 1, 2, 2 ] ], [ 8 ] ] ]
gap> PrintNPList( LTnp );
6a^2b
8ab^2
]]></Listing>

<#/GAPDoc>

<#GAPDoc Label="example-MkMonicNP">
<E>Example:</E>
Consider the following polynomial in NP format.
Expand All @@ -529,8 +553,9 @@ gap> PrintNP(p);
2a^2b - 1
]]></Listing>

The coefficient of the leading term is <M>2</M>. The function <C>MkMonicNP</C> finds
this coefficient and divides all terms by it:
The coefficient of the leading term is <M>2</M>.
The function <C>MkMonicNP</C> finds this coefficient
and divides every term by it:

<Listing><![CDATA[
gap> PrintNP(MkMonicNP(p));
Expand All @@ -539,6 +564,29 @@ gap> PrintNP(MkMonicNP(p));

<#/GAPDoc>

<#GAPDoc Label="example-FactorOutGcdNP">
<E>Example:</E>
Consider the following polynomial in NP format.
<Listing><![CDATA[
gap> p := [[[1,1,2],[1,2],[1]],[30,70,105]];;
gap> PrintNP(p);
30a^2b + 70ab + 105a
]]></Listing>

The <C>Gcd</C> of the coefficients <M>[30,70,105]</M> is <M>5</M>.
The function <C>FactorOutGcdNP</C> divides the polynomial by <M>5</M>:

<Listing><![CDATA[
gap> PrintNP(FactorOutGcdNP(p));
6a^2b + 14ab + 21a
gap> m := MkMonicNP(p);
[ [ [ 1, 1, 2 ], [ 1, 2 ], [ 1 ] ], [ 1, 7/3, 7/2 ] ]
gap> fm := FactorOutGcdNP(m);
fail
]]></Listing>

<#/GAPDoc>


<#GAPDoc Label="example-MulNP">
<E>Example:</E>
Expand Down
2 changes: 2 additions & 0 deletions doc/gbnp_doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ algebra with the same growth).
<#Include Label="GtNP">
<#Include Label="LtNP">
<#Include Label="LMonsNP"> <!-- here ?? -->
<#Include Label="LTermsNP">
<#Include Label="MkMonicNP">
<#Include Label="FactorOutGcdNP">
<#Include Label="MulNP">
</Section>
<Section Label="grobner"><Heading>Gröbner functions, standard variant</Heading>
Expand Down
4 changes: 4 additions & 0 deletions lib/nparith.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@

DeclareGlobalFunction("LtNP");
DeclareGlobalFunction("GtNP");
DeclareGlobalFunction("LMonNP");
DeclareGlobalFunction("LMonsNP");
DeclareGlobalFunction("LTermNP");
DeclareGlobalFunction("LTermsNP");
DeclareGlobalFunction("CleanNP");
DeclareGlobalFunction("MkMonicNP");
DeclareGlobalFunction("FactorOutGcdNP");
DeclareGlobalFunction("AddNP");
DeclareGlobalFunction("MulNP");
DeclareGlobalFunction("BimulNP");
Expand Down
Loading

0 comments on commit 1938ac9

Please sign in to comment.