Commit graph

187 commits

Author SHA1 Message Date
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
eqperes
6620b5dc8d Documentation improved for math module (#9266) 2018-10-10 14:25:39 +02:00
Arne Döring
5076fda2e2 fix for #9082 (#9089) 2018-10-09 19:37:53 +02:00
Araq
8029a649ba math.nim: document what to use instead of 'fmod' 2018-09-25 00:10:21 +02:00
cooldome
d0f4a929e0 fixes 8594 (#8721) 2018-08-22 12:16:18 +02:00
Dominik Picheta
bc957ace2e
Merge pull request #8628 from hlaaftana/patch-1
Small documentation typo in math
2018-08-14 11:21:26 +01:00
alaviss
7ef268274f Haiku support for Nim (#8542)
* posix_other: Haiku now has spawn.h

This is added per https://dev.haiku-os.org/ticket/13446

* posix_other: Add Haiku specific Dirent members

* cpuinfo: Add an implementation for Haiku

* distros: Add basic Haiku support

* encodings: update Haiku support

* fenv, math: Haiku now provides libm

* times: Add Haiku struct members

* ansi_c, osalloc: Add Haiku constants

* threads: Add Haiku support

* testament: Haiku uses LIBRARY_PATH

* nim.cfg: Update Haiku support

libnetwork should only be linked if network functions are used

* threads: Haiku does not support -pthread switch

* tworkingdir: Haiku's env is in /bin

* posix_other: add SIGKILLTHR for Haiku

* sockets: link with libnetwork on Haiku

* coro: correct ucontext.h location

http://pubs.opengroup.org/onlinepubs/009696699/basedefs/ucontext.h.html

* coro: ucontext backend is not available on Haiku

Haiku doesn't provide the <ucontext.h> header, as it was removed from POSIX

* coro: fix setjmp backend

The compiler does not allow statements after a noreturn function

* nativesockets: Haiku doesn't support AI_V4MAPPED

* system: hostOS can contains "haiku"

* os: add support for Haiku's packagefs

packagefs is read-only, but there are writable holes to the underlying
file system as well

* os: update constant for Haiku
2018-08-14 09:35:07 +02:00
hlaaf
ed4a267399
Small documentation typo in math 2018-08-14 01:33:56 +03:00
andri lim
c3d5ec8ead fixes #8421, fixes #7968, Nim compiler compiles with MSVC C89 version (#8556) 2018-08-07 09:07:18 +02:00
Andreas Rumpf
2d186f18ec
Merge pull request #7950 from Paalon/math-log
Add log for base b of x
2018-06-14 14:02:57 +02:00
Koki Fushimi
5332da2e7c Fix a test 2018-06-14 13:37:37 +09:00
Koki Fushimi
5fc5e37194 Use one same type for two parameters 2018-06-14 13:17:17 +09:00
Koki Fushimi
959b6354c1 Rename tgamma to gamma (#7929)
* Rename tgamma to gamma

* set the deprecating version  0.19.0

* update changelog and use description in deprecated pragma
2018-06-05 11:15:04 -04:00
Koki Fushimi
a3e5242d31 Add product proc (#7951)
* Add product proc

* Update changelog
2018-06-04 18:24:34 -04:00
Koki Fushimi
090ffa3869 Use concrete expression 2018-06-05 02:32:39 +09:00
Koki Fushimi
41601e9307 Bug fix 2018-06-05 00:27:04 +09:00
Koki Fushimi
05f81482f4 Change to use log(x, base) 2018-06-05 00:22:40 +09:00
Koki Fushimi
abf8ee049a Broaden the argument types 2018-06-04 16:48:11 +09:00
Koki Fushimi
f849db1c5c Generalize and add test 2018-06-04 15:09:17 +09:00
Koki Fushimi
d7913419d7 Add log proc for base b of x 2018-06-04 15:03:08 +09:00
data-man
1bbd83de3f Removed spaces in math module 2018-05-30 20:55:53 +03:00
Oscar Nihlgård
65070a6936 Use truncation division in mod for floats (#7118)
* Use truncation division in mod for floats

* Add changelog entry

* Add floorDiv/floorMod to math.nim

* Update changelog
2018-05-30 19:14:21 +03:00
Koki Fushimi
2107c81d6d Add inverse hyperbolic, and cot, sec and csc; and their hyperbolic, inverse, inverse hyperbolic, and change to use defined functions in C or JS for logs and hyperbolics. (#7893)
* Add secant, cosecant and cotangent.

* Add hyperbolic functions of cotangent, secant and cosecant.

* Add inverse hyperbolic functions.

* Change to use defined function of C and JS.

* Bug fix and refactoring.

* Add change to changelog.md
2018-05-30 15:29:34 +01:00
Koki Fushimi
09283bb939 Faster binary gcd algorithm (#7849)
* Faster binary gcd algorithm.

* Use built in countTrailingZeroBits to calculate gcd.

* Add definitions of gcd for integers and other types.

* Unified signed case and unsinged case in one proc by using when syntax.

* Change to faster one.
2018-05-26 08:31:45 +03:00
data-man
173c92d374 Fixes factorial's bug 2018-05-17 19:54:41 +03:00
notTito
8f7bd6cf5c Replace factorial function with a compile time one (#7276)
* Replace factorial function with a compile time one

* Fix the indentation

* Update
2018-05-04 07:37:57 +02:00
skilchen
a89b81eb96 fixes #6353 (#6951) 2017-12-21 16:32:26 +01:00
skilchen
47d00eb397 add missing math.trunc for js backend (#6950) 2017-12-20 22:26:22 +01:00
Federico Ceratto
590512873c Add hint about computing powers between integers (#6419) 2017-10-16 14:59:37 +02:00
Fabian Keller
a6e0494a6f fixes #5966 2017-06-20 12:11:09 +02:00
John Novak
17b55f9b29 Add sgn() function to the math module (#5971) 2017-06-15 21:00:18 +02:00
AdrianV
8a487d3223 bcc misses the same functions like vcc 2016-12-28 17:34:14 +01:00
andri lim
be6f792cbd Fixed #4532, VS2010 now can compile Nim
Fixed #4532, VS2010 now can compile Nim


Fixed #4532, VS2010 now can compile Nim
2016-08-08 20:24:33 +07:00
Mathijs Saey
756beb5b5b Removed trailing whitespace in math module 2016-08-05 17:58:31 +02:00
Mathijs Saey
2a84206e89 Fixed #4574 2016-08-05 17:57:51 +02:00
A. S. Budden
f9bb209c32 Corrected comment in maths library. 2016-06-20 09:15:56 +01:00
matkuki
39fd0e801d Update math.nim 2016-06-18 12:26:21 +02:00
matkuki
f9a659f7ab Windows MSVC < 2012 'round' function update
Microsoft Visual C++ compilers prior to 2012 do not implement the 'round', 'roundl' or 'roundf' functions.
This change is fixes this. Tested it with MSVC 2010.
2016-06-17 21:52:41 +02:00
A. S. Budden
695b25100c Changed math.nim tests to use newly defined ==~ operator 2016-05-31 15:53:18 +01:00
A. S. Budden
1b9c66d720 Correction to round0 following review. 2016-05-31 15:16:50 +01:00
A. S. Budden
46a2993917 Implemented function to split floating point numbers at the decimal place (equivalent to C's modf function). Fixes #4195. 2016-05-31 13:26:41 +01:00
A. S. Budden
0cc7c9a13c Modification to implementation of round() such that it returns a float and accepts a places argument (fixes #3473).
This also involved moving some functions around to get the hierarchy correct and the documentation for frexp was modified such that it was clear that it can return a float in either the range [-1, -0.5] or [0.5, 1].
2016-05-31 13:17:40 +01:00
Andreas Rumpf
95bb19a579 moved random procs from math to its own module (breaking change) 2016-05-30 16:24:52 +02:00