A humble request/challenge

Hi

I primarly use Ruby for math/science problems/projects because it’s so easy to program in, and it allows me to think about how to solve problems without worrying about how to code it. I’ve also played around with Crystal (aka Ruby on steroids) but it’s still young, and doesn’t let me (currently) do what I want, or without a lot of hassles, and I’ve just recently started looking at Nim (less than a month at time of writing).

I’ve been following Elixir for sometime but didn’t know if it was useful for heavy math alogirithms, but I was encouraged to ask anyway.

I developed a prime sieve called the Sieve of Zakiya (SoZ), and it’s companion the Segmented Sieve of Zakiya (SSoZ). I wrote a paper, The Segmented Sieve of Zakiya (SSoZ) which describes its mathematical foundations and algorithm, and provide a working C++ implementation at the end of the paper (compiled, run, and verified), though I don’t consider myself a C++ programmer, just funcitonal enough in it. It’s a relatively short program.

Here’s a link to read and download the paper:

My humble request/challenge is for a/some skilled Elixian(?) to translate the code into idiomatic Elixir to demonstrate the best way to code the algorithm in it. Extra points if someone can do a true parallel version of the algorithm, which I attempted to do using OpemMP, but what I did didnt’ seem to make the code faster than the serial version (see paper).

I assume coding this the Elixir way would look way different than the C++ code, and be structured quite different than a direct translation (if such a thing is even possible).

Ultimately, I’d like to publish the results of benchmarks in different languages doing the SSoZ in an updated paper.

If anyone would be willing to take up the challenge I’d be pleased to answer any questions the best I can.

Thanks in advance.

Jabari

1 Like

If it is for heavy math, it might be quicker to use elixir for parallelism, and calcul with c++, and make them communicate via nifs.

It might not suit your benchmark needs, but it fits well to use elixir with other languages (c++, or rust) for practical reason.

PS: Looking at the code on the link … There is so much for loop, I doubt it will be easy to rewrite it the functional programming way

1 Like

Eh that part is not hard, loops just become recursive function calls.

But regardless, if it is super-heavy math, usually better for a Port or NIF, depending.

1 Like