Recent

Author Topic: GMP: multiple precision arithmetic library, version 6.3.0.  (Read 823 times)

Ed78z

  • New Member
  • *
  • Posts: 32
GMP: multiple precision arithmetic library, version 6.3.0.
« on: September 10, 2024, 10:55:15 pm »
Do you have any information about using the GMP library in Lazarus?

It seems it's not implemented well in Lazarus.

srvaldez

  • New Member
  • *
  • Posts: 47
Re: GMP: multiple precision arithmetic library, version 6.3.0.
« Reply #1 on: September 10, 2024, 11:43:54 pm »
hello Aqdam1978

I cannot find the gmp units in 3.2.2 64 bit pascal??
but they are in the 32 bit version.
you can compile the gmp unit from source fpcbuild-3.2.2\fpcsrc\packages\gmp\src to 64-bit and then place the files in FPC\3.2.2\units\x86_64-win64\gmp
you will still need the DLL, just download a good MinGW distribution and look for the dll in the bin folder
<edit> have not tried anything related to GMP in Lazarus, works OK in FPC
« Last Edit: September 10, 2024, 11:45:48 pm by srvaldez »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1238
Re: GMP: multiple precision arithmetic library, version 6.3.0.
« Reply #2 on: September 11, 2024, 02:51:42 am »
Hello,
what is your O.S ?
For example to use gmp on windows 11  lazarus 64 bits .
1 - Download the file gmp.pas from github free pascal repository : https://github.com/fpc/FPCSource/tree/main/packages/gmp/src
2 - Put the file in your project folder.
3 - Download gmp library for windows. For example from here : https://github.com/gx/gmp/releases/tag/6.1.2-2  (only 6.1.2 version need msvc 2019 redistribuable library)
4 - from gmp-6.1.2-2-msvc2019-x64-Release.zip file extract libgmp-13.dll and rename it gmp.dll. Put it in your project folder or in the windows system32 folder

Example to use gmp in Lazarus :

Code: Pascal  [Select][+][-]
  1. implementation
  2.  uses  math, gmp;
  3. {$R *.lfm}
  4. procedure TForm1.GoClick(Sender: TObject);
  5. const N = 2;
  6.       NBITS = 100;
  7. var f: mpfloat;
  8.     bits, digits: integer;
  9. begin
  10.   f_set_default_prec(NBITS);
  11.   bits := f_get_default_prec;
  12.   digits := floor(bits * LOG_10_2);
  13.   f := f_sqrt_ui(N);
  14.   Memo1.Append(format('Sqrt(%d) to %d digits (%d bits) = %s', [N, digits, bits, AnsiString(f)]));
  15.   f := f ** 2;
  16.   Memo1.Append(format('Squared back = %s', [AnsiString(f)]));
  17.   f -= N;
  18.   Memo1.Append(format('Minus %d = %s', [N, AnsiString(f)]));
  19. end;        
   

Friendly, J.P     
« Last Edit: September 11, 2024, 02:56:00 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Ed78z

  • New Member
  • *
  • Posts: 32
Re: GMP: multiple precision arithmetic library, version 6.3.0.
« Reply #3 on: September 11, 2024, 04:20:33 am »
Thank you,

I have downloaded those files.

My system is Win 11 x64

Zvoni

  • Hero Member
  • *****
  • Posts: 2690
Re: GMP: multiple precision arithmetic library, version 6.3.0.
« Reply #4 on: September 11, 2024, 10:43:39 am »
Thank you,

I have downloaded those files.

My system is Win 11 x64
And change your screenname.....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Ed78z

  • New Member
  • *
  • Posts: 32
Re: GMP: multiple precision arithmetic library, version 6.3.0.
« Reply #5 on: September 14, 2024, 03:26:10 am »
Thank you all,

I was able to work with GMP library in Lazarus with your guide,

However, I just noticed there are no any logarithmic or trigonometric functions available in GMP! :(
It seem there is another library that uses GMP as a base library and also supporting lots of additional functions: MPFR

https://gitlab.inria.fr/mpfr/mpfr

Do you have any knowledge or information about MPFR package in Lazarus?

 

TinyPortal © 2005-2018