diff --git a/src/documentation.html b/src/documentation.html index 9767498..97393e6 100644 --- a/src/documentation.html +++ b/src/documentation.html @@ -98,6 +98,7 @@ <tr><td><tt>largeArray</tt><td>Don't prettyPrint Arrays larger than this <tr><td><tt>leq</tt><td>Pointwise x<=y <tr><td><tt>linspace</tt><td>Generate evenly spaced values +<tr><td><tt>logspace</tt><td>Generate logarithmically spaced values <tr><td><tt>log</tt><td>Pointwise Math.log(x) <tr><td><tt>lshift</tt><td>Pointwise x<<y <tr><td><tt>lshifteq</tt><td>Pointwise x<<=y @@ -397,6 +398,13 @@ <h1>Utility functions</h1> OUT> [1,1.5,2,2.5,3] </pre> +Or a vector of logarithmically spaced values between Math.pow(10,a) and Math.pow(10,b): + +<pre> +IN> numeric.logspace(0,1,5); +OUT> [1, 1.7782794100389228, 3.1622776601683795, 5.623413251903491, 10] +</pre> + <!-- <pre> IN> numeric.blockMatrix([[[[1,2],[3,4]],[[5,6],[7,8]]], diff --git a/src/numeric.js b/src/numeric.js index 537b68f..5b96e84 100644 --- a/src/numeric.js +++ b/src/numeric.js @@ -928,6 +928,12 @@ numeric.linspace = function linspace(a,b,n) { return ret; } +numeric.logspace = function logspace(a,b,n) { + return numeric.linspace(a,b,n).map( + function(x) { return Math.pow(10,x); } + ); +} + numeric.getBlock = function getBlock(x,from,to) { var s = numeric.dim(x); function foo(x,k) {