Test name | Executions per second |
---|---|
Cubic polynomials with 3 real roots | 1219.0 Ops/sec |
Cubic polynomials with flat random coefficients | 13691.4 Ops/sec |
Degree 4 polynomials with 4 real roots | 513.4 Ops/sec |
Degree 4 polynomials with flat random coefficients | 1855.3 Ops/sec |
Degree 7 polynomials with 7 real roots | 134.6 Ops/sec |
Degree 7 polynomials with flat random coefficients | 397.0 Ops/sec |
Degree 12 polynomials with 12 real roots | 37.7 Ops/sec |
Deg 12 polynomials with flat random coefficients | 124.9 Ops/sec |
<script src="https://mat-demo.appspot.com/bower_components/flo-poly/dist/flo-poly.js"></script>
var { evaluate, allRoots, hornerErrorBound } = FloPoly;
var { flatRootsArr, flatCoefficientsArr } = FloPoly.random;
const orders = [3,4,7,12,15];
var pssRealRootsOnly = [
// Flat random distribution of roots in [-10,10]
flatRootsArr(100, orders[0], -10, 10, 11111),
flatRootsArr(100, orders[1], -10, 10, 22222),
flatRootsArr(100, orders[2], -10, 10, 33333),
flatRootsArr(100, orders[3], -10, 10, 44444),
flatRootsArr(100, orders[4], -10, 10, 55555),
];
var pssRandomCoefficients = [
// Flat random distribution of coefficients in [-10,10]
flatCoefficientsArr(100, orders[0], -10, 10, 66666),
flatCoefficientsArr(100, orders[1], -10, 10, 77777),
flatCoefficientsArr(100, orders[2], -10, 10, 88888),
flatCoefficientsArr(100, orders[3], -10, 10, 99999),
flatCoefficientsArr(100, orders[4], -10, 10, 12121),
];
for (let i=0; i<pssRealRootsOnly[0].length; i++) {
var p = pssRealRootsOnly[0][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRandomCoefficients[0].length; i++) {
var p = pssRandomCoefficients[0][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRealRootsOnly[1].length; i++) {
var p = pssRealRootsOnly[1][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRandomCoefficients[1].length; i++) {
var p = pssRandomCoefficients[1][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRealRootsOnly[2].length; i++) {
var p = pssRealRootsOnly[2][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRandomCoefficients[2].length; i++) {
var p = pssRandomCoefficients[2][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRealRootsOnly[3].length; i++) {
var p = pssRealRootsOnly[3][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRandomCoefficients[3].length; i++) {
var p = pssRandomCoefficients[3][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRealRootsOnly[4].length; i++) {
var p = pssRealRootsOnly[4][i];
var roots = allRoots(p);
}
for (let i=0; i<pssRandomCoefficients[4].length; i++) {
var p = pssRandomCoefficients[4][i];
var roots = allRoots(p);
}