Skip to content
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

add set_randomseed to libsingular_julia #680

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions deps/src/singular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ JLCXX_MODULE define_julia_module(jlcxx::Module & Singular)
return old_mu;
});

Singular.method("set_randomseed", [](int m) {
int old_m=siSeed;
if (m != 0)
{
siSeed=m;
factoryseed(m);
}
return old_m;
});

Singular.method("random", []() {
return siRand();
});

singular_define_coeffs(Singular);
singular_define_rings(Singular);
singular_define_ideals(Singular);
Expand Down
6 changes: 6 additions & 0 deletions test/caller-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,9 @@ end
GC.gc(true)
@test length(string(a)) > 2
end

@testset "random" begin
Singular.libSingular.set_randomseed(1)
@test Singular.libSingular.random() == 16807
@test Singular.libSingular.random() == 282475249
end