Commit Graph

51 Commits

Author SHA1 Message Date
Vinzent Steinberg 3e4595eac6 Move functions remaining in num to num-traits
Fixes #102.
2016-05-13 10:38:14 +02: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
Łukasz Jan Niemier 58b5fe5883 Serializers dependencies 2016-04-11 20:43:07 +02:00
Josh Stone c9d82acf00 test_features.sh: re-enable as a simple build 2016-03-25 18:30:27 -07:00
Josh Stone 9d439e7860 num: don't need std::hash even for testing 2016-03-25 17:50:51 -07:00
Josh Stone 529d7634dd num: use original num_foo crate names for imports
Rust 1.0.0 can't seem to find `foo::bar` imports from renamed crates like
`pub use num_foo as foo`.  Use `num_foo::bar` instead.
2016-03-25 17:50:38 -07:00
Łukasz Jan Niemier 96e9166b0a Extract iter 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier ed076070e6 Extract complex 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier 54685c46a1 Extract rational 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier 2176b7048c Extract bigint 2016-03-11 01:06:05 +01:00
Łukasz Jan Niemier f1a80857ee Extract integer module 2016-03-11 01:06:05 +01:00
Łukasz Jan Niemier c124be549f Move traits to separate crate 2016-03-11 01:06:05 +01:00
Erick Tryzelaar 112923eec5 Add support for Serde 0.7.
Serde 0.7 dropped it's dependency on num, so this patch moves
the implementations here. For the sake of a better implementation,
this just serializes BigUint as a `Vec<u32>`, `BigInt` as a
`(u8, Vec<u32>)`, `Complex<T>` as a `(T, T)`, and `Ratio<T>`
as a `(T, T)`.
2016-02-27 00:07:32 -08:00
Josh Stone 9b2116d78f Fix spelling of "occurred". 2016-02-05 16:04:34 -08:00
est31 3c5ecdc636 Add checked_pow function 2016-02-03 06:43:40 +01:00
Brian Smith 9e3e8552ac Make `rand` and `rustc-serialize` dependencies optional.
Previously, the `rand` and `rustc-serialize` dependencies were optional
except they were required for the `bigint` feature.

Make the dependency on the `rand` crate optional in all cases.
including when the `bigint` feature is selected. Some of the tests for
the bigint feature are randomized so, while `rand` is now an optional
dependency, it is a non-optional dev-dependency.

Similarly, make the dependency on the `rustc-serialize` crate optional
in all cases, including when the `bigint` feature is selected.
2016-01-07 16:30:50 -10:00
Josh Stone 22722ac55d pow: shift exp powers of 2 before accumulating
We can save a multiplication if we start the accumulation basically at
the first set bit of the exponent, rather than starting at one and
waiting to multiply.  We only need one itself if the exponent is zero,
which is easy to pre-check.

Before:
    test pow_bench         ... bench:   8,267,370 ns/iter (+/- 93,319)

After:
    test pow_bench         ... bench:   7,506,463 ns/iter (+/- 116,311)
2016-01-06 18:32:01 -08:00
Josh Stone 2e3e575117 Fix the feature masks in the approx_sqrt doc example
The hidden "mod test" layout of the first example has been broken for a
while, but it wasn't noticed because rustdoc wasn't passing any features
at all.  That was fixed in rust-lang/rust#30372, and now we need to get
our ducks in a row too.
2015-12-21 12:21:47 -08:00
Josh Stone 7fa80f7786 Update intros to better reflect the breadth of num
Closes #132.
2015-11-21 16:39:00 -08:00
Josh Stone b4026b9fec Update repo and doc links 2015-11-12 18:40:13 -08:00
root 4c123a9e71 Make rustc-serialize, bignum, rational, complex into opt-out features
Making bignum optional allows skipping the rustc-serialize and rand
dependencies too, and it makes a big difference in num's build time.

With default (all) features, clean build time including dependencies: 27
seconds.

With no default features, clean build time including dependencies (none):
5 seconds.
2015-06-02 23:48:06 +02:00
Oliver Mader 785e07d83c Re-export `cast` for ergonomic reasons 2015-05-26 15:03:34 +02:00
Alex Crichton a6a399d52e Enable testing on stable Rust 2015-05-19 09:22:06 -07:00
kennytm 24d2f15ccf Avoid and remove some unstable features.
The only #[feature] left for now is the bencher.
2015-04-05 03:09:29 +08:00
Alex Crichton 996128bd4b Fix some doc tests 2015-04-03 10:26:37 -07:00
Aaron Turon 63c7a25ed9 Update to 1.0.0-beta (stable only)
Along the way, this commit also rationalizes the traits a bit more.

Moving to stable required vendoring a couple of minor things (notably,
radix formatting).
2015-04-03 10:17:39 -07:00
Huon Wilson c21b7e17d4 Feature gating is strict now. 2015-03-26 12:00:36 +11:00
Matt Brubeck 81a16f4a83 rustc-serialize is now rustc_serialize 2015-03-25 17:48:52 -07:00
Alex Crichton 445fbab108 Fix doc test 2015-03-22 10:43:11 -07:00
Josh Stone 043a5b2918 pow: avoid unnecessary overflows
The code was performing an extra squaring of the base, which might
trigger an arithmetic overflow that doesn't matter to the result.  Now
this squaring is only attempted when enough exp remains to need it.

A new doctest tries pow(6u8, 3), where an extra square would exceed 256.
2015-03-07 14:12:50 -08:00
Austin Bonander f260a7f565 Upgrade to latest Rust 2015-02-20 10:37:11 -08:00
Sam Payson 609c2e6ef0 Minor changes to silence warnings. 2015-02-18 16:41:28 -08:00
Alex Crichton e2f0b0d327 Update to rust master 2015-02-05 08:20:16 -08:00
Alex Crichton 0811c72bac Bump to 0.1.12 2015-02-03 12:37:01 -08:00
Matt Brubeck e68ea18edc Silence unstable feature warnings 2015-02-03 12:32:28 -08:00
Matt Brubeck 42edb63090 Update FromStr and FromStrRadix to return Result
Fixes build errors with Rust 1.0.0-nightly.
2015-02-03 12:31:10 -08:00
Huon Wilson 139cf8cf66 Bump to 0.1.7. 2015-01-09 22:36:03 +11:00
Alex Crichton bfa91ee92a Bump to 0.1.6 2015-01-07 12:09:44 -08:00
gifnksm 8219095e39 update to rust mater 2015-01-05 01:59:44 +09:00
Alex Crichton ce93a10ed0 Finish update and bump version number 2015-01-03 13:52:06 -08:00
Sven Nilsen ae3bb3619c Upgrade to latest Rust
A `_0` test fails, but don’t know why
2015-01-03 19:30:05 +01:00
Alex Crichton 5d4b921537 Fix build warnings 2014-12-23 09:51:08 -08:00
gifnksm a325a566c6 update to latest rustc
Now, arithmetic binary operator traits take operands by value,
but non-copyable types such as `BigUint` should not always moved out when
applying operators.

This commit implements these operators not only for bare structs also
these references.
By-value implementations are forwarded to by-reference implementations
for now. In the future, by-value implementations may be replaced with
more efficient implementations (for example, the implementation that
reuses moved buffers.)
2014-12-16 23:44:16 +09:00
Alex Crichton 01cc022174 Merge pull request #36 from steveklabnik/license
remove license attribute
2014-12-07 20:48:25 -05:00
Steve Klabnik 253f0bd3f3 don't allow deprecated items.
We don't actually use any.
2014-12-07 13:22:01 -05:00
Steve Klabnik ecc2e5fab7 remove license attribute 2014-12-07 13:20:39 -05:00
gifnksm 3568298a22 Add `iter` modules for generic number iteration.
The codes are imported from the standard library.
2014-11-16 19:37:53 +09:00
gifnksm 2155e7d2ee Add numeric functions and `traits` module that provide numeric traits for generic
mathematcs.

Import numeric traits and functions that were removed from the standard library.
This also implements `AdditiveIterator` and `MultiplicativeIterator` for
`BigUint` and `BigInt`.

closes #28
2014-11-16 19:37:49 +09:00
gifnksm 7a7c5fb2ad Implements `Encodable` and `Decodable`
Fixes #27
2014-11-13 20:54:42 +09:00
gifnksm 163646cd63 Use sliciing_syntax 2014-11-05 07:32:00 +09:00