Experimental package Gapjm.jl porting some GAP functionality to Julia

I put on
github.com/jmichel7/Gapjm.jl

my first efforts porting some functionality provided by the GAP programming language to Julia.
What I have now is permutations and permutation groups, cyclotomic numbers and Laurent polynomials. Coming soon are Coxeter groups, Hecke algebras, braid groups and Garside monoids.

I learned both Julia and github just a few months ago, so be indulgent – though I welcome all kinds of constructive criticsm: I not even sure what I put up is a proper Julia package, since I had trouble finding an
explanation step by step how to make a package aimed at a beginner like me.

I wanted to see if it is reasonable to think of porting a system like GAP to Julia. The first test is positive: similar functionality and performance with much less code when porting the underlying C code, and even a bit less
code when porting the GAP code. However one piece is missing: in GAP there is only one kind of numbers, which starting as Int64 seamlessly become BigInt, Rationals or Cyclotomics, and are very efficient (with the trick that a bit is set apart in Int64s to tell if it is a real Int or a boxed value). It should be possible to write such a type in Julia but it has not been done (and it is out of my competence for the near future at least). For now a solution like SafeIntegers might be the best which exists.
To give some perspective, in some tests I made BigInts used for a computation where most Ints are “small”
and only a few overflow is 200 times slower than GAP numbers (while SafeIntegers are roughly the same speed).

2 Likes

A quick look at your Gapjm.jl file:

push!(LOAD_PATH, @__DIR__) # not sure if this is the right way to use modules

is not needed, see this part of the Pkg doc, basically you should do something like follows in your REPL

] # enter package mode
dev https://github.com/jmichel7/Gapjm.jl

Also

  • there are no tests?
  • would it not be simpler to find if it was just called GAP.jl?

Your pointer to Pkg doc does not work. I needed to extend LOAD_PATH otherwise the submodules Perms, etc in my package are not found.

I wanted to put first as tests what appears as julia-repl in my docstrings, however I could not see how to make Documenter.jl do that: it wants rather what appears as ‘jldoctest’. Is there a way to use the examples in my docstrings as tests?

Finally I called my package Gapjm and not Gap because I know some other people may be working on Gap-related packages.

how about includeing all the files instead of extending LOAD_PATH?

jldoctests appear in the documentation exactly as julia-repl but are run only when the documentation is build

(link fixed, apologies, you may also want to consider https://docs.julialang.org/en/v1.0/manual/modules/#Relative-and-absolute-module-paths-1 as per issue posted on your repo)

What I would like is for a runtests.jl to be made automatically from thejulia-repl in my docstrings. Is there something which can do that?

Can you show me how would look the file Gapjm.jl? I did not manage to write something which works without error.

And same question to @tlienart

@Jean_Michel for the paths, please see https://github.com/jmichel7/Gapjm.jl/issues/2. Note the use of using .Util in Gapjm.jl and using ..Util in Perms.jl for instance.

first You need to fix Your deps;

then use include("Util.jl") and Gapjm.Util.degree(x) = ...

after You include(“Util.jl”) inside Gapjm module it is only in Gapjm scope, not in Gapjm.Perms, etc.

Thanks, I merged your PR