Skip to content

Commit

Permalink
Consolidate mathjs bundle:
Browse files Browse the repository at this point in the history
* Move mathjs bundling into one file
* Add seeding
  • Loading branch information
giovannic committed Nov 27, 2020
1 parent 08a7e20 commit 06c2b7c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 55 deletions.
25 changes: 1 addition & 24 deletions src/eigenvalues.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import {
create,
randomDependencies,
dotMultiplyDependencies,
divideDependencies,
normDependencies,
maxDependencies,
absDependencies,
sumDependencies,
dotDependencies,
subtractDependencies
} from 'mathjs';

const {
random,
multiply,
dotMultiply,
Expand All @@ -22,17 +9,7 @@ const {
sum,
dot,
subtract
} = create({
randomDependencies,
dotMultiplyDependencies,
divideDependencies,
normDependencies,
maxDependencies,
absDependencies,
sumDependencies,
dotDependencies,
subtractDependencies
}, {});
} from './math_bundle.js'

function raleighQuotient(m, x) {
return dot(multiply(m, x), x) / dot(x, x)
Expand Down
59 changes: 59 additions & 0 deletions src/math_bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//build small(er) version of math.js
import {
create,
addDependencies,
dotDivideDependencies,
dotMultiplyDependencies,
subsetDependencies,
indexDependencies,
rangeDependencies,
multiplyDependencies,
subtractDependencies,
transposeDependencies,
squeezeDependencies,
randomDependencies,
divideDependencies,
normDependencies,
maxDependencies,
absDependencies,
sumDependencies,
dotDependencies
} from 'mathjs';

export const {
add,
dotDivide,
dotMultiply,
subset,
index,
range,
transpose,
multiply,
subtract,
squeeze,
random,
divide,
norm,
max,
abs,
sum,
dot
} = create({
addDependencies,
dotDivideDependencies,
dotMultiplyDependencies,
subsetDependencies,
indexDependencies,
rangeDependencies,
multiplyDependencies,
subtractDependencies,
transposeDependencies,
squeezeDependencies,
randomDependencies,
divideDependencies,
normDependencies,
maxDependencies,
absDependencies,
sumDependencies,
dotDependencies
}, { randomSeed: 42 })
33 changes: 2 additions & 31 deletions src/reff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@ import { wellFormedArray } from './utils.js';
import { leadingEigenvalue } from './eigenvalues.js';

import {
create,
addDependencies,
dotDivideDependencies,
dotMultiplyDependencies,
subsetDependencies,
indexDependencies,
rangeDependencies,
multiplyDependencies,
subtractDependencies,
transposeDependencies,
squeezeDependencies,
flattenDependencies
} from 'mathjs';

//build small version of math.js
const {
add,
dotDivide,
dotMultiply,
Expand All @@ -27,21 +11,8 @@ const {
transpose,
multiply,
subtract,
squeeze,
flatten
} = create({
addDependencies,
dotDivideDependencies,
dotMultiplyDependencies,
multiplyDependencies,
subsetDependencies,
indexDependencies,
rangeDependencies,
subtractDependencies,
squeezeDependencies,
transposeDependencies,
flattenDependencies
}, {})
squeeze
} from './math_bundle.js';

import pars from '../data/pars_0.json'

Expand Down

0 comments on commit 06c2b7c

Please sign in to comment.