From 3a63a929bf337af9ba9de3b2eb4d2ae0c9d880a0 Mon Sep 17 00:00:00 2001 From: Pastafarianist Date: Thu, 19 Feb 2015 00:24:10 +0300 Subject: [PATCH 1/5] Fixed 100 rendered as 1e2 by prettyPrint Due to how prettyPrint was implemented, 100 would always be rendered as 1e2. Fixed that particular error. Still leaves open the issue of rendering 10000 as 1e4, for example. --- src/numeric.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/numeric.js b/src/numeric.js index 537b68f..04b40ba 100644 --- a/src/numeric.js +++ b/src/numeric.js @@ -56,9 +56,9 @@ numeric.prettyPrint = function prettyPrint(x) { if(typeof x === "string") { ret.push('"'+x+'"'); return false; } if(typeof x === "boolean") { ret.push(x.toString()); return false; } if(typeof x === "number") { - var a = fmtnum(x); + var a = parseFloat(x.toString()).toString(); var b = x.toPrecision(numeric.precision); - var c = parseFloat(x.toString()).toString(); + var c = fmtnum(x); var d = [a,b,c,parseFloat(b).toString(),parseFloat(c).toString()]; for(k=1;k Date: Fri, 26 Jun 2015 17:52:29 -0700 Subject: [PATCH 2/5] Fix unreachable code warnings in Firefox 40. This warning was being logged to the console whenever there was a doubled semicolon after a return statement, because there is an unreachable (empty) statement between the semicolons. Regularize the usage of semicolons in generated code to avoid producing these warnings. --- src/numeric.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/numeric.js b/src/numeric.js index 537b68f..dc4a653 100644 --- a/src/numeric.js +++ b/src/numeric.js @@ -358,10 +358,10 @@ numeric.mapreduce = function mapreduce(body,init) { numeric.mapreduce2 = function mapreduce2(body,setup) { return Function('x', 'var n = x.length;\n'+ - 'var i,xi;\n'+setup+';\n'+ + 'var i,xi;\n'+setup+'\n'+ 'for(i=n-1;i!==-1;--i) { \n'+ ' xi = x[i];\n'+ - ' '+body+';\n'+ + ' '+body+'\n'+ '}\n'+ 'return accum;' ); @@ -663,7 +663,7 @@ numeric.mapreducers = { prod: ['accum *= xi;','var accum = 1;'], norm2Squared: ['accum += xi*xi;','var accum = 0;'], norminf: ['accum = max(accum,abs(xi));','var accum = 0, max = Math.max, abs = Math.abs;'], - norm1: ['accum += abs(xi)','var accum = 0, abs = Math.abs;'], + norm1: ['accum += abs(xi);','var accum = 0, abs = Math.abs;'], sup: ['accum = max(accum,xi);','var accum = -Infinity, max = Math.max;'], inf: ['accum = min(accum,xi);','var accum = Infinity, min = Math.min;'] }; @@ -763,7 +763,7 @@ numeric.mapreducers = { o[1]+ 'if(typeof x !== "object") {'+ ' xi = x;\n'+ - o[0]+';\n'+ + o[0]+'\n'+ ' return accum;\n'+ '}'+ 'if(typeof s === "undefined") s = numeric.dim(x);\n'+ @@ -773,7 +773,7 @@ numeric.mapreducers = { 'var n = x.length, i;\n'+ 'for(i=n-1;i!==-1;--i) {\n'+ ' xi = arguments.callee(x[i]);\n'+ - o[0]+';\n'+ + o[0]+'\n'+ '}\n'+ 'return accum;\n'); } @@ -1102,15 +1102,15 @@ numeric.Tunop = function Tunop(r,c,s) { 'var x = this;\n'+ s+'\n'+ 'if(x.y) {'+ - ' '+c+';\n'+ + ' '+c+'\n'+ '}\n'+ - r+';\n' + r+'\n' ); } numeric.T.prototype.exp = numeric.Tunop( - 'return new numeric.T(ex)', - 'return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))', + 'return new numeric.T(ex);', + 'return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex));', 'var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;'); numeric.T.prototype.conj = numeric.Tunop( 'return new numeric.T(x.x);', @@ -1120,10 +1120,10 @@ numeric.T.prototype.neg = numeric.Tunop( 'return new numeric.T(neg(x.x),neg(x.y));', 'var neg = numeric.neg;'); numeric.T.prototype.sin = numeric.Tunop( - 'return new numeric.T(numeric.sin(x.x))', + 'return new numeric.T(numeric.sin(x.x));', 'return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));'); numeric.T.prototype.cos = numeric.Tunop( - 'return new numeric.T(numeric.cos(x.x))', + 'return new numeric.T(numeric.cos(x.x));', 'return x.exp().add(x.neg().exp()).div(2);'); numeric.T.prototype.abs = numeric.Tunop( 'return new numeric.T(numeric.abs(x.x));', From b3410736fb14f1f328630d09478adce0f40be355 Mon Sep 17 00:00:00 2001 From: Victor Sosa Date: Thu, 3 Dec 2015 10:51:59 -0400 Subject: [PATCH 3/5] added bower file for integration --- bower.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..06ffb53 --- /dev/null +++ b/bower.json @@ -0,0 +1,12 @@ +{ + "name": "numericjs", + "version": "1.2.6", + "main": "lib/numeric.js", + "description": "Numerical analysis in Javascript", + "license": "Eclipse", + "repo": "sloisel/numeric" + "ignore": [ + ".jshintrc", + "**/*.txt" + ] +} From 5c23748f06a4064fcfa5c4a415ffaa5533b34e64 Mon Sep 17 00:00:00 2001 From: Victor Sosa Date: Thu, 3 Dec 2015 11:15:29 -0400 Subject: [PATCH 4/5] fix dependency bower.json file --- bower.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 06ffb53..51d3040 100644 --- a/bower.json +++ b/bower.json @@ -3,10 +3,16 @@ "version": "1.2.6", "main": "lib/numeric.js", "description": "Numerical analysis in Javascript", - "license": "Eclipse", + "license": "MIT", "repo": "sloisel/numeric" "ignore": [ ".jshintrc", "**/*.txt" - ] + ], + "dependencies": { + "seedrandom": "latest", + "quadprog": "lib/quadprog.js", + "sparse2": "lib/sparse2.js", + "svd": "lib/svd.js", + } } From 434c3c7ac0f3066d21ea33db7cb8e25e2b9a4140 Mon Sep 17 00:00:00 2001 From: Victor Sosa Date: Thu, 3 Dec 2015 11:19:46 -0400 Subject: [PATCH 5/5] fix dependency bower.json file --- bower.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bower.json b/bower.json index 51d3040..3113b58 100644 --- a/bower.json +++ b/bower.json @@ -9,6 +9,10 @@ ".jshintrc", "**/*.txt" ], + "keywords": [ + "numerical", + "analysis" + ], "dependencies": { "seedrandom": "latest", "quadprog": "lib/quadprog.js",