Commit Graph

404 Commits

Author SHA1 Message Date
Josh Stone c8ed8ff87b num, bigint, complex, rational, traits: 0.1.35 2016-08-18 08:28:34 -07:00
Homu 4fb22849b4 Auto merge of #222 - SuperFluffy:serde_0.8, r=cuviper
Use serde 0.8

I updated `bigint`, `complex`, and `rational` to use `serde 0.8`, and also fixed deserialization and the `serde` feature as such in the `rational` crate (didn't add any tests, but it compiles now).

Similar to https://github.com/rust-num/num/pull/196 for `num/complex`, “`use serde;`” needed to be removed in `num/rational`.
2016-08-18 06:24:42 +09:00
Richard Janis Goldschmidt 4f6f7b3292 Add travis build test of 0.7.0 channel 2016-08-17 23:12:20 +02:00
Homu b0fbcedfa0 Auto merge of #223 - SuperFluffy:fix_import_serde, r=cuviper
Fix import serde and rational deserialization

Similar to #196 for num/complex, “use serde;” needed to be removed in num/rational.

Also, deserialization of `num/rational` needed to be fixed by adding type annotations.

This is in response to https://github.com/rust-num/num/pull/222#issuecomment-239957062 of issue https://github.com/rust-num/num/pull/222.

Also added a travis line, in response to https://github.com/rust-num/num/pull/222#issuecomment-239957062. Hope it works.
2016-08-18 03:59:26 +09:00
Richard Janis Goldschmidt a4ccb797cf Allow serde version in [0.7,0.9) 2016-08-17 12:20:08 +02:00
Richard Janis Goldschmidt eb486e8dc1 Add build test for serde feature 2016-08-17 12:19:51 +02:00
Richard Janis Goldschmidt 20360ebccf Fix deserialization by giving type annotations. 2016-08-17 12:05:09 +02:00
Richard Janis Goldschmidt 7339d6cb9a Remove redundant `use serde`; it is an external crate. 2016-08-17 12:05:09 +02:00
Homu ccdf307cee Auto merge of #220 - IvanUkhov:constant, r=cuviper
Add a trait for floating-point constants

The pull request is to address issue #194. In order to keep the library organized, I’ve introduced a new trait for the new functionality. The trait is supposed to closely follows the [`consts`](https://doc.rust-lang.org/std/f64/consts/index.html) module from the standard library. There are at least the following three open questions:

1. What should the name of the trait be? Currently, it’s `Constant`; an alternative is `Consts`.
2. What should the names of the getters be? Currently, they are lower-case versions of the constants defined in the `consts` module. Note that `Float` provides `log2` and `log10`, whereas `LOG_2` and `LOG_10` get translated into `log_2` and `log_10`, respectively.
3. Should `Float` require the new trait? Or should it be left up to the user?

Please let me know what you think. Thank you!

Regards,
Ivan
2016-08-16 10:29:20 +09:00
Ivan Ukhov 01aad702af Add a trait for floating-point constants 2016-08-15 06:38:08 +02:00
Homu 10a57ef1a6 Auto merge of #219 - cuviper:tiny-inline, r=hauleth
Inline small functions, especially wrappers

We already had `#[inline]` throughout a lot of the code, but notably some
functions which simply wrap inherent methods were not inlined.  That means
external references will get a full function call, when they could have been
optimized to as little as one opcode.

This PR inlines all functions that look tiny enough for this to matter.

Fixes #218.
2016-08-11 19:56:12 +09:00
Josh Stone 5c3d759d6c bigint: inline bits() methods 2016-08-10 22:23:28 -07:00
Josh Stone 932e45c207 traits: inline integer from_str_radix 2016-08-10 22:22:53 -07:00
Josh Stone 7a9c39fa87 traits: inline Bounded tuple methods 2016-08-10 22:22:15 -07:00
Josh Stone fa451ac00c traits: inline Saturating methods 2016-08-10 22:21:53 -07:00
Josh Stone eefa2a85d0 traits: inline Float methods 2016-08-10 22:21:33 -07:00
Josh Stone 7bc7ddfc87 traits: inline PrimInt methods 2016-08-10 22:21:00 -07:00
Homu d9f08cb148 Auto merge of #213 - ExpHP:ratio-pr3, r=cuviper
rational: recip bugfix and documentation tweaks

Cherry picked from #210 (minus the `new_raw` stuff), with small additions [in a third commit](32dee9a0c8).
2016-07-25 14:00:23 +09:00
Michael Lamparski 32dee9a0c8 rational: small additional tweaks
Move `new` to top to make it more visible in the docs.

Replace instances of $x == Zero::zero()$ with $x.is_zero()$,
partially addressing #11.
2016-07-24 14:58:43 -04:00
Michael Lamparski 8c75506f22 Ratio::recip now corrects sign and fails for zero 2016-07-24 14:54:06 -04:00
Michael Lamparski c84c4d15ba Improve Ratio docs
Closes #208.  Clarifies the rounding behavior of some methods and
makes formatting more uniform.
2016-07-24 14:34:55 -04:00
Josh Stone 29c5ab362d traits: bump to 0.1.34 2016-07-24 11:16:11 -07:00
Homu f1574d844b Auto merge of #212 - cuviper:float-deg-rad, r=cuviper
traits: add `to_degrees` and `to_radians` on `Float`

To avoid a breaking change, these have crude default implementations as
well as better implementations for `f32` and `f64` in particular.  They
don't use the inherent methods though, because `f32` didn't stabilize
those until Rust 1.7.

Fixes #211
2016-07-24 09:56:25 +09:00
Josh Stone 0faeb31b09 traits: add `to_degrees` and `to_radians` on `Float`
To avoid a breaking change, these have crude default implementations as
well as better implementations for `f32` and `f64` in particular.  They
don't use the inherent methods though, because `f32` didn't stabilize
those until Rust 1.7.

Fixes #211
2016-07-23 00:34:14 -07:00
Homu ad5a322868 Auto merge of #207 - koverstreet:master, r=cuviper
bigint: Break out into multiple files
2016-07-19 09:07:17 +09:00
Kent Overstreet 279522316c bigint: Break out into multiple files 2016-07-18 15:56:03 -08:00
Homu 78bad13948 Auto merge of #204 - koverstreet:master, r=cuviper
Minor optimization, prep work for more optimization

The patch "drop some dependencies on BigDigit's size" is the one I'd really like to get in.
2016-07-15 15:36:44 +09:00
Kent Overstreet 8e0baecf5c Drop some dependencies on BigDigit's size
Before:
test divide_0          ... bench:       1,011 ns/iter (+/- 184)
test divide_1          ... bench:      18,535 ns/iter (+/- 770)
test divide_2          ... bench:     990,467 ns/iter (+/- 91,980)
test fac_to_string     ... bench:       1,275 ns/iter (+/- 60)
test factorial_100     ... bench:       6,453 ns/iter (+/- 101)
test fib_100           ... bench:       1,142 ns/iter (+/- 99)
test fib_1000          ... bench:      18,713 ns/iter (+/- 2,172)
test fib_10000         ... bench:   1,197,965 ns/iter (+/- 21,178)
test fib_to_string     ... bench:         225 ns/iter (+/- 13)
test from_str_radix_02 ... bench:       3,460 ns/iter (+/- 626)
test from_str_radix_08 ... bench:       1,324 ns/iter (+/- 24)
test from_str_radix_10 ... bench:       1,488 ns/iter (+/- 19)
test from_str_radix_16 ... bench:         969 ns/iter (+/- 22)
test from_str_radix_36 ... bench:       1,135 ns/iter (+/- 23)
test hash              ... bench:     102,126 ns/iter (+/- 1,016)
test multiply_0        ... bench:         353 ns/iter (+/- 74)
test multiply_1        ... bench:      31,006 ns/iter (+/- 679)
test multiply_2        ... bench:   3,438,143 ns/iter (+/- 47,640)
test pow_bench         ... bench:   7,457,045 ns/iter (+/- 96,175)
test shl               ... bench:       5,627 ns/iter (+/- 121)
test shr               ... bench:       5,054 ns/iter (+/- 112)
test to_str_radix_02   ... bench:       2,774 ns/iter (+/- 88)
test to_str_radix_08   ... bench:         980 ns/iter (+/- 425)
test to_str_radix_10   ... bench:       3,029 ns/iter (+/- 115)
test to_str_radix_16   ... bench:         788 ns/iter (+/- 14)
test to_str_radix_36   ... bench:       8,285 ns/iter (+/- 175)

After:
test divide_0          ... bench:         925 ns/iter (+/- 30)
test divide_1          ... bench:      17,660 ns/iter (+/- 379)
test divide_2          ... bench:     972,427 ns/iter (+/- 7,560)
test fac_to_string     ... bench:       1,260 ns/iter (+/- 36)
test factorial_100     ... bench:       7,077 ns/iter (+/- 204)
test fib_100           ... bench:       1,124 ns/iter (+/- 32)
test fib_1000          ... bench:      18,475 ns/iter (+/- 166)
test fib_10000         ... bench:   1,192,748 ns/iter (+/- 27,128)
test fib_to_string     ... bench:         228 ns/iter (+/- 10)
test from_str_radix_02 ... bench:       3,379 ns/iter (+/- 74)
test from_str_radix_08 ... bench:       1,355 ns/iter (+/- 24)
test from_str_radix_10 ... bench:       1,470 ns/iter (+/- 20)
test from_str_radix_16 ... bench:         958 ns/iter (+/- 239)
test from_str_radix_36 ... bench:       1,137 ns/iter (+/- 19)
test hash              ... bench:     102,730 ns/iter (+/- 39,897)
test multiply_0        ... bench:         351 ns/iter (+/- 15)
test multiply_1        ... bench:      31,139 ns/iter (+/- 1,053)
test multiply_2        ... bench:   3,464,509 ns/iter (+/- 124,235)
test pow_bench         ... bench:   7,448,428 ns/iter (+/- 326,903)
test shl               ... bench:       5,784 ns/iter (+/- 190)
test shr               ... bench:       4,820 ns/iter (+/- 63)
test to_str_radix_02   ... bench:       2,757 ns/iter (+/- 33)
test to_str_radix_08   ... bench:         989 ns/iter (+/- 67)
test to_str_radix_10   ... bench:       3,045 ns/iter (+/- 70)
test to_str_radix_16   ... bench:         787 ns/iter (+/- 24)
test to_str_radix_36   ... bench:       8,257 ns/iter (+/- 117)/
2016-07-14 21:56:16 -08:00
Josh Stone e67d4630a2 num: require newer traits for moved functions, fixes #206 2016-07-12 23:24:45 -07:00
Josh Stone 29b63410ac num: bump to 0.1.33 2016-07-12 01:12:41 -07:00
Josh Stone 18b3cb425d complex: bump to 0.1.33 2016-07-12 01:10:37 -07:00
Josh Stone 9924163086 bigint: bump to 0.1.33 2016-07-12 01:10:37 -07:00
Josh Stone f056603bc0 traits: bump to 0.1.33 2016-07-12 01:10:37 -07:00
Josh Stone 8f5a27284c Remove an unused ToBigUint import 2016-07-12 00:40:10 -07:00
Josh Stone b21c89de36 Mask deprecation warnings on abs_sub 2016-07-12 00:34:55 -07:00
Josh Stone 15949b257a Move .multirust.sh to .rustup.sh
(rustup is pickier about paths to non-rust commands though...)
2016-07-12 00:34:27 -07:00
Homu 7fcd5f7304 Auto merge of #205 - cuviper:bigint-sub, r=hauleth
bigint: allow `Sub` to work in-place on the RHS

A new Fibonacci benchmark demonstrates the improvement by using both
addition and subtraction in each iteration of the loop, like #200.

Before:

    test fib2_100          ... bench:       4,558 ns/iter (+/- 3,357)
    test fib2_1000         ... bench:      62,575 ns/iter (+/- 5,200)
    test fib2_10000        ... bench:   2,898,425 ns/iter (+/- 207,973)

After:

    test fib2_100          ... bench:       1,973 ns/iter (+/- 102)
    test fib2_1000         ... bench:      41,203 ns/iter (+/- 947)
    test fib2_10000        ... bench:   2,544,272 ns/iter (+/- 45,183)
2016-07-11 01:21:49 +09:00
Josh Stone 388a3132b8 bigint: allow `Sub` to work in-place on the RHS
A new Fibonacci benchmark demonstrates the improvement by using both
addition and subtraction in each iteration of the loop, like #200.

Before:

    test fib2_100          ... bench:       4,558 ns/iter (+/- 3,357)
    test fib2_1000         ... bench:      62,575 ns/iter (+/- 5,200)
    test fib2_10000        ... bench:   2,898,425 ns/iter (+/- 207,973)

After:

    test fib2_100          ... bench:       1,973 ns/iter (+/- 102)
    test fib2_1000         ... bench:      41,203 ns/iter (+/- 947)
    test fib2_10000        ... bench:   2,544,272 ns/iter (+/- 45,183)
2016-07-08 17:34:12 -07:00
Josh Stone a7ac5e4299 Merge pull request #199 from adamcrume/master, r=hauleth
Implement Default for Complex
2016-07-01 10:19:08 -07:00
Josh Stone 1e663952fc Merge pull request #201 from cuviper/faster-add2-sub2, r=hauleth
bigint: simplify the add2/sub2 loops
2016-07-01 10:18:32 -07:00
Adam Crume c7c974ec4b Implement Default for Complex
Fixes #198
2016-06-29 18:33:19 -07:00
Josh Stone 609629d34d bigint: simplify the add2/sub2 loops
This splits the main arithmetic loops from the final carry/borrow
propagation, and also normalizes the slice lengths before iteration.
This lets the optimizer generate better code for these functions.
2016-06-29 18:19:47 -07:00
Homu f0bc5596af Auto merge of #196 - SuperFluffy:remove_use_serde, r=hauleth
`use serde;` leads to compilation error; `extern crate` is enough

This PR fixes the compile error of `num-complex` that appears due to a redundant `use serde;` after `extern crate serde;` in the same module. To reproduce the error, just build `num-complex` with the feature `serde`, see below.

```zsh
% cargo build --features serde
   Compiling num-complex v0.1.32 (file:///home/janis/github/num/complex)
src/lib.rs:27:5: 27:10 error: an extern crate named `serde` has already been imported in this module [E0259]
src/lib.rs:27 use serde;
                  ^~~~~
src/lib.rs:19:1: 19:20 note: previous import of `serde` here
src/lib.rs:19 extern crate serde;
              ^~~~~~~~~~~~~~~~~~~
src/lib.rs:27:5: 27:10 help: run `rustc --explain E0259` to see a detailed explanation
error: aborting due to previous error
error: Could not compile `num-complex`.
```
2016-06-13 23:14:11 +09:00
Richard Janis Goldschmidt c8543380ea Remove `use`ing serde. Import through `extern crate` is enough 2016-06-13 15:46:56 +02:00
Josh Stone 72a146b9ed macros: bump to 0.1.33 2016-05-18 16:28:32 -07:00
Josh Stone 0adac57e11 macros: init MethodDef.unify_fieldless_variants to false
AFAICT this field is irrelevant to us, but it still must be initialized.
2016-05-18 16:24:33 -07:00
Homu ace0951f2a Auto merge of #192 - vks:split-func, r=cuviper
Move functions remaining in num to num-traits

Fixes #102.
2016-05-14 02:36:58 +09:00
Vinzent Steinberg 3e4595eac6 Move functions remaining in num to num-traits
Fixes #102.
2016-05-13 10:38:14 +02:00
Homu 4bbc34b083 Auto merge of #190 - rust-num:private-crates, r=cuviper
num: remove `pub` from sub-crates

Rust 1.4 through 1.7 will issue warnings that `pub extern crate` does
not work as expected, although it appears to be fine.  But Rust 1.8 and
later issue `#[warn(private_in_public)]` for `pub use num_foo as foo` if
that crate isn't public, and that's headed toward a hard error.

@bluss suggested instead `pub mod foo { pub use num_foo::*; }`, which
I thought I had tried before, but it appears to work fine on all
versions of Rust.  Let's do it!

A small downside is that docs for `num::foo` now just show the wildcard
reexport, instead of direct documentation, but at least there's a link
to follow to the sub-crate.

It's a breaking change that `num::num_foo` paths are no longer public,
but we didn't really want those exposed in the first place.  I consider
this minor -- people should either use the `num::foo` module as before
the split-up, or use the `num_foo` crate directly.

Fixes #189.
2016-05-13 04:55:55 +09:00
Josh Stone 865c491ce2 num: remove `pub` from sub-crates
Rust 1.4 through 1.7 will issue warnings that `pub extern crate` does
not work as expected, although it appears to be fine.  But Rust 1.8 and
later issue `#[warn(private_in_public)]` for `pub use num_foo as foo` if
that crate isn't public, and that's headed toward a hard error.

@bluss suggested instead `pub mod foo { pub use num_foo::*; }`, which
I thought I had tried before, but it appears to work fine on all
versions of Rust.  Let's do it!

A small downside is that docs for `num::foo` now just show the wildcard
reexport, instead of direct documentation, but at least there's a link
to follow to the sub-crate.

It's a breaking change that `num::num_foo` paths are no longer public,
but we didn't really want those exposed in the first place.  I consider
this minor -- people should either use the `num::foo` module as before
the split-up, or use the `num_foo` crate directly.

Fixes #189.
2016-04-29 15:36:17 -07:00