33 Commits
Author SHA1 Message Date
Ole Begemann 0ed7e786b5 Remove broken link in Real module readme
The link target for `[Real]` wasn't defined. I decided toremove the link altogether because the readme would essentially link to itself.
2019-11-12 17:28:36 +01:00
Stephen CanonandXiaodi Wu 5d783ce458 Update Sources/Real/ScalarConformances.swift
Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>
2019-11-10 22:19:39 -05:00
Stephen CanonandXiaodi Wu 3fbc22cbe3 Update Sources/Real/ScalarConformances.swift
Co-Authored-By: Xiaodi Wu <xiaodi.wu@gmail.com>
2019-11-10 22:19:30 -05:00
Stephen Canon e24586e2b1 Defer to libm cbrt for root(x,3).
This lets us get exact cases right only platforms where cbrt(x) has sub-ulp accuracy. It doesn't get all the other non-power-of-two roots quite right, and is still dependent on the host system, but 2 and 3 are the most common roots people take by far, so it's a good first step.
2019-11-10 22:02:53 -05:00
Stephen Canon 6d904ea56c Add documentation for AdditiveArithmetic conformance of ElementaryFunctions 2019-11-10 21:12:37 -05:00
NevinBR 6195693e3a Made ElementaryFunctions refine AdditiveArithmetic 2019-11-10 19:58:07 -05:00
Stephen Canon 3519620ac6 Merge pull request #65 from stephentyrone/split-codable-make-debugDecription-unconditional
Split Codable conformance of Complex into Encodable and Decodable. NFC.
2019-11-10 14:59:18 -05:00
Stephen Canon 0ddfd0ead7 Split Codable conformance of Complex into Encodable and Decodable. NFC.
Also make conformance to CustomDebugStringConvertible unconditional using String(reflecting:) on x and y.
2019-11-10 14:32:09 -05:00
NevinBR ab19494638 Fixed typo in a comment 2019-11-10 10:35:22 -05:00
Noah Wilder b46bd9a83e Fixed Complex division by zero to return .infinity 2019-11-09 01:37:27 -05:00
araki cd4a8b41cf Make Complex SignedNumeric 2019-11-09 10:13:37 +09:00
Stephen Canon 5d4368257e Merge pull request #36 from Sajjon/fix_typos_in_code
Fix typos in source code
2019-11-08 09:33:23 -05:00
Sajjon 0cc4950453 Adding MARK in long source file 2019-11-08 08:39:27 +01:00
Sajjon c423f9592b Fix typos in source code 2019-11-08 08:39:07 +01:00
Noah Wilder 0308def714 Added setters for real and imaginary properties of Complex 2019-11-07 23:51:40 -05:00
Stephen Canon 37253aa0b6 Update Real module README to bring it in line with the Swift Numerics blog post. 2019-11-06 12:58:09 -05:00
Stephen Canon f59e64a1aa Rename ElementaryFunctions module -> Real
No change to the protocols involved, purely a change so that the module that users import shares the name of the feature they are most likely to be using, rather than a somewhat-esoteric implementation detail.
2019-11-06 12:40:12 -05:00
Stephen Canon fe37d9896e Further complex divide benchamark and performance work (#29)
Instead of using @_specialize, mark the rescaled division @_aEIC + inline(never). This more closely matches the semantics of what we want, gets better performance, and fixes the issue for every type, not only the types on which we specialize. This is probably as good as we can do for now.
2019-11-04 11:37:51 -05:00
Stephen Canon a2353c82df Further benchmark improvments, workaround hypot bug. (#28)
Added benchmark version that defeats hoisting part of the divide computation outside of the workloop (but kept the old ones as well, because *both* are good representitives of what we want to track). Also found a bug in macOS hypot very close to the overflow boundary for the naive algorithm, and added a workaround (also reported the bug).
2019-11-02 21:40:00 -04:00
Stephen Canon e387654448 More complex testing, and split it apart into multiple files.
Added some performance tests for multiply/divide, and some transparent annotations to the source where necessary for performance reasons. Additionally removed the Linux test information, since that's no longer necessary with test discovery in swiftpm.

Also added a new `var reciprocal: Self?` for Complex that allows for more efficient divisions when a divisor is used repeatedly, while avoiding the accuracy hazard of using `1/self` when a value is poorly scaled.
2019-11-01 21:16:15 -04:00
Stephen Canon 9b3bd5af26 Beef up complex multiply/divide testing, fix an edge-case that it turned up.
Previously we simply checked if the result of the naive divide was normal; this isn't quite right, because it could miss unsafeLengthSquared underflowing without going all the way to zero, resulting in significant loss of intermediate precision. Instead check if unsafeLengthSquared itself is non-normal. This is actually a cheaper check, and gets us everything we need, so it's a win-win.

Proof: if w.unsafeLengthSquared is normal, then so is w.conjugate.divided(by: unsafeLengthSquared), which means that we're left only with the multiply. Our goal is to be only as good as multiply is, so that's good enough.
2019-10-31 16:00:34 -04:00
Stephen Canon fdc2268885 Fixup formatting of bulleted list in complex README. 2019-10-31 13:42:21 -04:00
Stephen Canon 78042238c0 Further README improvements.
Add one README for each module, format READMEs consistently; one sentence per line to minimize diff noise.
2019-10-31 13:38:20 -04:00
Stephen Canon 29d3104da4 Beef up ElementaryFunctions README
Add a small usage example, list the operations that are available with links to Wiki for the more obscure operations, be clear about logGamma not being available on Windows.
2019-10-31 10:09:03 -04:00
Stephen Canon eb76aa632b Update license headers, add CONTRIBUTING.md and umbrella module 2019-10-30 16:11:20 -04:00
Steve (Numerics) Canon 6908e3951a Re-arrange some stuff within Complex.swift, expand documentation
Also add a note about relative vs absolute error in Complex multiplication and division.
2019-08-05 15:24:08 -04:00
Steve (Numerics) Canon 919f13ce2e Restore the NumericShims module, use it instead of silgen_name.
I had thought that we could get away with just using @_silgen_name to wrap the platform libm functions in ElementaryFunctions conformances, but that's now failing in release builds when both ElementaryFunctions and the Platform module are imported (and actually crashing swiftc).

Fall back on the previous strategy of using C header shims. This adds an extra layer of source abstraction, but we're still able to optimize it away at compile time, even in unoptimized builds, so we can live with it for now.
2019-08-01 22:12:03 -04:00
Steve (Numerics) Canon 8977e637f4 Fix a typo in the _silgen_name for expMinusOne functions. 2019-08-01 10:33:51 -04:00
Stephen Canon 27903ffa54 Merge pull request #20 from stephentyrone/expm1-logp1-naming
Give expm1 and logp1 more explicit names
2019-07-30 13:12:34 -04:00
Steve (Numerics) Canon 4df7603179 fixed_layout -> frozen 2019-07-22 11:18:48 -04:00
Steve (Numerics) Canon 4a2409ffcd Give expm1 and logp1 more explicit names
These names are relatively standard, but more cryptic than they might be. Let's try using something else; I think that there's a decent chance we'll end up going back to the short/common names eventually, but it's worth experimenting with these a little bit.
2019-07-22 11:07:10 -04:00
Steve (Numerics) Canon fa9422ec6e Remove NumericShims module; we don't need it thanks to silgen_name. 2019-07-19 16:29:53 -04:00
Steve (Numerics) Canon 8aab7a90f8 Initial project setup for swift-numerics
Two modules to begin with:
- ElementaryFunctions
- Complex
Added README.md files describing each module very roughly, and a project
README to describe goals and process.
2019-07-06 15:27:21 -04:00