Commit Graph

745 Commits

Author SHA1 Message Date
Nicolas Kirchner 10127907f5 Add a bench for bigint multiply
This bench allows to see the increase of time
if we double the size of one of the operands.
2017-08-03 18:30:09 +02:00
bors[bot] e7df30bac4 Merge #325
325: Implement assign_from_slice r=cuviper

This commit implements `assign_from_slice(..)` for `BigUint` and `BigInt`. `assig_from_slice` is for performance : it allows to reassign a value to a `BigInt` or a `BigUint` without useless reallocations. It would be useful for loops for example. I need it to implement the Toom-3 algorithm.

I also added a missing test for `BigInt::from_slice(..)`.
2017-08-03 01:23:53 +00:00
Nicolas Kirchner cbdaf8f6f9 Optimize `BigInt::from_biguint` and `BigInt::assign_from_slice`
It removes useless memory allocations.
2017-08-02 22:25:21 +02:00
Nicolas Kirchner 5106fcc95a Replace `Vec::copy_from_slice` not implemented in rust 1.8 by another method 2017-08-02 16:38:38 +02:00
Nicolas Kirchner 9b56d6667c Implement assign_from_slice 2017-08-02 16:12:04 +02:00
bors[bot] 54fe41f305 Merge #323 #324
323: Add CI badge r=cuviper



324: Add CI badge r=cuviper

This adds the CI badge to the pages on crates.io, #323 adds it to the README. Sorry for the separate PRs, but I didn't feel like forking and cloning the repository down to my laptop and simply used the GitHub online editor instead :-)
2017-07-25 00:21:18 +00:00
Martin Geisler 97bc42854a Add CI badge 2017-07-25 00:17:17 +02:00
Martin Geisler 8d64ff9708 Add CI badge 2017-07-25 00:16:07 +02:00
Josh Stone 846ef39ba6 complex: bump to 0.1.40 with fixed traits dep 2017-07-23 21:24:34 -07:00
bors[bot] a8ebac5af1 Merge #317
317: Feature/complex from str r=cuviper

This commit adds a basic parser for Complex types in Cartesian form, per https://github.com/rust-num/num/issues/289. It will take numbers of the form `a + bi`, `ai + b`, `a - bi`, `ai - b`, `a`, or `ai`. At least one space between the real/imaginary parts and the operator is mandatory; without bringing in a dependency on some regex crate, it's nontrivial to handle cases like, e.g., 0.217828e+1+31.4159E-1, or a similar case with polar coordinates. I could work on these issues later if you like.
2017-07-19 22:19:24 +00:00
Josh Stone ee6bbdb2f6 complex: refactor ParseComplexError a little 2017-07-19 15:16:34 -07:00
Josh Stone bd22a89a32 complex: Simplify the from_str signature 2017-07-19 12:49:03 -07:00
Josh Stone 79c7a4be5f complex: relax the FromStr trait requirements even more 2017-07-19 12:47:07 -07:00
Alan Liddell 16a180f132 simplifies parse loop, allows leading '+', parametrizes Error on T::Err 2017-07-19 06:03:05 -04:00
Alan Liddell add0fbf0f0 More informative error messages for complex::from_str 2017-07-16 15:20:50 -04:00
Alan Liddell 38ee1304bb Cleaned out some allocations 2017-07-16 09:51:55 -04:00
Josh Stone 23d1ab689d num: bump to 0.1.40 2017-07-14 17:42:00 -07:00
Josh Stone 4e9b426c30 rational: bump to 0.1.39 2017-07-14 17:39:21 -07:00
Josh Stone fe55d1fb4e iter: bump to 0.1.34 2017-07-14 17:38:12 -07:00
Josh Stone 59b8433a5e derive: bump to 0.1.41 2017-07-14 17:36:17 -07:00
Josh Stone 11a23dd5d7 complex: bump to 0.1.39 2017-07-14 17:33:58 -07:00
Josh Stone ea2158f3dd bigint: bump to 0.1.40 2017-07-14 17:32:18 -07:00
Josh Stone 63aa15ae9a integer: bump to 0.1.35 2017-07-14 17:30:18 -07:00
Josh Stone ca433f74ab traits: bump to 0.1.40 2017-07-14 17:28:12 -07:00
Alan Liddell 97e6d45d03 Adds more tests, including failure cases 2017-07-13 14:50:27 -04:00
Alan Liddell 14d323f5a3 Allows 'j' for imaginary unit 2017-07-13 14:13:04 -04:00
Alan Liddell ac746c2a5d Allows for arbitrary spacing between operands when parsing Complex 2017-07-13 14:05:44 -04:00
bors[bot] d159ed63be Merge #320
320: complex: implement real ops directly r=cuviper

