big rename
This commit is contained in:
parent
15a7bcc89f
commit
11b6958755
98 changed files with 2491 additions and 2341 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2014 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
## Constructive mathematics is naturally typed. -- Simon Thompson
|
||||
##
|
||||
## Basic math routines for Nimrod.
|
||||
## Basic math routines for Nim.
|
||||
## This module is available for the `JavaScript target
|
||||
## <backends.html#the-javascript-target>`_.
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ const
|
|||
## for Nimrod's ``float`` type.
|
||||
|
||||
type
|
||||
TFloatClass* = enum ## describes the class a floating point value belongs to.
|
||||
## This is the type that is returned by `classify`.
|
||||
FloatClass* = enum ## describes the class a floating point value belongs to.
|
||||
## This is the type that is returned by `classify`.
|
||||
fcNormal, ## value is an ordinary nonzero floating point value
|
||||
fcSubnormal, ## value is a subnormal (a very small) floating point value
|
||||
fcZero, ## value is zero
|
||||
|
|
@ -51,10 +51,10 @@ type
|
|||
fcInf, ## value is positive infinity
|
||||
fcNegInf ## value is negative infinity
|
||||
|
||||
proc classify*(x: float): TFloatClass =
|
||||
proc classify*(x: float): FloatClass =
|
||||
## classifies a floating point value. Returns `x`'s class as specified by
|
||||
## `TFloatClass`.
|
||||
|
||||
## `FloatClass`.
|
||||
|
||||
# JavaScript and most C compilers have no classify:
|
||||
if x == 0.0:
|
||||
if 1.0/x == Inf:
|
||||
|
|
@ -287,12 +287,14 @@ proc random[T](a: openArray[T]): T =
|
|||
result = a[random(a.low..a.len)]
|
||||
|
||||
type
|
||||
TRunningStat* {.pure,final.} = object ## an accumulator for statistical data
|
||||
n*: int ## number of pushed data
|
||||
sum*, min*, max*, mean*: float ## self-explaining
|
||||
RunningStat* = object ## an accumulator for statistical data
|
||||
n*: int ## number of pushed data
|
||||
sum*, min*, max*, mean*: float ## self-explaining
|
||||
oldM, oldS, newS: float
|
||||
|
||||
proc push*(s: var TRunningStat, x: float) =
|
||||
{.deprecated: [TFloatClass: FloatClass, TRunningStat: RunningStat].}
|
||||
|
||||
proc push*(s: var RunningStat, x: float) =
|
||||
## pushes a value `x` for processing
|
||||
inc(s.n)
|
||||
# See Knuth TAOCP vol 2, 3rd edition, page 232
|
||||
|
|
@ -313,16 +315,16 @@ proc push*(s: var TRunningStat, x: float) =
|
|||
s.oldS = s.newS
|
||||
s.sum = s.sum + x
|
||||
|
||||
proc push*(s: var TRunningStat, x: int) =
|
||||
proc push*(s: var RunningStat, x: int) =
|
||||
## pushes a value `x` for processing. `x` is simply converted to ``float``
|
||||
## and the other push operation is called.
|
||||
push(s, toFloat(x))
|
||||
|
||||
proc variance*(s: TRunningStat): float =
|
||||
proc variance*(s: RunningStat): float =
|
||||
## computes the current variance of `s`
|
||||
if s.n > 1: result = s.newS / (toFloat(s.n - 1))
|
||||
|
||||
proc standardDeviation*(s: TRunningStat): float =
|
||||
proc standardDeviation*(s: RunningStat): float =
|
||||
## computes the current standard deviation of `s`
|
||||
result = sqrt(variance(s))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue