Commit Graph

719 Commits

Author SHA1 Message Date
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
Josh Stone 31fa9f626a Merge pull request #316 from cuviper/bors-ng
Enable bors-ng
2017-07-08 22:51:41 -07:00
Josh Stone b181cae401 Enable bors-ng 2017-07-08 22:29:48 -07:00
Josh Stone 3299702e69 Whitelist branches for CI 2017-07-08 22:28:49 -07:00
Lee Bousfield aaa4ab357f
Clarify what "newer versions of Rust" applies to 2017-07-08 17:21:32 -04:00
Lee Bousfield f0fa65a9d5
Fix float NaN pos/neg assumptions 2017-07-08 17:15:35 -04:00
Lee Bousfield 5f3a3b0004
Derive ToPrimitive for enums 2017-07-08 11:24:42 -04:00
Sam Cappleman-Lynes 1fb03ca18a Make new code work on rustc-1.8.0
- Don't apply attributes to statements (1.12.0)
 - Don't use checked_abs (1.13.0)
2017-06-30 00:39:37 +01:00
Sam Cappleman-Lynes 2a3cd41820 Add scalar ops for all remaining integer types 2017-06-29 22:18:54 +01:00
Sam Cappleman-Lynes fd87d87db3 Fix normalization in scalar addition 2017-06-29 20:40:54 +01:00
Josh Stone 3f32ad48f4 rational: make sure Hash agrees with Eq
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.
2017-06-29 11:52:25 -07:00
Sam Cappleman-Lynes 99873d06e5 Scalar operations on integer types up to 32 bits 2017-06-29 18:29:14 +01:00
Sam Cappleman-Lynes 94d570697c Add operations on i32 to BigInt 2017-06-29 17:20:17 +01:00
Sam Cappleman-Lynes 9b0392d235 Add scalar division to BigInt 2017-06-29 16:19:11 +01:00
Sam Cappleman-Lynes 8b1288ea01 Add scalar multiplication to BigInt 2017-06-29 15:46:07 +01:00
Sam Cappleman-Lynes 79448cbdf9 Add scalar subtraction to BigInt 2017-06-29 15:15:59 +01:00
Sam Cappleman-Lynes 80feea2722 Also implement scalar addition for BigInt 2017-06-29 14:07:44 +01:00
Sam Cappleman-Lynes 1e26bdde81 Remove unnecessary normalization 2017-06-29 13:53:08 +01:00
Sam Cappleman-Lynes d0bfb54eee All variants of dividing BigUint by BigDigit
Allow the division to occur with either operand order and with any
combination of owned and borrowed arguments.
2017-06-29 13:38:00 +01:00
Sam Cappleman-Lynes 51408a9b3b All variants of subtracting BigDigit from BigUint
Allow the subtraction to occur with either operand order and with any
combination of owned and borrowed arguments.
2017-06-29 10:12:53 +01:00
Sam Cappleman-Lynes 5738141b7c Distinction for commutative scalar ops 2017-06-29 09:59:42 +01:00
Sam Cappleman-Lynes fd2f516a5d All variants of multiplying BigUint by BigDigit
Allow the multiplication to occur with either operand order and with any
combination of owned and borrowed arguments.
2017-06-29 09:56:15 +01:00
Sam Cappleman-Lynes e5ed503141 Implement all variants of adding BigDigit to BigUint
Allow the addition to occur with either operand order, and with any combination
of owned and borrowed arguments.
2017-06-29 08:41:46 +01:00
Sam Cappleman-Lynes 784d26bbf8 Scalar division of a BigUint by a BigDigit
A BigUint can be divided by a BigDigit - this is one of several
operations being implemented to allow scalar operations on BigInt and
BigUint across the board.
2017-06-28 16:59:35 +01:00
Sam Cappleman-Lynes 530e2f6022 Fix typo in comment in division algorithm 2017-06-28 16:26:40 +01:00
Sam Cappleman-Lynes 7b7799eab7 Scalar subtraction of a BigDigit from a BigUint
A BigDigit can be subtracted from a BigUint - this is one of several
operations being implemented to allow scalar operations on BigInt and
BigUint across the board.
2017-06-28 16:24:56 +01:00
Sam Cappleman-Lynes a2a28c682e Scalar addition of BigDigit to BigUint
A BigDigit can be added to a BigUint - this is one of several
operations being implemented to allow scalar operations on BigInt and
BigUint across the board.
2017-06-28 16:11:02 +01:00