It's more efficient to implement these without creating an intermediate
complex value -- at the least, we don't have to rely on the compiler
optimizing out zero-ops.
2017-07-12 22:03:07 +00:00
bors[bot] a07eaab226 Merge #274
274: Implement OpAssign for Complex r=cuviper

Design choice: Use by-value forms of OpAssign and use Clone to forward the reference arguments. That matches what the other traits do (for example Add).

Design choice: The complex += complex operation needs Add, not just AddAssign. The complex += real operation can use just AddAssign. You could just use Add for both, not sure which way is preferable.
2017-07-12 21:41:21 +00:00
Josh Stone f06f5c548e complex: implement real ops directly
It's more efficient to implement these without creating an intermediate
complex value -- at the least, we don't have to rely on the compiler
optimizing out zero-ops.
2017-07-12 14:37:50 -07:00
Josh Stone d57c0c2879 complex: implement add/sub_assign directly 2017-07-12 13:59:30 -07:00
Josh Stone 055c6693b1 complex: require T:NumAssign for assign ops 2017-07-12 13:54:57 -07:00
bluss 686411f44e complex: Add tests for OpAssign
Add tests by expanding the current a + b tests to include a += b, and so
on.
2017-07-12 13:48:12 -07:00
bluss 3ec194bafb complex: implement OpAssign for Complex<T> 2017-07-12 13:48:12 -07:00
bors[bot] ebc36b3e55 Merge #313
313: Scalar operations across all integer types r=cuviper

With my apologies for opening a new PR, and also for the 8 month delay, this continues the work started in #237 - the discussion there outlines the goals I was aiming for. I suppose this supersedes that PR and the other one can now be closed.

This PR adds support for Add, Sub, Mul, Div and Rem operations involving one BigInt/BigUint and one primitive integer, with operands in either order, and any combination of owned/borrowed arguments.
2017-07-12 05:16:29 +00:00
Josh Stone e5434dc659 Add assert_scalar_op! for DRYer testing 2017-07-11 21:59:10 -07:00
Josh Stone 6afac825d9 test and fix more scalar add cases 2017-07-11 17:27:19 -07:00
Josh Stone 18a5bfcd0b fix endianness of to/from_doublebigdigit calls 2017-07-11 17:22:11 -07:00
Josh Stone 18cc1902fb inline i32_abs_as_u32 and i64_abs_as_u64 2017-07-11 17:01:15 -07:00
bors[bot] 73a2dfd647 Merge #314
314: Derive ToPrimitive for enums r=cuviper

I had to double the compile fail tests, as they will bail on the first error.

I have some ideas for more complex to/from primitive derives (with inner values that implement to/from primitive), but I'll save those for a future PR.
2017-07-11 22:28:02 +00:00
bors[bot] 26af99cf39 Merge #318
318: Add cargo keywords and categories. r=cuviper

Fixes #306. Suggestions welcome for better keywords/categories, though there is a limit of 5 of each.
2017-07-11 22:20:41 +00:00
Keith Wansbrough ef83e851e7 Add keywords and categories to subcrates too. 2017-07-11 09:30:42 +01:00
Keith Wansbrough c87faf46a6 Tweak categories based on review. 2017-07-11 09:47:15 +01:00
Keith Wansbrough eddcb54d6b Add cargo keywords and categories.
Resolves #306. Suggestions welcome for better keywords/categories, though there is a limit of 5 of each.
2017-07-11 09:47:15 +01:00
bors[bot] bcccab17dd Merge #311
311: rational: make sure Hash agrees with Eq r=cuviper

We can't use a derived `Hash` when we have a manual `Eq`, because we
need to uphold the invariant `a == b` → `h(a) == h(b)`.  Since `Eq`
doesn't require them to be in reduced form, `Hash` also needs to be
normalized.

Fixes #310.
2017-07-10 20:12:23 +00:00
bors[bot] 36b492a191 Merge #315
315: Fix float NaN positive/negative assumptions r=cuviper

These are the minimal assumptions to make about `NaN`. Fixes part of #312 (but not the `next` branch).
2017-07-10 17:31:04 +00:00
Alan Liddell e5e8266009 handles case where imaginary part is just 'i' or '-i', adds tests 2017-07-10 09:51:46 -04:00
Alan Liddell 506fbaf4e7 swap 'Some(u)' out for '_' to suppress unused variable warnings 2017-07-10 08:09:49 -04:00
Alan Liddell 3c490cdee4 adds basic parser for complex numbers in Cartesian form 2017-07-10 05:57:38 -04:00
Lee Bousfield 426034ba09
Switch doctests to match functions 2017-07-09 08:30:22 -04:00