summary refs log tree commit diff stats
path: root/lib/pure/math.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/math.nim')
-rw-r--r--lib/pure/math.nim42
1 files changed, 22 insertions, 20 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 8af09114b..32bae18c2 100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -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>`_.
 
@@ -30,19 +30,19 @@ const
   E* = 2.71828182845904523536028747 ## Euler's number
 
   MaxFloat64Precision* = 16 ## maximum number of meaningful digits
-                            ## after the decimal point for Nimrod's
+                            ## after the decimal point for Nim's
                             ## ``float64`` type.
   MaxFloat32Precision* = 8  ## maximum number of meaningful digits
-                            ## after the decimal point for Nimrod's
+                            ## after the decimal point for Nim's
                             ## ``float32`` type.
   MaxFloatPrecision* = MaxFloat64Precision ## maximum number of 
                                            ## meaningful digits
                                            ## after the decimal point 
-                                           ## for Nimrod's ``float`` type.
+                                           ## for Nim'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:
@@ -278,21 +278,23 @@ else:
 proc `mod`*(x, y: float): float =
   result = if y == 0.0: x else: x - y * (x/y).floor
 
-proc random*[T](x: TSlice[T]): T =
+proc random*[T](x: Slice[T]): T =
   ## For a slice `a .. b` returns a value in the range `a .. b-1`.
   result = random(x.b - x.a) + x.a
 
-proc random[T](a: openarray[T]): T =
+proc random[T](a: openArray[T]): T =
   ## returns a random element from the openarray `a`.
   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))