Code Monkey home page Code Monkey logo

fastrationals.jl's Introduction

I am busy breaking, fixing, testing, and refining (June 17th--23rd)

( This will become available for use in concert with its announcement on Discourse. )

please know that your interest and attentiveness are matters of moment and import



FastRationals.jl

rationals with unreal performance ๐“ช

Copyright ยฉ 2017-2019 by Jeffrey Sarnoff. This work is released under The MIT License.

computing with rational arithmetic

relative speed
FastRational{ Int32 } 6 .. 12
SystemRational{ Int32 } 1

Benchmarking

using FastRationals, Polynomials, BenchmarkTools

w,x,y,z = 1//121, -2//877, 3//454, -4//171; q = 1//87
poly = Poly([w,x,y,z])

a,b,c,d = FastRational.([w,x,y,z]); p = FastRational(q)
fastpoly = Poly([a,b,c,d])

polyval(poly, q) == polyval(fastpoly, p)
# true

relative_speedup =
    floor((@belapsed polyval($poly, $q)) / (@belapsed polyval($fastpoly, $p)))

# relative_speedup is (win_v111 = 14.0, wsh_v13x = 17.0)
using FastRationals, BenchmarkTools

x, y, z = 1234//3451, 345//78912, 987//53
a, b, c = FastRational.([x, y, z])

function test(x,y,z)
   a = x + y
   b = x * y
   c = z - b
   d = a / c
   return d
end

test(x,y,z) == test(a,b,c)
# true

relative_speedup =
    floor( (@belapsed test(Ref($x)[],Ref($y)[],Ref($z)[])) / 
           (@belapsed test(Ref($a)[],Ref($b)[],Ref($c)[])))

# relative_speedup is (win_v111 = 12.0, wsh_v13x = 16.0)

Arithmetic works like Rational for eltypes Int8, .., Int128, UInt8, .. except there is no Infinity, no NaN comparisons.


๐“ช Harmon Stopples on 2019-06-14

fastrationals.jl's People

Contributors

jeffreysarnoff avatar klausc avatar

Watchers

James Cloos avatar  avatar

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.