Commit Graph

506 Commits

Author SHA1 Message Date
Sebastian Dröge f74753089b rational: Implement approximation from floats and FromPrimitive for various types
FromPrimitive is implemented for i8/16/32/64 and BigInt.

https://github.com/rust-num/num/issues/282
2017-05-02 02:28:27 +03:00
Homu e2ea246016 Auto merge of #279 - yoanlcq:impl-num-for-wrapping, r=cuviper
Implemented Zero, One and Num for std::num::Wrapping<T>

Attempts to fix issue #278
2017-04-22 02:18:42 +09:00
Yoan Lecoq 2172a9368b impl One for Wrapping doesn't require Add 2017-04-21 19:10:42 +02:00
Yoan Lecoq 356a4ba5b5 Removed useless trait bounds 2017-04-21 18:56:23 +02:00
Yoan Lecoq b562c1ec39 Minor changes for correctness 2017-04-21 18:47:42 +02:00
Yoan Lecoq 9b06d4a0bb Attempt at fixing E0411 on older rust versions 2017-04-21 10:31:29 +02:00
Yoan Lecoq b024e1c326 Implemented Zero, One and Num for Wrapping<T> 2017-04-21 09:26:53 +02:00
Josh Stone 6513a5618b num-integer-0.1.34 2017-04-09 06:22:05 -07:00
Josh Stone fca95eaf42 num-complex-0.1.37 2017-04-09 06:18:09 -07:00
Homu aff06286ad Auto merge of #275 - bluss:repr-c, r=cuviper
Complex: Use repr(C) and add documentation for what it means

Here's an ambitious proposal that puts currently practiced ffi usage of `Complex<f32/f64>` on sound footing.

Fixes  #79

Current users appear to be:

- https://crates.io/crates/blas
  + Their use is not about Complex<f64> in an extern function's signature, but it is explicitly using that it is memory layout compatible.
2017-04-05 01:53:14 +09:00
bluss 0cf3419b9e complex: Use repr(C) and add documentation for what it means 2017-04-04 06:48:35 +02:00
Homu f63c933737 Auto merge of #272 - vks:binomial-coeffs, r=cuviper
Implement an iterator over the binomial coefficients

I'm not very happy with the excessive cloning, but to fix it the bounds on the type parameters would have to be excessive. We probably need something like [this](https://github.com/vks/discrete-log/blob/master/src/main.rs#L90) in `num-traits`.
2017-03-31 10:29:14 +09:00
Vinzent Steinberg 0fc6cb15a5 binomial: Discuss overflow 2017-03-29 14:13:39 +02:00
Vinzent Steinberg a7b459c05e Make `binomial` and `IterBinomial` less likely to overflow 2017-03-26 15:57:25 +02:00
Homu 4fc1e28832 Auto merge of #271 - vks:multinomial, r=cuviper
Implement multinomial
2017-03-26 04:40:20 +09:00
Homu 904d9b494f Auto merge of #170 - DonSheddow:complex-fmt, r=cuviper
Add formatting options for Complex

This adds LowerExp and UpperExp traits for Complex, taking precision into account. Fixes #148
2017-03-26 04:31:24 +09:00
Sigurd Kolltveit 2784b89837 Remove support for zero padding 2017-03-20 19:04:17 +01:00
Vinzent Steinberg d4deba6947 IterBinomial: Make tests closer to overflow threshold (like for binomial) 2017-03-20 10:45:27 +01:00
Vinzent Steinberg 47613ff5ff IterBinomial: Only return coefficient 2017-03-20 10:20:15 +01:00
Vinzent Steinberg e486e6a981 Address some of @cuviper's feedback 2017-03-20 10:14:01 +01:00
Vinzent Steinberg 3de345f912 Don't panic when calculating multinomial 2017-03-20 09:43:01 +01:00
Sigurd Kolltveit e044cfbc6d Simplify some lines 2017-03-18 17:24:00 +01:00
Sigurd Kolltveit 69943915ba Add more string formatting tests 2017-03-18 16:04:53 +01:00
Sigurd Kolltveit e2759e0321 Implement more formatting options for Complex 2017-03-18 16:04:53 +01:00
Sigurd Kolltveit 6113192e04 Add tests for more formatting options 2017-03-18 16:04:53 +01:00
Sigurd Kolltveit f138f3da9e Add formatting options for Complex 2017-03-18 16:04:53 +01:00
Vinzent Steinberg c408bd6605 Try to fix build on Rust 1.8 2017-03-17 18:21:06 +01:00
Vinzent Steinberg 8d235759dd Implement an iterator over the binomial coefficients 2017-03-17 18:03:58 +01:00
Vinzent Steinberg ebe3f85976 Implement multinomial 2017-03-17 17:27:46 +01:00
Homu 2adf018aa6 Auto merge of #270 - vks:binomial, r=cuviper
Implement binomial

