Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: GMP library: free library for arbitrary precision arithmetic

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    GMP library: free library for arbitrary precision arithmetic

    In response to Sandy question about rounding problems found into calculator gui examples ... http://community.thinbasic.com/index.php?topic=1406.0
    I was searching for a library able to make calculations with arbitrary precision and able to output results with the wanted precision into a string.

    I found GMP library at http://gmplib.org/
    and the corresponsing compiled DLL (version 4.1.2 at http://www.cs.nyu.edu/exact/core/gmp/)

    Made some tests and attached you can find what I was able to get so far. Adding new exported functions to the script is quite easy but I stopped for a while in order to better understand the library.

    In the attached file you will find the following files to be placed into a testing directory you like:
    • gmp.dll (dll library)
    • gmp.h (C header file used to understand sub/functions declares)
    • gmp.tbasic (thinBasic example)
    • gmp-man-4.2.2.pdf (manual)


    Have fun with it.
    I will work on it more in new year because it seems a good starting.

    Ciao
    Eros

    _________________________________________________
    PS:
    GMP library works on integer, rational and floating point numbers. It has 323 exported functions! I just declared few of them working on floating point numbers in order to test the possibility to have this library as standard in one of the next thinBasic distribution. Tests went fine so the possibility to have GMP as thinBasic standard is quite high.

    If someone succede in declaring more functions (using C header file and PDF maual), please post them here and I will add into final thinBasic include file. Thanks.

    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: GMP library: free library for arbitrary precision arithmetic

    Eros, I unzipped it and ran it from the folder I unzipped too and got a crash. Should I move the dll some place special? I thought it would read it from the same place as the script?
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: GMP library: free library for arbitrary precision arithmetic

    Same here
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  4. #4

    Re: GMP library: free library for arbitrary precision arithmetic

    Same here. I tried moving the dll to Lib but this didn't make any difference.

    Thanks
    Sandy

    I was playing around with the script and got an error message I don't understand.
    Attached Images Attached Images

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: GMP library: free library for arbitrary precision arithmetic

    You are right.
    Seems it is working only on my development laptop while on other computer I have I get GPF too.
    I will check what's the problem. Sorry about that.

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: GMP library: free library for arbitrary precision arithmetic

    Stupid me. I changed the way BYREF strings (both dynamic and ASCIIZ) are passed to external DLLs, so I needed also to distribute thinCore.dll
    Please find attached to first post the latest thinCore.dll as separated file so you do not have to download again all.

    Put thinCore.dll into thinBasic installation directory replacing current one.
    All the rest can be placed into a sample script directory. If experiments will go fine, in one of the next future release GMP will be incorporated as standard library with a dedicated include file.

    Let me know.
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: GMP library: free library for arbitrary precision arithmetic

    Thanks Eros, I hope I find some spare minutes to check this out.

  8. #8

    Re: GMP library: free library for arbitrary precision arithmetic

    hi
    thanks for introducing us to GMP math Library, and as suggested i have added another functions so the available now for mpf (+ - * / sqrt pow), i have copied the form from textbox examples, but i need to know how to change the font type and font size of the textboxes.
    from site :
    ftp://deltatrinity.dyndns.org/gmp-4....Libs/pentium4/
    a more recent gmp dll v 4.2.1 called libgmp-3.dll rename it to gmp.dll
    and about precision there is in the site:
    http://www.nabble.com/Re:-about-prec...-p5313487.html
    someone said that if we choose precision 2048 then the number of digits at the right of the mantissa is 2048*log10(2) = 616.51 digits.
    so the precision used here 2048
    try pow 2.2 , 3 will produce 10.647999...up to digit 616 from the period
    second question: can we color the period and make it a bigger size so we can discriminate the left integer side and the right fractional side especially if the period is located somewhere far in a big number
    the calculator_2 example in samplescripts by Psch, is excellent, i may borrow it's structure once i have more functions, clicking on buttons are easier than typing
    one drawback of the GMP library is the lacking of Logarithm function, i think it is available in mpfr library
    another notice: is that the pow function is restricted to an integer exponent
    regards


    Attached Images Attached Images
    Attached Files Attached Files

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: GMP library: free library for arbitrary precision arithmetic

    Hi Zak,

    very interesting code.
    I attach version, where:
    • operations presented in form of combobox
    • controls are getting bigger when resizing
    • integer and floating point part of the result have different colors
    • dialog is handled via callback - much less CPU intensive script


    Hope you like it ,
    Petr

    UPDATED ATTACHEMENT
    Attached Images Attached Images
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10

    Re: GMP library: free library for arbitrary precision arithmetic

    yes Petr it is a fantastic code , full of ideas and inventions, i will spend some time in studying it. in the next month (next year) i will try to add the integer numbers (MPZ) because they have the primality checking, and the next_prime function.
    you missed to delete the line number 143 in the subtraction code,it gives an error.
    thanks very much
    and thanks for Eros for his ideas and declarations.



Page 1 of 3 123 LastLast

Similar Threads

  1. 2D Library
    By Pipes in forum thinBasic General
    Replies: 11
    Last Post: 27-01-2009, 22:17

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •