in reply to porting C code to Perl
However, all tests usually pass when I install Inline::C on Strawberry Perl. What's the problem that you're seeing there ?Test Summary Report ------------------- t/27inline_maker.t (Wstat: 1024 Tests: 8 Failed: 4) Failed tests: 2-3, 6-7 Non-zero exit status: 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: porting C code to Perl (Inline::C)
by Discipulus (Canon) on Oct 23, 2017 at 15:41 UTC | |
The test with Inline::C was a collateral experiment. cpan -fi Inline::C still failed with strawberry perl 5.14 I suppose while building prerequisite Win32::Mutex or it's preprerequisite Win32::IPC Instead strawberrry Perl 5.24 64bit installed all modules smoothly. This is good. So i retried the Inline::C test but again my ignorance won: as I understand from Inline::C docs I must have subroutine in the C code to be exported into Perl. I was not able to tranform the C code into a sub. More: the first error (or well the first that seems an error to me), complains with int len = floor(10 * N/3) + 1 pointing to the f of foor I assumed that the math.h was not imported at that time. thanks again, but probably I have no much fu to proceed further with C, or I must take it seriously and study from basics.. L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS. | [reply] [d/l] [select] |
by marioroy (Prior) on Oct 30, 2017 at 04:43 UTC | |
Hi Discipulus, Strawberry Perl with PDL editions include Inline::C. Moreover, GMP libraries are included as well. The following is the Chudnovsky algorithm (found here) for computing Pi. It runs fine with Strawberry Perl. On Unix platforms, change the inc and libs paths to point to the GMP location.
Regards, Mario | [reply] [d/l] [select] |
by marioroy (Prior) on Nov 06, 2017 at 02:36 UTC | |
The Chudnovsky algorithm allows one to run parallel. C calls perl_add which adds to a shared Math::BigFloat object.
Parallel Example
I'm using Signal::Safety so that pressing Ctrl-C responds immediately while inside C. Regards, Mario | [reply] [d/l] [select] |
by danaj (Friar) on Nov 07, 2017 at 00:48 UTC | |
This seems to be much slower than AGM. 10k digits takes 0.13s but 100k digits takes 33.8s. Even the Machin-type formula are faster. The paper Exploration in π Calculation Using Various Methods Implemented in Python has some insight, and is useful to read in general as well. We certainly shouldn't be doing all those factorials in the loop. Those are pretty easy to pull out. But the killer is the huge-precision divide done for every loop iteration. Binary splitting is what's needed, though it is a non-trivial change. You can see in their Table 2 just how significant the difference is. If I recall correctly, fast implementations use fine control of the precision on every loop iteration, where in contrast AGM has to use full precision for each iteration. | [reply] |
by marioroy (Prior) on Nov 07, 2017 at 09:15 UTC | |
by marioroy (Prior) on Jan 23, 2018 at 09:53 UTC | |
I got caught up with computing Pi. Chudnovsky-Pi lives here on Github. It runs well on Cygwin and Unix, of course ;-). Strawberry Perl 64-bit is not built with true 64-bit integer support, unfortunately. Anyway, the Chudnovsky-Pi demonstration runs with Linux Bash Shell on Windows 10. The m4 binary is needed and optionally yasm, needed for MPIR. Hence, sudo apt-get install m4 yasm. Cheers, Mario | [reply] |