-
Notifications
You must be signed in to change notification settings - Fork 292
Added the Subring package #3736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fragandi
wants to merge
35
commits into
Macaulay2:development
Choose a base branch
from
fragandi:master
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e2e4fba
Added the Subring package
fragandi f1f3aa0
typos handled. Still need to resolve the issue with directory structure
fragandi 2564a4a
Merge branch 'development' into master
fragandi 2b35a8a
directory structure is fixed
fragandi c5e7721
paths fixed
fragandi ce9c38d
renamed package Subring -> Subrings
mahrud c81444a
deleted .vscode/settings.json
mahrud c6774f2
added link to SubalgebraBases in Subrings
mahrud 308d007
fixed auxiliary file paths in Subrings
mahrud 98da806
set AuxiliaryFiles for Subrings
mahrud b38618a
Merge branch 'Macaulay2:stable' into master
fragandi 6d807f5
Add workflow to build and push testbot Docker image
d-torrance 1a37f6f
Trust the Macaulay2 Homebrew tap
d-torrance fdf5ff2
Merge branch 'Macaulay2:stable' into master
ollieclarke8787 287c51b
cache subring in matrix
ollieclarke8787 79bc995
update Subring to handle towers of rings
ollieclarke8787 c9bb90c
fix M -> genMatrix
ollieclarke8787 9785924
fix subring opts
ollieclarke8787 0dd0ba9
add options for subring(List)
ollieclarke8787 7332fd8
fix isSubringElement to work with towers of rings
ollieclarke8787 6624403
fix indentation
ollieclarke8787 149d940
clean up comment
ollieclarke8787 89210ef
add test for tower of rings
ollieclarke8787 69c567b
TODO: rewrite isSubringElement to use hooks for future-proofing
ollieclarke8787 2f4dcb4
export Subring type
ollieclarke8787 b4777fe
add flattenRing Subring
ollieclarke8787 7b061ac
clean Subring doc
ollieclarke8787 ce6a670
clean spacing
ollieclarke8787 27ee670
use hooks for subring membership
ollieclarke8787 67170be
fix doc for flattenedRing
ollieclarke8787 2c5af3e
add flattenedRing doc
ollieclarke8787 1492759
add tests
ollieclarke8787 571b39c
use Subring in SubalgebraBases
ollieclarke8787 7b8351d
Update M2/Macaulay2/packages/Subrings.m2
ollieclarke8787 6b67548
Update package headline
ollieclarke8787 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "githubPullRequests.ignoredPullRequestBranches": [ | ||
| "master" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| -- -*- coding: utf-8 -*- | ||
| newPackage( | ||
| "Subring", | ||
| Version => "1.0", | ||
| Date => "June 6, 2023", | ||
| Authors => { | ||
| {Name => "Francesca Gandini", Email => "fra.gandi.phd@gmail.com"}, | ||
| {Name => "Casey Hill", Email => "casey.hill@uky.edu"}, | ||
| {Name => "Trevor K. Karn", Email => "karnx018@umn.edu"}, | ||
| {Name => "Miranda Moore", Email => "moor2340@umn.edu"}, | ||
| {Name => "Christopher O'Neill", Email => "cdoneill@sdsu.edu"}}, | ||
| Headline => "a package for subrings", | ||
| Keywords => {"Commutative Algebra"}, | ||
| ) | ||
|
|
||
|
|
||
| export {"subring", | ||
| "subringGenerators", | ||
| "presentationRing", | ||
| "presentationMap", | ||
| "presentationIdeal", | ||
| "toQuotientRing", | ||
| "isSubringElement"} | ||
|
|
||
| Subring = new Type of HashTable | ||
|
|
||
| -- a method to create subrings from a `Matrix` of generators | ||
| subring = method() | ||
| subring Matrix := genMatrix -> ( | ||
|
|
||
| -- compute presentation ring | ||
| R := ring genMatrix; | ||
| nGens := numgens source genMatrix; | ||
| k := coefficientRing R; | ||
| p := symbol p; | ||
| P := k[p_0..p_(nGens-1)]; | ||
|
|
||
| -- compute presentation map | ||
| f := map(R, P, genMatrix); | ||
|
|
||
| S := new Subring from { | ||
| generators => genMatrix, | ||
| ambient => R, | ||
|
|
||
| -- presentation ring: one variable for each generator | ||
| presentationRing => P, | ||
|
|
||
| -- presentation map: presentation ring --> ambient ring, image(f)=S | ||
| presentationMap => f, | ||
|
|
||
| cache => new CacheTable | ||
| }; | ||
| S | ||
| ) | ||
|
|
||
| -- a method to create subrings from a `List` of generators | ||
| subring List := genList -> ( | ||
| subring matrix {genList} | ||
| ) | ||
|
|
||
| presentationRing = method() | ||
| presentationRing Subring := S -> ( | ||
| S#presentationRing | ||
| ) | ||
|
|
||
| presentationMap = method() | ||
| presentationMap Subring := S -> ( | ||
| S#presentationMap | ||
| ) | ||
|
|
||
| presentationIdeal = method() | ||
| presentationIdeal Subring := S -> ( | ||
| f := presentationMap S; | ||
| return ker f; --kernel is cached automatically | ||
| ) | ||
|
|
||
| -- a quotient ring isomorphic to the image of the subring inside of the presentation ring | ||
| toQuotientRing = method() | ||
| toQuotientRing Subring := S -> ( | ||
| P := presentationRing S; | ||
| I := presentationIdeal S; | ||
| return P/I; | ||
| ) | ||
|
|
||
| subringGenerators = method() | ||
| subringGenerators Subring := S -> S#generators | ||
|
|
||
| generators Subring := Matrix => opts -> S -> ( | ||
| if S#?generators then S#generators | ||
| else if S.cache.?generators then S.cache.generators | ||
| else S.cache.generators = S#generators) | ||
|
|
||
| ambient Subring := S -> S#ambient | ||
|
|
||
| -- format printing of Subring type | ||
| net Subring := S -> ( | ||
| R := ambient S; | ||
| P := presentationRing S; | ||
| g := flatten entries S#generators; | ||
| genstr := ""; | ||
| if #g <= 3 then ( | ||
| genstr = toString(g_{0 .. min(2, #g-1)}); | ||
| ) else ( | ||
| genstr = "{" | toString(g_0) | ", " | toString(g_1) | ", " | toString(g_2) | ", ...}"; | ||
| ); | ||
|
|
||
| "Subring of " | toString(R) | " generated by " | genstr | " with presentation ring " | toString(P) | ||
| ) | ||
|
|
||
| -- given a subring S and an element x of the ambient ring, checks whether x is in S | ||
| isSubringElement = method() | ||
| isSubringElement(RingElement, Subring) := (r, S) -> ( | ||
| R := ambient S; | ||
| P := presentationRing S; | ||
| T := tensor(R, P, MonomialOrder=>Eliminate(numgens R)); | ||
| gT := vars T; | ||
| R2T := map(T, R, gT_{0 .. numgens R - 1}); | ||
| P2T := map(T, P, gT_{numgens R .. numgens T - 1}); | ||
| ambGens := gens R; | ||
| subringGens := subringGenerators S; | ||
| presGens := gens P; | ||
| graphIdealGens := for i from 0 to (-1 + numgens P) list | ||
| (P2T(presGens_i) - R2T(subringGens_i)_0); | ||
| I := ideal graphIdealGens; | ||
| M := matrix {{R2T(r) % I}}; | ||
| selectInSubring(1, M) == M | ||
| ) | ||
|
|
||
| -- equality of Subrings | ||
| -- check that every generator of S1 is in S2 and every generator of S2 is in S1 | ||
| Subring == Subring := (S1, S2) -> ( | ||
| if not (ambient S1) === (ambient S2) then return false; | ||
| all(entries(subringGenerators S1)_0, f -> isSubringElement(f, S2)) and all(entries(subringGenerators S2)_0, f -> isSubringElement(f, S1)) | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| -* | ||
|
|
||
| -- given an element of S, write it in terms of the p_i's | ||
|
|
||
| *- | ||
|
|
||
| ----------------------------------------- | ||
| --- Load documentation files ------------ | ||
| ----------------------------------------- | ||
| beginDocumentation() | ||
|
|
||
| load "./Subring/SubringDoc.m2" | ||
| load "./Subring/SubringTests.m2" | ||
|
|
||
| end-- | ||
|
|
||
| restart | ||
| installPackage "Subring" | ||
| R = QQ[x] | ||
| S1 = subring {x, x^2} | ||
| S2 = subring {x^2} | ||
| S3 = subring {x} | ||
| S1 == S3 --true | ||
| S1 == S2 --false | ||
|
|
||
| net S3 | ||
|
|
||
| mingens S1 | ||
| presentationRing S1 | ||
| mingens | ||
|
|
||
| gens S1 | ||
|
|
||
| -- run tests | ||
| check Subring | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.