Giter Site home page Giter Site logo

gosit's Introduction

Gosit

Gosit is a posit library for go. There is currently one other go implementation but this one has been archived and wont receive updates.

Posits are a representation of real numbers that tries to compete with floating point numbers. See the wikipedia page and the paper if you want to learn more about posits.

This library has been moved to https://gitlab.com/amfiremage/gosit. This repository will remain as it is now, with most of the most essential operations working.

Testing

Gosit is fuzzed against goposit, the fuzzing finds a case where the bits returned form this library are diferent from goposit, it fails. As of the initial commit all functions have been fuzzed at least 1 hout, or around 26000 cases. This is not a lot and there might be some edge cases it hasnt found yet, but it gives a good indication that in general this library does the right thing. Only ES=2 has been fuzzed, mostly because this is the ES used in softposit for julia and rust, allowing me to easily verify and debug with a maintained version of softposit. Other values will be tested later on.

Suport

Gosit currently only supports 32 bit posits, this should be enough for most use cases. 64 bit, and probably some smaller sizes, are on the roadmap. Currently only es=2 is fuzzed as states in the Testing section.

How to use.

p := gosit.Newposit32FromBits(0b0_001_10_11_10000011_01111110_10010111)
q := gosit.Newposit32FromBits(0b0_000001_11_0000001_00000111_10100011)
fmt.Println(gosit.Getfloat(p), "*", gosit.Getfloat(q), "=", gosit.Getfloat(gosit.MulPositSameES(p,q)))

Benchmarks

Currently I only benchmark against the slow goposit, since its the only other go library for posits.

Goposit

All tests are ran with the exect same bench cases to eliminate favouring one library over another because of coincidence. These are rotated out every iteration. No other code is ran besides getting the case from an array, and running the corresponding function on it. All benches ware using ES=2

go test --run=X --bench=. -benchtime 30s
BenchmarkAddSlow-10             1000000000              18.32 ns/op
BenchmarkAddSlowGoposit-10       9228086              3922 ns/op
BenchmarkMulSlow-10             1000000000              17.06 ns/op
BenchmarkMulSlowGoposit-10       8928680              4118 ns/op
BenchmarkDivSlow-10             1000000000              22.38 ns/op
BenchmarkDivSlowGoposit-10       8428436              4151 ns/op
BenchmarkSqrtSlow-10            1000000000              32.50 ns/op

softposit-rs

No direct comparisons exist, but taking some averages from cargo bench on my machine:

Operation ns/op on my machine
Add 7.5ns/op
- 6.9ns/op
* 6.3ns/op
/ 9.8ns/op

gosit's People

Contributors

jaicewizard avatar

Watchers

 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.