Comments (5)
[3.2.2023] EDIT to main issue:
- [BigInt tests] 💀 Init from float 754
- [BigInt tests] ✅🐰 Codable
- many changes in performance tests
from swift-numerics.
Things to do in Helpers
(but I'm not going to update 15 PRs, so we will do it later):
-
add
reserveCapacity
ingenerate[Big]Ints
- this does not matter in normal tests (count ~1000), but it matters in performance tests where we need to generate100_000
values -
rename
BigIntPrototype.compare
->BigIntPrototype.compareMagnitude
-
rewrite
BigIntPrototype.create
- shifts 10x faster than multiplication:internal static func create<T: FixedWidthInteger>( isPositive: Bool, magnitude: [T] ) -> BigInt { assert(!T.isSigned) var result = BigInt() for (index, word) in magnitude.enumerated() { var bits = BigInt(word) bits <<= index * T.bitWidth result |= bits } if !isPositive { result.negate() } return result }
If we use sign+magnitude with
UInt
asWord
then there is another possible optimisation that avoids calculations altogether.
from swift-numerics.
I wrote Violet XsProMax which is a Violet implementation with following changes:
- no small inlined integer (
Smi
) - magnitude is always stored on the heap - no restrictions on the size -
isNegative
is stored in-line (and not on the heap like in Violet);count
andcapacity
are on the heap because I don't want to stray too much fromViolet
.
Which gives us:
struct BigInt {
struct Header {
var count: UInt32
var capacity: UInt32
}
var flags: UInt8
var buffer: ManagedBufferPointer<Header, UInt>
}
I updated the performance PR with the results.
from swift-numerics.
The issue below (from @LiarPrincess) appears fixed in my latest updates (see pull request #261)
// -9223372036854775808 = Int64.min, obviously '-Int64.min' overflows
let int: Int64 = -9223372036854775808
let big = BigInt(int)
XCTAssertEqual(-big, big * -1)
from swift-numerics.
All remaining issues (at least the published ones) appear to have been fixed with the pull request #262.
There were some problems with division/modulo signs, initialization, corner-case fixes.
from swift-numerics.
Related Issues (20)
- Meaning of pre‐semantic versioning? HOT 7
- Missing required module HOT 7
- Add a script to generate the CMakeLists files? HOT 1
- Feature request for "relaxed" floating-point semantics HOT 2
- Floating point exponent `pow` returns NaN for integer exponents HOT 2
- Possible improvement in 'pow' Elementary Function when operands are zero HOT 5
- Should complex multiplication use augmented arithmetic? HOT 1
- Warnings in `Double.testIntegerExponent()` HOT 1
- Duplicate symbols on Windows
- "^=" xor function code was incorrect. HOT 1
- Improve String init() execution time and fix Violet bugs
- Change default branch from `Quaternions` to `main`
- `** ARCHIVE FAILED **` due to `_NumericsShims` missing HOT 4
- Crash in `DoubleWidth` HOT 4
- Variadic GCD and LCM
- Feature request: GCD for floating-point HOT 7
- Error in Swift Playgrounds HOT 1
- Issues with CMake support HOT 3
- [FR]: Support Apple Privacy Manifest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-numerics.