aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math
AgeCommit message (Collapse)Author
2021-01-06std: Rename ArrayList shrink => shrinkAndFreeAlex Cameron
2020-12-31Year++Frank Denis
2020-12-09std: explicitly cast indices to usizeLemonBoy
This is needed for platforms where usize=u16, eg. MSP430.
2020-11-19Add builtin.Signedness, use it instead of is_signedTadeo Kondrak
2020-11-06change debug.assert to testing.expect in testsxackus
2020-11-05std: Implement more useful approxEq semanticsLemonBoy
Comparisons with absolute epsilons are usually useful when comparing numbers to zero, for non-zero numbers it's advised to switch to relative epsilons instead to obtain meaningful results (check [1] for more details). The new API introduces approxEqAbs and approxEqRel, where the former aliases and deprecated the old `approxEq`, allowing the user to pick the right tool for the job. The documentation is meant to guide the user in the choice of the correct alternative. [1] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
2020-10-17Make std.meta.Int accept a signedness parameterJan Prudil
2020-10-09std: Add/Fix/Change parts of big.intLemonBoy
* Add an optimized squaring routine under the `sqr` name. Algorithms for squaring bigger numbers efficiently will come in a PR later. * Fix a bug where a multiplication was done twice if the threshold for the use of Karatsuba algorithm was crossed. Add a test to make sure this won't happen again. * Streamline `pow` method, take a `Const` parameter. * Minor tweaks to `pow`, avoid bit-reversing the exponent.
2020-10-05std: Fix two bugs in bigint powLemonBoy
* Correctly scan all the exponent bits, this caused the incorrect result to be computed for exponents being powers of two. * Allocate enough limbs to make llmulacc stop whining.
2020-10-04std: Add pow(a,b) for big intsLemonBoy
Implemented following Knuth's "Evaluation of Powers" chapter in TAOCP, some extra complexity is needed to make sure there's no aliasing and avoid allocating too many limbs. A brief example to illustrate why the last point is important: consider 10^123, since 10 is well within the limits of a single limb we can safely say that the result will surely fit in: ⌈log2(10)⌉ bit * 123 = 492 bits = 7 limbs A naive calculation using only the number of limbs yields: 1 limb * 123 = 123 limbs The space savings are noticeable.
2020-09-07big int: fix Managed.dump()Vincent Rischmann
2020-09-03update uses of deprecated type field accessVexu
2020-08-26forceEval() -> doNotOptimizeAway()Frank Denis
2020-08-25std.math.big: fix use-after-freeAndrew Kelley
When there is parameter aliasing, the ensureCapacity calls can cause the Const parameters to become dangling pointers. See #6167
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-07-27Fix bug in big.int.Mutable.toManaged() and add testsjoachimschmidt557
Fixes #5918
2020-07-11run zig fmt on std lib and self hostedVexu
2020-07-04std.mem.dupe is deprecated, move all references in stdjoachimschmidt557
Replaced all occurences of std.mem.dupe in stdlib with Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-06-17Improve f128 standard library supportantlilja
* Add functions: floor128, ceil128, trunc128 and round128 * Add corresponding tests
2020-06-09fix memory errorsJonathan Marler
2020-05-01fix off-by-one error in sizeInBaseUpperBoundAndrew Kelley
2020-05-01update std.meta.IntType => std.meta.IntAndrew Kelley
2020-05-01rework std.math.big.IntAndrew Kelley
Now there are 3 types: * std.math.big.int.Const - the memory is immutable, only stores limbs and is_positive - all methods operating on constant data go here * std.math.big.int.Mutable - the memory is mutable, stores capacity in addition to limbs and is_positive - methods here have some Mutable parameters and some Const parameters. These methods expect callers to pre-calculate the amount of resources required, and asserts that the resources are available. * std.math.big.int.Managed - the memory is mutable and additionally stores an allocator. - methods here perform the resource calculations for the programmer. - this is the high level abstraction from before Each of these 3 types can be converted to the other ones. You can see the use case for this in the self-hosted compiler, where we only store limbs, and construct the big ints as needed. This gets rid of the hack where the allocator was optional and the notion of "fixed" versions of the struct. Such things are now modeled with the `big.int.Const` type.
2020-05-01ZIR: implement return instructionAndrew Kelley
2020-05-01ZIR: add cmp and condbr instructionsAndrew Kelley
2020-04-28std.meta.IntType -> std.meta.IntTadeo Kondrak
2020-04-26Fix f64 variants of math.cosh and math.sinh to accept negative inputs. (#5172)Nick Appleton
* add tests for negative inputs to cosh32 and cosh64. fix bug in cosh64 for negative inputs. * fix problem with negative input with f64 sinh and add tests
2020-04-22std.math.big.Int: don't rely on the allocator when printingAndrew Kelley
2020-04-21ir: analyze int castingAndrew Kelley
2020-04-15Enable formatting in std.big.Int.formatjoachimschmidt557
2020-04-15translate-c cleanup and zig fmtVexu
2020-04-07move big.rational.gcd to big.int.gcdjoachimschmidt557
2020-04-02new ArrayList API: fix everything elsexackus
2020-03-24Merge remote-tracking branch 'origin/llvm10'Andrew Kelley
LLVM 10 was released today
2020-03-23Use math.Order for comparing bigints instead of i8 (#4791)Joachim Schmidt
2020-03-23Merge pull request #4741 from momumi/masterAndrew Kelley
allow `_` separators in number literals (stage 1)
2020-03-22update parsing of int literals in self-hostedmomumi
* update std.math.big.Int.setString() to ignore underscores and make it case insensitive * fix issue in ir.zig with leading zeroes in integer literals
2020-03-19Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-17clean up some self-hosted bitrot + don't assume libstdc++Andrew Kelley
closes #4682 The self-hosted compiler is still bit rotted and still not compiling successfully yet. I have a more serious rework of the code in a different branch.
2020-03-13Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-12Replace fmt with new fmtstreamBenjamin Feng
2020-03-12Integrated outstreams with new formatterBenjamin Feng
2020-03-03Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-01short std.builtin enum literals in std libxackus
2020-02-28update std lib to new Target APIAndrew Kelley
2020-02-25Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-02-24remove uses of `@ArgType` and `@IntType`Vexu
2020-02-24remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType`Vexu
2020-02-14Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-02-14std: use testing.allocator in testsdaurnimator