Commit Graph

378 Commits

Author SHA1 Message Date
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
Homu ffaee11f91 Auto merge of #188 - koverstreet:master, r=cuviper
bigint: Fix calculation of size for multiply temporaries

When x.len() and y.len() are both equal and odd, we have x1.len() + y1.len() + 1
(the required size to multiply x1 and y1) > y.len() + 1

This fixes #187
2016-04-21 08:57:08 +09:00
Kent Overstreet 1e65e9dc51 bigint: Fix calculation of size for multiply temporaries
When x.len() and y.len() are both equal and odd, we have x1.len() + y1.len() + 1
(the required size to multiply x1 and y1) > y.len() + 1

This fixes #187
2016-04-20 15:48:02 -08:00
Homu 39c1de8841 Auto merge of #137 - liebharc:master, r=cuviper
Added powc, powf, log and expf methods for complex numbers

I would like to have a few functions added for complex numbers (powf, log and exp function with arbitrary base). I've provided an implementation with this commit. However it requires more work and discussion and I've added comments to point out the parts which I'm especially unhappy with. Would be nice to get some feedback so that we can improve this pull request first.
2016-04-18 07:06:39 +09:00
Christian Liebhardt 24fcc1575a Added powc, powf, log and expf methods for complex numbers 2016-04-15 11:28:43 -07:00
Homu 0861fb4cfb Auto merge of #180 - bluss:fix-toprimitive-float, r=cuviper
Fix ToPrimitive for f64 -> f32 conversion.

Fix ToPrimitive for f64 -> f32 conversion.

It should use the destination type and not the source type to check if
the conversion would be to a value that's in range.

NOTE: A finite f64 value that is larger than the f32 value range now produces
None when converted to f32 with ToPrimitive.

Previously, too large f64 values would produce inf f32 values. This `as`
cast has an undefined result and was not specified to always produce for
example `inf`.

The conversion preserves nan/+-inf specifically.
2016-04-16 01:32:23 +09:00
bluss acde249bf7 traits: Fix ToPrimitive for f64 -> f32 conversion.
It should use the destination type and not the source type to check if
the conversion would be to a value that's in range.

NOTE: A finite f64 value that is larger than the f32 value range now produces
None when converted to f32 with ToPrimitive.

Previously, too large f64 values would produce inf f32 values. This `as`
cast has an undefined result and was not specified to always produce for
example `inf`.

The conversion preserves nan/+-inf specifically.
2016-04-15 13:36:29 +02:00
Josh Stone 1e192c31ae num: add path-dependency versions 2016-04-14 00:45:03 -07:00
Josh Stone 0dd410468c rational: add path-dependency versions 2016-04-14 00:39:07 -07:00
Josh Stone 164da50a99 iter: add path-dependency versions 2016-04-14 00:37:04 -07:00
Josh Stone dc733b1402 complex: add path-dependency versions 2016-04-14 00:29:19 -07:00
Josh Stone 0b79edc108 bigint: add path-dependency versions 2016-04-14 00:26:54 -07:00
Josh Stone 84ffb0ad01 integer: add path-dependency versions 2016-04-14 00:25:51 -07:00
Josh Stone 2e8ce33d84 Bump all num crates to 0.1.32 2016-04-14 00:17:42 -07:00
Homu 774bf31ec6 Auto merge of #182 - ollie27:ratio_posneg, r=cuviper
Correct Ratio::is_negative and Ratio::is_positive

Zero is not positive or negative.

This was broken in 8be7e7bab5.
2016-04-14 07:05:42 +09:00
Oliver Middleton c22e3bf9a2 Correct Ratio::is_negative and Ratio::is_positive
Zero is not positive or negative.

This was broken in 8be7e7bab5.
2016-04-13 22:47:15 +01:00
Homu 095738e7de Auto merge of #164 - rust-num:split-into-crates, r=cuviper
Move segments of library to separate crates

Issue #102

- [x] traits
- [x] bigint
- [x] integer
- [x] complex
- [x] iter
- [x] rational
2016-04-14 05:30:34 +09:00
Łukasz Jan Niemier 58b5fe5883 Serializers dependencies 2016-04-11 20:43:07 +02:00
Łukasz Jan Niemier e59ead7b3a Add Serde crate to `num_bigint` 2016-04-11 12:32:10 +02:00
Łukasz Jan Niemier 8450782413 Revert old `num` crate description 2016-04-11 12:30:16 +02:00
Łukasz Jan Niemier 3d11940538 Better descriptions for subcrates 2016-04-10 10:31:22 +02:00
Josh Stone a423b39833 .multirust.sh: use the subcrated "make test" 2016-03-25 18:30:27 -07:00
Josh Stone 015cd0be43 .travis.yml: add a verbose build
I like to have a verbose build log for automation like Travis CI,
because it sometimes helps in diagnosing failures.
2016-03-25 18:30:27 -07:00
Josh Stone c9d82acf00 test_features.sh: re-enable as a simple build 2016-03-25 18:30:27 -07:00
Josh Stone 03884fdbcc bigint: reapply #176 2016-03-25 17:50:51 -07:00
Josh Stone aebbc4fd37 bigint: fix and un-ignore the first doctest 2016-03-25 17:50:51 -07:00
Josh Stone 8845ee11ed integer: reapply the rest of #167 2016-03-25 17:50:51 -07:00