@@ -197,19 +197,20 @@ Using Chrome
197
197
185 PASS: numeric.solveLP([1,1],[[1,0],[0,1]],[0,0]).message; ==> "Unbounded"
198
198
186 PASS: numeric.solveLP([1,2,3], /* minimize [1,2,3]*x */ [[-1,0,0],[0,-1,0],[0,0,-1]], /* matrix A of inequality constraint */ [0,0,0], /* RHS b of inequality constraint */ [[1,1,1]], /* matrix Aeq of equality constraint */ [3] /* vector beq of equality constraint */ ); ==> {solution:[3,1.685e-16,4.559e-19],message:"",iterations:12}
199
199
187 PASS: n = 7; m = 3; for(k=0;k<10;++k) { A = numeric.random([n,n]); x = numeric.rep([m],1).concat(numeric.rep([n-m],0)); b = numeric.dot(A,x); J = numeric.diag(numeric.rep([n],-1)); B = numeric.blockMatrix([[A , J ], [numeric.neg(A) , J ], [numeric.rep([n,n],0), J ]]); c = b.concat(numeric.neg(b)).concat(numeric.rep([n],0)); d = numeric.rep([n],0).concat(numeric.rep([n],1)); y = numeric.solveLP(d,B,c).solution; y.length = n; foo = numeric.norm2(numeric.sub(x,y)); if(foo>1e-10) throw new Error("solveLP test fails: "+numeric.prettyPrint({A:A,x:x})); } "solveLP tests pass" ==> "solveLPtestspass"
200
- 188 PASS: sol = numeric.dopri(0,1,1,function(t,y) { return y; }) ==> {x:[0,0.1,0.1522,0.361,0.5792,0.7843,0.9813,1],y:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],f:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],ymid:[1.051,1.134,1.293,1.6,1.977,2.418,2.693],iterations:8,events:,message:""}
201
- 189 PASS: sol.at([0.3,0.7]) ==> [1.35,2.014]
202
- 190 PASS: sol = numeric.dopri(0,10,[3,0],function (x,y) { return [y[1],-y[0]]; }); sol.at([0,0.5*Math.PI,Math.PI,1.5*Math.PI,2*Math.PI]) ==> [[3,0],[-9.534e-8,-3],[-3,2.768e-7],[3.63e-7,3],[3,-3.065e-7]]
203
- 191 PASS: numeric.dopri(0,20,[2,0],function(t,y) { return [y[1], (1-y[0]*y[0])*y[1]-y[0]]; }).at([18,19,20]) ==> [[-1.208,0.9916],[0.4258,2.535],[2.008,-0.04251]]
204
- 192 PASS: sol = numeric.dopri(0,2,1,function (x,y) { return y; },1e-8,100,function (x,y) { return y-1.3; }); ==> {x:[0,0.0181,0.09051,0.1822,0.2624],y:[1,1.018,1.095,1.2,1.3],f:[1,1.018,1.095,1.2,1.3],ymid:[1.009,1.056,1.146,1.249],iterations:5,events:true,message:""}
205
- 193 PASS: sol = numeric.dopri(0,2,1, function(x,y) { return y; }, undefined,50, function(x,y) { return [y-1.5,Math.sin(y-1.5)]; }); ==> {x:[0,0.2,0.4055],y:[1,1.221,1.5],f:[1,1.221,1.5],ymid:[1.105,1.354],iterations:2,events:[true,true],message:""}
206
- 194 PASS: D = numeric.identity(8); d = numeric.rep([8],0); A = [[1, 1, -1, 0, 0, 0, 0, 0, 0, 0],[-1, 1, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 0, 0, -1, 0, 0, 0, 0, 0],[-1, 1, 0, 0, 0, 1, 0, 0, 0, 0],[1, 1, 0, 0, 0, 0, -1, 0, 0, 0],[-1, 1, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 0, 0, 0, 0, 0, 0, -1, 0],[-1, 1, 0, 0, 0, 0, 0, 0, 0, 1]]; b = [1, 1, -1, 0, -1, 0, -1, 0, -1, 0]; numeric.solveQP(D,d,A,b,undefined,2) ==> {solution:[0.25,0,0.25,0,0.25,0,0.25,0],value:[0.125],unconstrained_solution:[0,0,0,0,0,0,0,0],iterations:[3,0],iact:[1,2,0,0,0,0,0,0,0,0],message:""}
207
- 195 PASS: numeric.imageURL(numeric.rep([3],[[1,2],[3,4]])); ==> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAH0lEQVQIHQAIAPf/AAEBAQICAgABBwD4/wMDAwQEBAAAogAfhs2H3QAAAABJRU5ErkJggg=="
208
- 196 PASS: numeric.gradient(function(x) { return Math.exp(Math.sin(x[0])*(x[1]+2)); },[1,2]); ==> [62.59,24.37]
209
- 197 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
210
- 198 PASS: numeric.seedrandom.random() ==> 0.6139
211
- 199 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
212
- Chrome testing complete. PASS: 200 FAIL: 0 Total: 200
200
+ 188 PASS: numeric.solveLP([1,2,3], /* minimize [1,2,3]*x */ [[1, 0, 0], [0, 1, 0], [0, 0, 1],[-1,0,0],[0,-1,0],[0,0,-1]], /* matrix A of inequality constraint */ [1,1,1,0,0,0], /* RHS b of inequality constraint */ [[1,1,1]], /* matrix Aeq of equality constraint */ [3] /* vector beq of equality constraint */ ); ==> {solution:NaN,message:"Infeasible",iterations:10}
201
+ 189 PASS: sol = numeric.dopri(0,1,1,function(t,y) { return y; }) ==> {x:[0,0.1,0.1522,0.361,0.5792,0.7843,0.9813,1],y:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],f:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],ymid:[1.051,1.134,1.293,1.6,1.977,2.418,2.693],iterations:8,events:,message:""}
202
+ 190 PASS: sol.at([0.3,0.7]) ==> [1.35,2.014]
203
+ 191 PASS: sol = numeric.dopri(0,10,[3,0],function (x,y) { return [y[1],-y[0]]; }); sol.at([0,0.5*Math.PI,Math.PI,1.5*Math.PI,2*Math.PI]) ==> [[3,0],[-9.534e-8,-3],[-3,2.768e-7],[3.63e-7,3],[3,-3.065e-7]]
204
+ 192 PASS: numeric.dopri(0,20,[2,0],function(t,y) { return [y[1], (1-y[0]*y[0])*y[1]-y[0]]; }).at([18,19,20]) ==> [[-1.208,0.9916],[0.4258,2.535],[2.008,-0.04251]]
205
+ 193 PASS: sol = numeric.dopri(0,2,1,function (x,y) { return y; },1e-8,100,function (x,y) { return y-1.3; }); ==> {x:[0,0.0181,0.09051,0.1822,0.2624],y:[1,1.018,1.095,1.2,1.3],f:[1,1.018,1.095,1.2,1.3],ymid:[1.009,1.056,1.146,1.249],iterations:5,events:true,message:""}
206
+ 194 PASS: sol = numeric.dopri(0,2,1, function(x,y) { return y; }, undefined,50, function(x,y) { return [y-1.5,Math.sin(y-1.5)]; }); ==> {x:[0,0.2,0.4055],y:[1,1.221,1.5],f:[1,1.221,1.5],ymid:[1.105,1.354],iterations:2,events:[true,true],message:""}
207
+ 195 PASS: D = numeric.identity(8); d = numeric.rep([8],0); A = [[1, 1, -1, 0, 0, 0, 0, 0, 0, 0],[-1, 1, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 0, 0, -1, 0, 0, 0, 0, 0],[-1, 1, 0, 0, 0, 1, 0, 0, 0, 0],[1, 1, 0, 0, 0, 0, -1, 0, 0, 0],[-1, 1, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 0, 0, 0, 0, 0, 0, -1, 0],[-1, 1, 0, 0, 0, 0, 0, 0, 0, 1]]; b = [1, 1, -1, 0, -1, 0, -1, 0, -1, 0]; numeric.solveQP(D,d,A,b,undefined,2) ==> {solution:[0.25,0,0.25,0,0.25,0,0.25,0],value:[0.125],unconstrained_solution:[0,0,0,0,0,0,0,0],iterations:[3,0],iact:[1,2,0,0,0,0,0,0,0,0],message:""}
208
+ 196 PASS: numeric.imageURL(numeric.rep([3],[[1,2],[3,4]])); ==> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAH0lEQVQIHQAIAPf/AAEBAQICAgABBwD4/wMDAwQEBAAAogAfhs2H3QAAAABJRU5ErkJggg=="
209
+ 197 PASS: numeric.gradient(function(x) { return Math.exp(Math.sin(x[0])*(x[1]+2)); },[1,2]); ==> [62.59,24.37]
210
+ 198 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
211
+ 199 PASS: numeric.seedrandom.random() ==> 0.6139
212
+ 200 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
213
+ Chrome testing complete. PASS: 201 FAIL: 0 Total: 201
213
214
Fetching http://numericjs.com/staging/documentation.html
214
215
In-browser unit tests.
215
216
Using Firefox
@@ -401,16 +402,17 @@ Using Firefox
401
402
185 PASS: numeric.solveLP([1,1],[[1,0],[0,1]],[0,0]).message; ==> "Unbounded"
402
403
186 PASS: numeric.solveLP([1,2,3], /* minimize [1,2,3]*x */ [[-1,0,0],[0,-1,0],[0,0,-1]], /* matrix A of inequality constraint */ [0,0,0], /* RHS b of inequality constraint */ [[1,1,1]], /* matrix Aeq of equality constraint */ [3] /* vector beq of equality constraint */ ); ==> {solution:[3,1.685e-16,4.559e-19],message:"",iterations:12}
403
404
187 PASS: n = 7; m = 3; for(k=0;k<10;++k) { A = numeric.random([n,n]); x = numeric.rep([m],1).concat(numeric.rep([n-m],0)); b = numeric.dot(A,x); J = numeric.diag(numeric.rep([n],-1)); B = numeric.blockMatrix([[A , J ], [numeric.neg(A) , J ], [numeric.rep([n,n],0), J ]]); c = b.concat(numeric.neg(b)).concat(numeric.rep([n],0)); d = numeric.rep([n],0).concat(numeric.rep([n],1)); y = numeric.solveLP(d,B,c).solution; y.length = n; foo = numeric.norm2(numeric.sub(x,y)); if(foo>1e-10) throw new Error("solveLP test fails: "+numeric.prettyPrint({A:A,x:x})); } "solveLP tests pass" ==> "solveLPtestspass"
404
- 188 PASS: sol = numeric.dopri(0,1,1,function(t,y) { return y; }) ==> {x:[0,0.1,0.1522,0.361,0.5792,0.7843,0.9813,1],y:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],f:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],ymid:[1.051,1.134,1.293,1.6,1.977,2.418,2.693],iterations:8,events:,message:""}
405
- 189 PASS: sol.at([0.3,0.7]) ==> [1.35,2.014]
406
- 190 PASS: sol = numeric.dopri(0,10,[3,0],function (x,y) { return [y[1],-y[0]]; }); sol.at([0,0.5*Math.PI,Math.PI,1.5*Math.PI,2*Math.PI]) ==> [[3,0],[-9.534e-8,-3],[-3,2.768e-7],[3.63e-7,3],[3,-3.065e-7]]
407
- 191 PASS: numeric.dopri(0,20,[2,0],function(t,y) { return [y[1], (1-y[0]*y[0])*y[1]-y[0]]; }).at([18,19,20]) ==> [[-1.208,0.9916],[0.4258,2.535],[2.008,-0.04251]]
408
- 192 PASS: sol = numeric.dopri(0,2,1,function (x,y) { return y; },1e-8,100,function (x,y) { return y-1.3; }); ==> {x:[0,0.0181,0.09051,0.1822,0.2624],y:[1,1.018,1.095,1.2,1.3],f:[1,1.018,1.095,1.2,1.3],ymid:[1.009,1.056,1.146,1.249],iterations:5,events:true,message:""}
409
- 193 PASS: sol = numeric.dopri(0,2,1, function(x,y) { return y; }, undefined,50, function(x,y) { return [y-1.5,Math.sin(y-1.5)]; }); ==> {x:[0,0.2,0.4055],y:[1,1.221,1.5],f:[1,1.221,1.5],ymid:[1.105,1.354],iterations:2,events:[true,true],message:""}
410
- 194 PASS: D = numeric.identity(8); d = numeric.rep([8],0); A = [[1, 1, -1, 0, 0, 0, 0, 0, 0, 0],[-1, 1, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 0, 0, -1, 0, 0, 0, 0, 0],[-1, 1, 0, 0, 0, 1, 0, 0, 0, 0],[1, 1, 0, 0, 0, 0, -1, 0, 0, 0],[-1, 1, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 0, 0, 0, 0, 0, 0, -1, 0],[-1, 1, 0, 0, 0, 0, 0, 0, 0, 1]]; b = [1, 1, -1, 0, -1, 0, -1, 0, -1, 0]; numeric.solveQP(D,d,A,b,undefined,2) ==> {solution:[0.25,0,0.25,0,0.25,0,0.25,0],value:[0.125],unconstrained_solution:[0,0,0,0,0,0,0,0],iterations:[3,0],iact:[1,2,0,0,0,0,0,0,0,0],message:""}
411
- 195 PASS: numeric.imageURL(numeric.rep([3],[[1,2],[3,4]])); ==> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAH0lEQVQIHQAIAPf/AAEBAQICAgABBwD4/wMDAwQEBAAAogAfhs2H3QAAAABJRU5ErkJggg=="
412
- 196 PASS: numeric.gradient(function(x) { return Math.exp(Math.sin(x[0])*(x[1]+2)); },[1,2]); ==> [62.59,24.37]
413
- 197 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
414
- 198 PASS: numeric.seedrandom.random() ==> 0.6139
415
- 199 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
416
- Firefox testing complete. PASS: 200 FAIL: 0 Total: 200
405
+ 188 PASS: numeric.solveLP([1,2,3], /* minimize [1,2,3]*x */ [[1, 0, 0], [0, 1, 0], [0, 0, 1],[-1,0,0],[0,-1,0],[0,0,-1]], /* matrix A of inequality constraint */ [1,1,1,0,0,0], /* RHS b of inequality constraint */ [[1,1,1]], /* matrix Aeq of equality constraint */ [3] /* vector beq of equality constraint */ ); ==> {solution:NaN,message:"Infeasible",iterations:10}
406
+ 189 PASS: sol = numeric.dopri(0,1,1,function(t,y) { return y; }) ==> {x:[0,0.1,0.1522,0.361,0.5792,0.7843,0.9813,1],y:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],f:[1,1.105,1.164,1.435,1.785,2.191,2.668,2.718],ymid:[1.051,1.134,1.293,1.6,1.977,2.418,2.693],iterations:8,events:,message:""}
407
+ 190 PASS: sol.at([0.3,0.7]) ==> [1.35,2.014]
408
+ 191 PASS: sol = numeric.dopri(0,10,[3,0],function (x,y) { return [y[1],-y[0]]; }); sol.at([0,0.5*Math.PI,Math.PI,1.5*Math.PI,2*Math.PI]) ==> [[3,0],[-9.534e-8,-3],[-3,2.768e-7],[3.63e-7,3],[3,-3.065e-7]]
409
+ 192 PASS: numeric.dopri(0,20,[2,0],function(t,y) { return [y[1], (1-y[0]*y[0])*y[1]-y[0]]; }).at([18,19,20]) ==> [[-1.208,0.9916],[0.4258,2.535],[2.008,-0.04251]]
410
+ 193 PASS: sol = numeric.dopri(0,2,1,function (x,y) { return y; },1e-8,100,function (x,y) { return y-1.3; }); ==> {x:[0,0.0181,0.09051,0.1822,0.2624],y:[1,1.018,1.095,1.2,1.3],f:[1,1.018,1.095,1.2,1.3],ymid:[1.009,1.056,1.146,1.249],iterations:5,events:true,message:""}
411
+ 194 PASS: sol = numeric.dopri(0,2,1, function(x,y) { return y; }, undefined,50, function(x,y) { return [y-1.5,Math.sin(y-1.5)]; }); ==> {x:[0,0.2,0.4055],y:[1,1.221,1.5],f:[1,1.221,1.5],ymid:[1.105,1.354],iterations:2,events:[true,true],message:""}
412
+ 195 PASS: D = numeric.identity(8); d = numeric.rep([8],0); A = [[1, 1, -1, 0, 0, 0, 0, 0, 0, 0],[-1, 1, 0, 1, 0, 0, 0, 0, 0, 0],[1, 1, 0, 0, -1, 0, 0, 0, 0, 0],[-1, 1, 0, 0, 0, 1, 0, 0, 0, 0],[1, 1, 0, 0, 0, 0, -1, 0, 0, 0],[-1, 1, 0, 0, 0, 0, 0, 1, 0, 0],[1, 1, 0, 0, 0, 0, 0, 0, -1, 0],[-1, 1, 0, 0, 0, 0, 0, 0, 0, 1]]; b = [1, 1, -1, 0, -1, 0, -1, 0, -1, 0]; numeric.solveQP(D,d,A,b,undefined,2) ==> {solution:[0.25,0,0.25,0,0.25,0,0.25,0],value:[0.125],unconstrained_solution:[0,0,0,0,0,0,0,0],iterations:[3,0],iact:[1,2,0,0,0,0,0,0,0,0],message:""}
413
+ 196 PASS: numeric.imageURL(numeric.rep([3],[[1,2],[3,4]])); ==> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAH0lEQVQIHQAIAPf/AAEBAQICAgABBwD4/wMDAwQEBAAAogAfhs2H3QAAAABJRU5ErkJggg=="
414
+ 197 PASS: numeric.gradient(function(x) { return Math.exp(Math.sin(x[0])*(x[1]+2)); },[1,2]); ==> [62.59,24.37]
415
+ 198 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
416
+ 199 PASS: numeric.seedrandom.random() ==> 0.6139
417
+ 200 PASS: numeric.seedrandom.seedrandom(3); numeric.seedrandom.random() ==> 0.7569
418
+ Firefox testing complete. PASS: 201 FAIL: 0 Total: 201
0 commit comments