Commit Graph

179 Commits

Author SHA1 Message Date
flywind
0e3ea16554 use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
Jason Beetham
f28dc2c61e Added assertion to clamp (#17248)
Co-authored-by: flywind <xzsflywind@gmail.com>
2021-03-04 17:27:02 -08:00
Jason Beetham
c180de60a8 Added math.clamp for slice clamping (#17246)
* Added math.clamp for slice clamping

* Added inline to math.clamp

* Cleaned up math.clamp + test
2021-03-03 23:54:23 +00:00
Timothee Cour
cde950e1bc make copySign for js consistent with other backends (#16609)
* make copySign work more robustly in js
* improve tests
* improve tests/vm/tcastint.nim
2021-02-22 08:47:00 +01:00
flywind
35e14998ec fix math.frexp function signature (#16725) 2021-02-17 19:27:48 +01:00
konsumlamm
afa87f223c Improve math module (#17019)
* Improve documentation for math

Support empty input for cumsummed
Use runnableExamples
Move some examples to tests
Add more tests

* Update tests/stdlib/tmath.nim

Move some tests to trandom.nim
Move tests into main template where possible
Add test for #17017

* Add more tests for gamma & lgamma

Remove gamma(-1.0) example
Small fixes/changes

* Move more tests into template main()

* Fix typos

* Add edge case examples for copySign
2021-02-12 17:13:39 +01:00
flywind
a0fddfecd4 perpare for more compact bit operations in JS (#16728) 2021-01-19 14:57:16 +01:00
flywind
8939de15d7 minor improvement on math.nim (#16733) 2021-01-16 12:37:23 +01:00
flywind
bab0aa6ecf add math.signbit (#16592) 2021-01-07 08:48:02 +01:00
flywind
df9e74b510 fix #9125 (#16582)
* fix #9125

* Update tests/stdlib/tmath.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* back

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-01-05 17:47:10 +01:00
flywind
515cd45420 Add math.copySign (#16406)
* add math.copySign
* fix + tests
2020-12-30 15:09:30 +01:00
flywind
b1c3dab208 add euclDiv and euclMod to math (#16414)
* add `euclDiv` and `euclMod` to `math`
* use abs
* Update lib/pure/math.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>
2020-12-23 12:04:38 +01:00
Timothee Cour
bc84d9c8cb [backport => 1.0] fix #16428 vmops now works for generic procs (#16429)
* fix #16428 vmops now works for generic procs

* remove duplication
2020-12-22 02:05:21 +01:00
flywind
d00a412129 docs minor for math (#16407) 2020-12-20 19:53:27 -08:00
Timothee Cour
0b73106ccf add math.isNaN (#16179)
* add math.isNaN
* isNaN now works with --passc:-ffast-math; tests
* Update lib/pure/math.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2020-12-11 11:01:43 +01:00
ee7
2297b96238 math.nim: Use func everywhere (#16285)
* math.nim: procs with {.noSideEffect} -> funcs

* math.nim: procs without {.noSideEffect.} -> funcs

* math.nim: proc -> func in links

* math.nim: proc -> func in doc comments

* test: add `math` to strictFuncs test
2020-12-07 23:26:14 +01:00
ihlec
5c23ba7545 fixed article duplication typos (#16216) 2020-12-02 09:15:29 +01:00
Antonis Geralis
e220f756e7 fix for comparing infinities (#16122) 2020-11-25 10:15:34 +01:00
flywind
cbc793b30b move tests to testament (#16101)
* move tests to testament

* minor

* fix random

* disable test random
2020-11-24 19:06:41 +01:00
flywind
ef2677f5f3 change some code-blocks to runnableExamples and correct some errors in docs (#15900)
* original docs are wrong
* fix pathnorm
* Update lib/pure/pathnorm.nim

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
2020-11-12 10:47:56 +01:00
Antonis Geralis
c274d9aed6 add approxequal (#15766)
* add approxequal

* Address review comments, tests that pass

* more wikipedia links [ci skip]

* forgot since

Co-authored-by: b3liever <b3liever@yandex.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2020-10-30 09:56:28 +01:00
Miran
5163fe7d87 remove deprecation from math.round (#15224) 2020-08-25 15:59:42 +02:00
Hugo Granström
32ac1b7c9d fix #15033 (#15034) 2020-07-22 10:30:46 +02:00
Miran
e7f280bd26 Remove deprecated stuff from stdlib (#14699)
* update to the latest Jester

* remove deprecated procs from some stdlib modules

* 'criterion' is not maintained anymore and relies on obsolete stuff
2020-06-17 15:25:02 +02:00
hlaaftana
fbc97e712a move since from inclrtl to std/private/since (#14188)
* move since from inclrtl to std/private/since
* move since import in system below for HCR
2020-05-02 23:51:59 +02:00
Jacek Sieka
7d6cbf290a Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
2020-04-28 19:56:01 +02:00
Miran
352232e62d style fix: change 'JS' to 'js' to make it consistent (#13168) 2020-01-16 14:14:03 +01:00
Araq
a1beeb313f fixes #13032 2020-01-04 19:33:49 +01:00
KeepCoolWithCoolidge
ae7b53ec51 Fixes classify function to detect subnormal floating points (#12836)
* Fix classify to test for subnormality.
* Minor fix.
* Modified to maintain existing API.
* Minor change.
* Removed 32-bit case since float is always 64-bit.
2019-12-08 20:17:11 +01:00
PMunch
b662842bd0 Fix for 16 bit platforms (#12760) [backend]
This fixes some tiny issues with using Nim on 16-bit platforms. Not
entirely sure why the AVR chip I was compiling for with "cpu = avr" was
detected as 16-bit, but that's probably another issue..
2019-11-28 17:11:56 +01:00
Yanis Zafirópulos
76085e8a45 added support for openArray's for gcd and lcm (#12621) 2019-11-07 18:06:48 +01:00
Nindaleth
34dbc5699e fix several typos in documentation and comments (#12553) 2019-10-30 09:08:45 +01:00
Miran
b03de8a4d9 Fix many broken links and prefer relative links within docs (#12463)
* Fix many broken links

Note that contrary to what docgen.rst currently says, the ids have
to match exactly or else most web browsers will not jump to the
intended symbol.

* Prefer relative links for Nim documentation

This is more friendly to those browsing the documentation without
a network connection. The nim-doc package in Debian allows this,
for example.

Also, the domain name being used was not consistent. It could have
been either nim-lang.org or nim-lang.github.io, and those reading
the stable docs could have found themselves suddenly reading the
devel docs instead.

* koch.rst: remove link to nonexistent section

* manual.rst: remove unintended link

cast[T](0) is interpreted as a link to id 0 with text T, so escape
the opening parentheses to display the intended output.

* asyncstreams: replace unintended link with emphasis

* Fix word wrapping
2019-10-24 14:07:43 +02:00
Juan Carlos
8f8916413f [backport] Documentation Math module (#12460) 2019-10-24 14:07:21 +02:00
Jjp137
93461aee34 Fix many broken links
Note that contrary to what docgen.rst currently says, the ids have
to match exactly or else most web browsers will not jump to the
intended symbol.
2019-10-22 17:59:12 -07:00
narimiran
6c994b2498 [backport] run nimpretty on numbers stuff 2019-09-30 13:58:05 +02:00
Graeme Cross
dad3c40f55 Fix the broken link in math.nim (#11653) [ci skip] 2019-07-04 13:24:19 +02:00
narimiran
436f570651 [documentation] fix #4630, document unsupported functions for JS 2019-06-24 12:52:54 +02:00
Benjamin Summerton
a009cbdc2f Add cbrt() bindings for the JS Target (#11528)
`Math.cbrt()` exists:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt

The binding was missing for the JavaScript backend.
2019-06-18 02:26:47 -04:00
LemonBoy
7d217a71d3 Render deprecated pragmas (#8886)
* Render deprecated pragmas
* fix the expected html
* clean up the documentation regarding deprecations
* fix typo
* fix system.nim
* fix random
2019-06-03 10:15:20 +02:00
Araq
11fca968b2 stdlib: more consistent formatting 2019-05-22 07:41:16 +02:00
Miran
9bd4347abb fix #10910, optimize squaring and cubing (#11291) 2019-05-21 15:57:33 +02:00
Arne Döring
e904b3f952 code cleanup (#10874) 2019-03-28 12:32:02 +01:00
Arne Döring
28394153ab 32 bit fixes (#10608) 2019-02-13 23:30:14 +01:00
Emery Hemingway
15422a3e5a Genode fixes (#10491)
Readline pasthru, add linker to config, do not pass -lm to linker.
2019-01-29 15:08:43 +01:00
narimiran
52a54f5f04 documentation: remove author field [ci skip] 2019-01-17 07:15:40 +01:00
narimiran
387f481e86 better docs: math 2019-01-16 09:46:01 +01:00
c-blake
7ac1fc81fd Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ? (#10084)
* Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ?
CDF is a standard ident in all things related to random numbers/sampling,
and full words "cumulativeDistributionFunction" would be silly long, in
this case, IMO.  We use lowercase `cdf` to make it not look like a type,
remove all looping from `sample` letting callers do it.  Besides just
side-stepping any `sampleSize` name choice, callers may want to filter
out samples anyway which this makes slightly simpler.

Also add two variants of `cumsum`, value return and in-place update
distinguished by the var-ness of the first argument.  Add tests for
`int` and `float` for both `cumsum` and the new `sample`.  (The sample
tests exercise the value return mode of `cumsum`.)

Functionality pre-this-PR `sample(a, w)` is now the almost as simple
`for i in 0..<n: sample(a, w.cumsum)`, but this new code factoring is
almost surely better.  The statistical tests pass, as before.

* Address Araq comment in https://github.com/nim-lang/Nim/pull/10084
We can always add in some `var` version later if desired to save
memory, but this change now at least firms up the `sample` interface.

* Rename `cumsum` -> `cumsummed` to honor NEP1 style.  Re-instate `cumsum` as
the in-place transformation.  Test both in `tests/stdlib/tmath.nim` and use
`cumsummed` in the example code for sample since that's a simpler example.

* Fix requests from https://github.com/nim-lang/Nim/pull/10084 :
  example in lib/pure/math.nim and comment whitespace in lib/pure/random.nim
2018-12-31 14:52:51 +01:00
B3liever
8a1d52fa48 Fix #9585 hypot in js 2018-10-31 14:09:39 +02:00
narimiran
80b78b50d0 more examples for mod and div, plus corrections [ci skip] 2018-10-28 22:37:58 +00:00