#floating-point #propagation #point #floating #error #analysis #error-handling

err_prop

Super simple ( and stupid ) floating point error propagation calculating type

2 releases

Uses old Rust 2015

0.0.2 Mar 12, 2017
0.0.1 Mar 10, 2017

#18 in #propagation

Unlicense

15KB
526 lines

err_prop Build Status

Super simple ( and stupid ) floating point type calculating upper bound of error propagation I dont guarantee that this is correct. If you know you can do something better just contribute! :)

how it works

This works on premise that each floating point operation has an error. Where Addition and Subtraction generate actual error and Multiplication Division just increase that error: snapshot of implementation:
Add:

val: self.val + rhs.val,
err: self.val.abs().max(rhs.val.abs()) + self.err + rhs.err

Sub:

val: self.val - rhs.val,
err: self.val.abs().max(rhs.val.abs()) + self.err + rhs.err

Mul:

val: self.val * rhs.val,
err: self.val.abs() * rhs.err + rhs.val.abs() * self.err

Div:

val: self.val / rhs.val,
err: self.err / rhs.val.abs() + rhs.err * self.val / (rhs.val * rhs.val)

After you are done with your calculations use the .err() method or better .err_times_eps() to get static upper bound value of accumulated error

bunch of method unimplemented!()

There is bunch of methods which are unimplemented!(). Why? Because I needed to provide them however I did not them yet, so I just put unimplemented!().
Most important std::ops::* are implemented that is:

+, - , *, /

why cgmath dependency?

Well. Because I am using cgmath library. and unfortunatelly to be able to use custom num type with cgmath you have to depend on them. :( Because they provide their own trait which has to be implemented.

Dependencies

~1.5MB
~23K SLoC