stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

Proposal for arbitrary precision data type and arbitrary precision Lapack/Blas

Open Jim-215-Fisher opened this issue 5 years ago • 9 comments

Like to see an arbitrary precision data type in stdlib. Other languages like python, c++, java and Julia have already implemented. As a programming language for scientific calculation, Fortran should have the arbitrary precision data type implemented as well.

GNU has a GMP multiple precision library for c++. To the Fortran side, there are David Bailey's MPfun2015 package (https://www.davidhbailey.com/dhbsoftware/) and David Smith's FM package (https://dmsmith.lmu.build/).

For arbitrary precision Lapack/Blas, there is mpack(http://mplapack.sourceforge.net/).

Jim-215-Fisher avatar Sep 10 '20 17:09 Jim-215-Fisher

I like the idea - while I do not usually need multiple precision in my daily work or my hobbies, having such a feature readily available is certainly welcome. Something that might also be useful: arbitrary precision integer data.

Have you checked the status and the licence of the various libraries?

Regards,

Arjen

Op do 10 sep. 2020 om 19:18 schreef Jing [email protected]:

Like to see an arbitrary precision data type in stdlib. Other languages like python, c++, java and Julia have already implemented. As a programming language for scientific calculation, Fortran should have the arbitrary precision data type implemented as well.

GNU has a GMP multiple precision library for c++. To the Fortran side, there are David Bailey's MPfun2015 package ( https://www.davidhbailey.com/dhbsoftware/) and David Smith's FM package ( https://dmsmith.lmu.build/).

For arbitrary precision Lapack/Blas, there is mpack( http://mplapack.sourceforge.net/).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fortran-lang/stdlib/issues/231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN6YR3P3GD2R4P5RE5KRO3SFEC7BANCNFSM4RFPDUUA .

arjenmarkus avatar Sep 14 '20 09:09 arjenmarkus

For mpack, it is 2-caluse BSD style license. It has not been updated since 2012. For MPfun2015 package, it has LIMITED BSD LICENSE, i do know what that means. For FM package, it is free.

Jim-215-Fisher avatar Sep 20 '20 15:09 Jim-215-Fisher

Thanks for looking into this. I cannot find any information about a limited BSD license, but there is a Github mirror by @jacobwilliams for this package. Maybe Jacob can explain this? In any case, there are no obvious restrictions based on the license text I found there to the use of theat package in the Fortran stdlib.

Op zo 20 sep. 2020 om 17:56 schreef Jing [email protected]:

For mpack, it is 2-caluse BSD style license. It has not been updated since 2012. For MPfun2015 package, it has LIMITED BSD LICENSE, i do know what that means. For FM package, it is free.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fortran-lang/stdlib/issues/231#issuecomment-695802946, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN6YR5SXBO2M7L3B2RHF43SGYQ2FANCNFSM4RFPDUUA .

arjenmarkus avatar Sep 22 '20 06:09 arjenmarkus

FYI: the latest version of mplapack (the name has been changed because of https://github.com/nakatamaho/mplapack/issues/2) is sitting here: https://github.com/nakatamaho/mplapack.

tueda avatar Apr 11 '21 07:04 tueda

Yes, Fortran definitely needs an arbitrary precision floating point, as either a library or part of stdlib.

Arbitrary precision lapack/blas is also occasionally useful. I've used quadruple precision Lapack in the past by recompiling Lapack in quadruple precision. Not the best, but it worked to give me some extra precision.

@Jim-215-Fisher, would you be interested in working on this?

certik avatar Feb 03 '22 20:02 certik

Yes, I would be glad to introduce an arbitrary precision package to stdlib. I need some feedback about implementation and interface.

Jim-215-Fisher avatar Feb 03 '22 21:02 Jim-215-Fisher

Here is some thoughts about the implementation and interface of the arbitrary precision module for stdlib.

module  multiprecision
    type :: mp
       integer, allocatable :: n(:)
   end type mp
  ! use integer array to represent sign, exponent and digits of a float with a desired precision

   public :: set_precision     ! call for precision setup
   interface operator(+)       ! operator overload for arithmetic
   interface operatoe(-)
   interface operator(*)
   interface operator(/)
   interface assignment(=)  ! operator overload for assignment
   interface operator(==)     ! operator overload for logic comparison
   interface operator(<)
   interface operator(<=)
   interface operator(>)
   interface operator(>=)
   interface abs                  ! intrinsic function overload
   interface sin
   interface cos
...

end module multiprecision

Any suggestion or comment?

Jim-215-Fisher avatar Feb 05 '22 02:02 Jim-215-Fisher

CC @awvwgk, @milancurcic, @LKedward, @arjenmarkus

What would be the best approach?

certik avatar Feb 06 '22 14:02 certik

I have rather limited experience with multiprecision libraries (used them once for code generation in Ruby, but this is years ago).

Probably worth to collect some information what other libraries/languages are doing regarding representation, functionality and interfaces. A couple of Fortran compatible libraries are already linked above.

Another question is how much effort a multiprecision implementation in stdlib is going to be, especially regarding code review, testing and validation. Do we have the tools for this available?

awvwgk avatar Feb 06 '22 14:02 awvwgk