-
Notifications
You must be signed in to change notification settings - Fork 181
Add conversion methods between OSCAR and HomotopyContinuation as a julia extension #5758
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
base: master
Are you sure you want to change the base?
Changes from 14 commits
9080b1b
3c68a5e
446babf
87ee070
f8e7c26
f6808b0
58ea098
d73d186
5d8acf3
e7dacae
45e5b2f
e92a698
5c8476f
4da3ff3
3a8e38c
f0f6253
123f89c
0765bf2
7e58c76
5c3fbde
0f9e7f9
9891b41
c1e2cc9
9507e9b
c3b5fc7
0894cc9
742b0ab
716c2ee
d61ab7f
818beac
ed5158c
1403729
4eaa37d
323a1e1
d7fc8d4
1bd6c71
232b556
40d4c33
2510158
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -364,6 +364,51 @@ jobs: | |||
| with: | ||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||
|
|
||||
| exts: | ||||
| runs-on: ${{ matrix.os }} | ||||
| continue-on-error: ${{ contains(matrix.julia-version, 'nightly') }} | ||||
| timeout-minutes: 60 | ||||
| strategy: | ||||
| fail-fast: false | ||||
| matrix: | ||||
| julia-version: | ||||
| - '1.10' | ||||
| - '1.12' | ||||
| - '1.13-nightly' | ||||
| - 'nightly' | ||||
| os: ['ubuntu-latest'] | ||||
| env: | ||||
| OSCAR_TEST_SUBSET: "exts" | ||||
| steps: | ||||
| - uses: actions/checkout@v6 | ||||
| - name: "Set up Julia" | ||||
| uses: julia-actions/setup-julia@v2 | ||||
|
thofma marked this conversation as resolved.
Outdated
|
||||
| with: | ||||
| version: ${{ matrix.julia-version }} | ||||
| - uses: julia-actions/cache@v2 | ||||
|
thofma marked this conversation as resolved.
Outdated
|
||||
| with: | ||||
| cache-name: julia-cache;workflow=${{ github.workflow }};julia=${{ matrix.julia-version }};arch=${{ runner.arch }} | ||||
| include-matrix: false | ||||
| cache-scratchspaces: false | ||||
| - name: "Inject HomotopyContinuation as test dependencies" | ||||
| continue-on-error: true | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I don't see how a sed command could fail
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copied the work flow for the dependency injections for Hecke.jl @benlorenz any opinions here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it can be removed but it doesn't hurt either.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok let's keep it |
||||
| run: | | ||||
| sed -i -e "s/\[deps\]/[deps]\nHomotopyContinuation = \"f213a82b-91d6-5c5d-acf7-10f1c761b327\"/" test/Project.toml | ||||
| - uses: julia-actions/julia-runtest@v1 | ||||
| with: | ||||
| annotate: ${{ matrix.julia-version == '1.10' }} | ||||
| coverage: ${{ matrix.julia-version == '1.10' }} | ||||
| - name: "Process code coverage" | ||||
| if: matrix.julia-version == '1.10' | ||||
| uses: julia-actions/julia-processcoverage@v1 | ||||
| with: | ||||
| directories: src,experimental | ||||
| - name: "Upload coverage data to Codecov" | ||||
| if: matrix.julia-version == '1.10' | ||||
| continue-on-error: true | ||||
| uses: codecov/codecov-action@v5 | ||||
|
thofma marked this conversation as resolved.
Outdated
|
||||
| with: | ||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||
|
thofma marked this conversation as resolved.
|
||||
|
|
||||
| # adapted from gap-system/gap | ||||
| slack-notification: | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| module HomotopyContinuationExt | ||
|
|
||
| using Oscar, HomotopyContinuation | ||
|
|
||
| import HomotopyContinuation: HomotopyContinuation, Variable | ||
|
|
||
| """ | ||
| Expression(f::MPolyRingElem) | ||
|
|
||
| Takes a polynomial `f` an `MPolyRingElem` and converts it into a | ||
| `HomotopyContinuation.Expression`. The `HomotopyContinuation.Variable` | ||
| objects used in the expression have the same names as the generators | ||
| in the `parent(f)` (including brackets as in `x[1]`). | ||
| """ | ||
| function HomotopyContinuation.Expression(f::MPolyRingElem) | ||
| # Get a list of HomotopyContinuation variables whose names are the | ||
| # same as the ones in the Oscar polynomial f. | ||
| v = Variable.(symbols(parent(f))) | ||
| # Make the HomotopyContinuation expression | ||
| sum(Float64(c) * prod(v[i]^e for (i,e) in enumerate(a)) for (c,a) in coefficients_and_exponents(f)) | ||
| end | ||
|
|
||
| """ | ||
| System(I::MPolyIdeal; args...) | ||
|
|
||
| Takes an `MPolyIdeal` and turns it into a `HomotopyContinuation.System` | ||
| containing the ideal generators. It forwards all `args` to `HomotopyContinuation.System`. | ||
| """ | ||
| HomotopyContinuation.System(I::MPolyIdeal; args...) = HomotopyContinuation.System(Expression.(gens(I)); args...) | ||
|
|
||
| """ | ||
| solve(I::MPolyIdeal; args...) | ||
|
|
||
| Call `HomotopyContinuation.solve` on the `HomotopyContinuation.System` derived | ||
| from `I` forwarding all `args`. | ||
| """ | ||
| HomotopyContinuation.solve(I::MPolyIdeal; show_progress=false, args...) = HomotopyContinuation.solve(HomotopyContinuation.System(I); show_progress, args...) | ||
|
|
||
| HomotopyContinuation.witness_set(I::MPolyIdeal; show_progress=false, args...) = HomotopyContinuation.witness_set(HomotopyContinuation.System(I); show_progress, args...) | ||
|
|
||
| """ | ||
| dim(I::MPolyIdeal) | ||
|
|
||
| Compute the dimension of `I` numerically. | ||
| """ | ||
| function HomotopyContinuation.dim(I::MPolyIdeal) | ||
| # This is provided by HomotopyContinuation.jl and computes the | ||
| # dimension based on the Jacobian rank at a random point. | ||
| F = HomotopyContinuation.System(I) | ||
| return HomotopyContinuation.nvariables(F) - rank(HomotopyContinuation.fixed(F)) | ||
| end | ||
|
|
||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using HomotopyContinuation | ||
|
antonydellavecchia marked this conversation as resolved.
Outdated
|
||
|
|
||
| @testset "Extensions" begin | ||
|
antonydellavecchia marked this conversation as resolved.
|
||
| @testset "HomotopyContinuation" begin | ||
| Qxy, (x, y) = QQ[:x, :y] | ||
| I = ideal([x^2 - x * y + y^3, y^2 - x - 4//5]) | ||
| @test iszero(HomotopyContinuation.dim(I)) | ||
| result = Oscar.nsolve(I) | ||
|
lgoettgens marked this conversation as resolved.
Outdated
|
||
| @test [r.multiplicity for r in result.path_results] == [1, 1, 1, 1] | ||
|
|
||
| J = ideal([x^2 - x * y + y^3]) | ||
| ws = Oscar.witness_set(J) | ||
|
lgoettgens marked this conversation as resolved.
Outdated
|
||
| @test length(ws.R) == 3 | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.