translating the header using FBfrog produces a huge bi file that needs many corrections but using libpari is very simple
you can use functions like mpadd simply enough but there's no need, you can simply evaluate a string with your functions
I only post a tiny fraction of the include file with example usage
Code: Select all
#Pragma Once
#Inclib "pari"
Extern "C"
Type pari_ulong As Ulongint
Type GEN As Longint Ptr
Declare Sub pari_print_version()
Declare Function geval(Byval x As GEN) As GEN
Declare Function setdefault(Byval s As Const Zstring Ptr, Byval v As Const Zstring Ptr, Byval flag As Longint) As GEN
Declare Function strtoGENstr(Byval s As Const Zstring Ptr) As GEN
Declare Function setrealprecision(Byval n As Longint, Byval prec As Longint Ptr) As Longint
Declare Sub pari_init(Byval parisize As Uinteger, Byval maxprime As pari_ulong)
Declare Function GENtostr(Byval x As GEN) As Zstring Ptr
Declare Function stoi(Byval x As Longint) As GEN
Declare Function mpadd(Byval x As GEN, Byval y As GEN) As GEN
Declare Function mpsub(Byval x As GEN, Byval y As GEN) As GEN
Declare Function mpmul(Byval x As GEN, Byval y As GEN) As GEN
Declare Function mpdiv(Byval x As GEN, Byval y As GEN) As GEN
End Extern
Dim As GEN a, b, c, e, f
Dim As Zstring Ptr s=Callocate(1024*1024)
Dim As Longint prec, flag
pari_init(8000000,500000)
pari_print_version()
setrealprecision(50, @prec)
f=setdefault("seriesprecision", "12", flag)
*s="fibonacci(50)"
a=strtoGENstr(s) 'convert to GEN string
b=geval(a) 'eval the string in a
s=GENtostr(b) 'convert GEN to string
Print "fibonacci(50) = ";*s
*s="sin(x)"
a=strtoGENstr(s)
c=geval(a)
s=GENtostr(c)
Print "sin(x) = ";*s
*s="Pi"
a=strtoGENstr(s)
c=geval(a)
s=GENtostr(c)
Print "Pi = ";*s
Print
Print "evaluate a tiny program: for(i=2, 10, print(sqrt(i)))"
*s="for(i=2, 10, print(sqrt(i)))"
a=strtoGENstr(s)
c=geval(a)
Deallocate(s)
Code: Select all
GP/PARI CALCULATOR Version 2.13.4 (released)
amd64 running mingw (x86-64/GMP-6.1.2 kernel) 64-bit version
compiled: Mar 25 2022, gcc version 8.3-posix 20190406 (GCC)
threading engine: single
(readline v8.0 disabled, extended help enabled)
fibonacci(50) = 12586269025
sin(x) = x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11 + O(x^13)
Pi = 3.1415926535897932384626433832795028841971693993751
evaluate a tiny program: for(i=2, 10, print(sqrt(i)))
1.4142135623730950488016887242096980785696718753769
1.7320508075688772935274463415058723669428052538104
2.0000000000000000000000000000000000000000000000000
2.2360679774997896964091736687312762354406183596115
2.4494897427831780981972840747058913919659474806567
2.6457513110645905905016157536392604257102591830825
2.8284271247461900976033774484193961571393437507539
3.0000000000000000000000000000000000000000000000000
3.1622776601683793319988935444327185337195551393252