GithubHelp home page GithubHelp logo

tkoenig1 / fmpfr Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 386 KB

A Fortran binding for the GNU MPFR library.

License: Other

Makefile 22.48% M4 2.17% Fortran 44.46% C 1.66% Perl 11.18% Shell 18.06%
fortran mpfr multiprecision

fmpfr's Introduction

FMPFR - a Fortran binding for MPFR

This library offers a Fortran binding to the GNU MPFR Library multi-precision library. The aim of the library is to make the use of MPFR convenient for a Fortran user.

Status

This is an initial work, expect bugs and (especially) missing features and possibly some instability, at least in binary compatibility. Source code compatibility should be fine.

Compiler requirements

As of now, you need a compiler which supports `ERROR STOP for the testsuite.

What is supported

  • Arithmetic expressions can be used the usual way; expressions can be mixed with real and integer expressions.

  • Mathematical intrinsics, like sin, cos etc.

  • Array expressions

  • Setting and changing a default precision of variables

  • List-directed output

  • Reading values from strings

What is not supported

  • Input (user-defined I/O is too unevenly implemented in existing compilers)

  • Array intrinsics like MAXLOC and MAXVAL

An example

Here is a short exampe, if your compiler supports user-defined I/O:

program memain
  use fmpfr_oper
  implicit none
  type (fmpfr), dimension(:), allocatable :: a
  call set_default_prec (128)
  allocate (a(2))
  a(1) = fmpfr("1.3")
  a(2) = a(1) + 2
  print *,a
  print *,sin(a)
  print *,get_str(cos(a(1)),10)
end program memain

whose output is

 1.299999999999999999999999999999999999998E0  3.299999999999999999999999999999999999998E0 
 9.635581854171929647013486300395548153418E-1  -1.577456941432483820116542776024823708430E-1 
 2.674988286E-1

Installation

Type ./configure and make. If everything was successful, type make check.

Modifying the code

If you want to modify the code, it is best if you make your changes to the src/generate.pl file and run

$ grep ^@deftypefun mfpr.texi | perl generate.pl

where mpfr.texi is the MPFR documentation.

License

This is covered under the MIT license.

fmpfr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fmpfr's Issues

Improve handling of precision and rounding

It would be nice to be able to specify precision and rounding, both optional, to allow something like FMPFR("1.23456",100,mpfr_rndz) where both the 100 and the mpfr_rndz are optional.

Have to think a bit how Fortran generics rules allow for that...

Enable a subset for older compilers

Right now, the program needs derived type I/O and ERROR STOP (the latter only for the testsuite). It could still be useful for older compilers. It would be better to not compile those parts, or chose an alternative.

Issues Using FMPFR

Hi!
I am having some issues using your wrapper library that I am hoping you can clear up. I have successfully installed and configured FMPFR, but it does not work. The main problem is within the src files of FMPR itself. When a function in an FMPFR file is called that is defined within a different file, the whole thing crashes. It appears as if there has been no effort to link the files within the library together. Now, I will say that I have never had to install a library like this before. This means that there is a 99% chance that this is my fault and I am just lacking the knowledge of how to correctly call and use the wrapper. If that is the case, then some advice and assistance would be GREATLY appreciated!

memory leaks due to buggy finalization in gfortran

The interface is essentially unusable when using gfortran (Version 12.1.1), because it does not handle finalization properly (compiler bug). So on each assignment, or for temporary results from operators in formulas, memory is leaked. You can check this easily with valgrind.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.