An arbitrary-precision complex interval number library for Ruby. Requires GNU MP, MPFR, and MPC.
C Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ext/number
test
.gemtest
.gitignore
README.md
Rakefile
number.gemspec

README.md

Ruby Numbers

The Ruby Number gem is an arbitrary-precision complex interval number library for Ruby. The gem is intended to be a drop-in replacement for Ruby's Numeric classes when arbitrary-precision complex interval calculations are warranted. The basis of the arbitrary-precision calculations is the GNU MP, MPFR, and MPC libraries.


Installing

First, go grab the source code for the GMP, MPFR, and MPC libraries and install them (in that order) following the instructions on their websites. In Unix, you'd install them by entering the following into the command line:

cd /some_path/my_gmp_src_directory
./configure
make
sudo make install

After all 3 libraries are installed, grab the Number gem in the usual way:

gem install number

Now you should be ready to go!


Quick Example

Use the global function Number() to create Number objects.

Pass a single argument to create a new Number from a Ruby object:

  • Integers

      Number(1)
        => 1:1
    
  • Floats

      Number(1.2)
        => 12:1
    
  • Strings

      Number("1:5")
        => 1:5
    

Create complex numbers and interval numbers by passing multiple arguments to Number().

  • Complex

      Number(1,2)
        #=> 1:1+2:1i
    
  • Interval

      Number(1,2,3)
        #=> [1:1 ≤ (2:1) ≤ 3:1]
    
  • Complex Interval

      Number(Number(1,2,3), Number(4,5,6))
        #=> [1:1 ≤ (2:1) ≤ 3:1]+[4:1 ≤ (5:1) ≤ 6:1]i
    

Once a Number, Always a Number

Number objects coerce Numeric objects into Number objects.

Number(1) + 1
5 / Number(1,2,3)

Stay tuned. More documentation to come.