The implementation avoids overflows and fractions.
2017-03-16 08:55:20 +09:00
Vinzent Steinberg 40cbe1ff20 Use correct formula 2017-03-12 10:23:27 +01:00
Vinzent Steinberg 07df43b034 Address binomial review feedback
* Use substraction instead of division in comparison.
* More tests.
* Add comment.
2017-03-12 10:17:49 +01:00
Vinzent Steinberg 2f6eb31903 Implement binomial
The implementation avoids overflows and fractions.
2017-03-11 16:44:51 +01:00
Josh Stone d23e3f32b8 num-bigint-0.1.37 2017-03-08 11:14:32 -08:00
Homu fe21c725e8 Auto merge of #269 - cuviper:biguint-parse-plus, r=cuviper
bigint: Create the parsing error better for nested `+`

If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so it
has proper parsing context to understand what's in error.

Fixes #268.
2017-03-09 04:10:48 +09:00
Josh Stone 0b6cae0dc7 bigint: Create the parsing error better for nested `+`
If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so
it has proper parsing context to understand what's in error.

Fixes #268.
2017-03-06 13:23:40 -08:00
Josh Stone 4b8c71fbec bigint: Cleanup unused imports 2017-03-06 13:20:30 -08:00
Josh Stone 66ce252494 Bump versions in the num collection 2017-02-26 14:18:33 -08:00
Josh Stone 6632ca8e1b Merge pull request #267 from cuviper/licenses
Add licenses to subcrates
2017-02-26 13:53:29 -08:00
Josh Stone 1a66ee9e80 Add licenses to subcrates 2017-02-26 13:39:23 -08:00
Homu d273495cbf Auto merge of #263 - cuviper:revamp-ci, r=hauleth
Bump rustc to 1.8 and revamp all CI

This bumps the minimum rustc to 1.8.0, "fixing" #257.  I normally
consider this a breaking change, but we were already broken due to
external factors, for which I couldn't find a workaround.

This adds 1.15.0 to the CI matrix to build stable num-derive.  We still
need nightly to run its tests though, because of compiletest_rs, and
dev-dependencies can't be optional.

The testing scripts are moved from .travis/ to ci/, as they don't really
need to be hidden.  It's also now consolidated into one test_full.sh
which considers $TRAVIS_RUST_VERSION as needed.
2017-02-10 09:19:34 +09:00
Josh Stone 1606fe7206 Bump rustc to 1.8 and revamp all CI
This bumps the minimum rustc to 1.8.0, "fixing" #257.  I normally
consider this a breaking change, but we were already broken due to
external factors, for which I couldn't find a workaround.

This adds 1.15.0 to the CI matrix to build stable num-derive.  We still
need nightly to run its tests though, because of compiletest_rs, and
dev-dependencies can't be optional.

The testing scripts are moved from .travis/ to ci/, as they don't really
need to be hidden.  It's also now consolidated into one test_full.sh
which considers $TRAVIS_RUST_VERSION as needed.
2017-02-09 16:09:48 -08:00
Josh Stone d561e4b702 Merge pull request #262 from Xaeroxe23/master
Add clamp function
2017-02-09 14:17:14 -08:00
Jacob Kiesel c78a48fd35 Improve documentation comments
Remove passive voice from documentation comments.
2017-02-08 15:10:01 -07:00
Jacob Kiesel 17665ec50d Update lib.rs
Make assert debug error more accurate.
2017-02-07 15:03:00 -07:00
Jacob Kiesel f8dcec366b Made requested changes. 2017-02-07 13:02:32 -07:00
Jacob Kiesel 182e08a091 Add inline attribute 2017-02-07 10:49:28 -07:00
Jacob Kiesel b346f9c2df Add a new line for improved formatting. 2017-02-07 10:18:23 -07:00
Jacob Kiesel a5445b7619 Adding documentation comments 2017-02-07 10:18:23 -07:00
Jacob Kiesel 07ff5b62b9 Changing to >= and <= as it's a slight optimization 2017-02-07 09:52:23 -07:00