Coder Social home page Coder Social logo

unum's Introduction

Copyright (c) 2016, Lawrence Livermore National Security, LLC.
Produced at the Lawrence Livermore National Laboratory.
Written by G. Scott Lloyd, [email protected].
LLNL-CODE-704762.
All rights reserved.

This file is part of Unum.
For details, see http://github.com/LLNL/unum
Please also read COPYING.

--------------------------------------------------------------------------------

This floating-point arithmetic library contains a software 
implementation of Universal Numbers (unums) in 'C' as described by 
John Gustafson in the book "The End of Error: Unum Computing". The 
implementation is patterned after the prototype code printed in the 
book. A download of the Mathematica code is available from the 
publisher's website: 

http://www.crcpress.com/The-End-of-Error-Unum-Computing/Gustafson/9781482239867

Since this 'C' implementation uses names common with the Mathematica 
implementation, the book can be used as a form of documentation to help 
understand the source code. The unum library uses the GNU Multiple 
Precision (GMP) Arithmetic Library for the low-level arithmetic. GMP 
(http://gmplib.org/) must be installed or accessible on your system to 
build and use the unum library. If you don't install GMP to a standard 
location, you can define the following environment variables before 
running "./configure". 

export CPPFLAGS=-I<path to GMP include>
export LDFLAGS=-L<path to libgmp>

Some additional documentation about the unum package can be found in the 
"doc" directory. 

After configuring the distribution with "./configure", existing test 
programs can be executed in a batch by running "make check" from the top 
level directory of the distribution. Once built, they can be 
individually run at the command line from the "tests" directory. 

To help in writing unum test programs, an example "tests/tdev.c" is 
provided. Test programs can be built individually with the standalone 
make file "tests/tdev.mak" that is not part of the autotools build 
system. This make file is handy when making frequent changes to the unum 
library source code since it compiles and links the individual source 
files with a test without the overhead of autotools and building the 
library archive. 

The library supports creation of unums and printing of unum values. It 
also supports variable sized unums from a few bits up to thousands. 
Functions are available that convert between unums and primitive 'C' 
types. The relational operators, four arithmetic operators (add, 
subtract, multiply and divide), and square root are also implemented. 
The guess function, when applied to a unum after an arithmetic 
operation, will produce a rounded result much like a floating-point 
calculation. 

Three main interfaces to unum functionality are available in the "src"
directory:
 * unumxx.h – 'C++' wrapper class that allows unums (actually ubounds)
               to be used with the standard arithmetic operators
 * unum.h   – 'C' function interface that stores unums in a variable length
               byte array
 * ubnd.h   – 'C' function interface that stores unums in a data structure

The C++ wrapper class will generate calls to the ubnd.h interface. 
Within a program, unums are defined with the "ubnd_c" type and may be 
used in place of "floats" and "doubles". A simple example is shown in 
the "tunumxx.cpp" test program. The unum environment must be set with 
the set_uenv() function before any operations occur with unums. Existing 
applications modified to use unums will likely need to have "AUTO_GUESS" 
defined at compile time. This will automatically insert calls to the 
unum guess function at every assignment. 

Operations on unums through the library are several thousand times 
slower than operations on IEEE standard types with floating-point 
hardware. While faster implementations of the library are possible, the 
intent of this implementation is to provide flexibility for research 
purposes and accurate results. 

unum's People

Contributors

gslloyd avatar

Stargazers

 avatar Andrii Vasyliev avatar Tiancheng Xu avatar Paran Lee avatar Chien-Yu Lin avatar Samuel Wilder avatar Shawn Zhuang avatar Filipe Varjão avatar Daniel Sokil avatar  avatar Samuel Kelemen avatar  avatar Rafael Escrich avatar  avatar Diego Alonso avatar Andy Gelme avatar Matt Guthaus avatar Bater.Makhabel avatar Roman Dzieciol avatar Larry Melia avatar Josh Milthorpe avatar Richard Davies avatar Lawrence Peng avatar Ferris avatar  avatar Edward Smith-Rowland avatar Alex Converse avatar Daniel Lin avatar Manuel Freire avatar Izaak "Zaak" Beekman avatar Jeff Hammond avatar  avatar Dmitriy avatar  avatar  avatar Mike Lam avatar Kevin Geng avatar Waldir Pimenta avatar Deepak Ingole avatar Todd Gamblin avatar

Watchers

xman avatar Nina Jeliazkova avatar Martin Schulz avatar Waldir Pimenta avatar Varun Agrawal avatar Kevin Geng avatar Dmitriy avatar James Cloos avatar Reto Schneider avatar Rafael Escrich avatar Edward Smith-Rowland avatar  avatar Roy Gulla avatar Deepak Ingole avatar Katrina Trujillo avatar  avatar  avatar

unum's Issues

Errors in some calculations

Hi,
I am noticing some peculiarities in some of the calculations. For example:
I expect this:

r-237-121-25-172:lab5 hugh$ ./unumcalc 1 div "[0,2]"
   Result of 1 div [0,2] is NaN
r-237-121-25-172:lab5 hugh$ ./unumcalc 1 div "(0,2]"
   Result of 1 div (0,2] is [0.5,Inf)

But I am surprised by this:

r-237-121-25-172:lab5 hugh$ ./unumcalc 1 div "[0,1]"
   Result of 1 div [0,1] is NaN
r-237-121-25-172:lab5 hugh$ ./unumcalc 1 div "(0,1]"
   Result of 1 div (0,1] is NaN

It appears that if the dividend is the same value as the upper bound of the divisor, then the result is wrong:

r-237-121-25-172:lab5 hugh$ ./unumcalc 2 div "(0,2]"
   Result of 2 div (0,2] is NaN
r-237-121-25-172:lab5 hugh$ ./unumcalc 3 div "(0,3]"
   Result of 3 div (0,3] is NaN
r-237-121-25-172:lab5 hugh$ ./unumcalc 4 div "(0,4]"
   Result of 4 div (0,4] is NaN

Anyway - has anyone else noticed this behaviour?
Cheers Hugh

unum_log not implemented?

Hi,

I note that unum_log does not appear to be in the library, although it appears in the unum.h file. Is this correct?
Cheers Hugh

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.