Published
Edited
Dec 28, 2019
1 star
Also listed in…
Hello
Insert cell
Insert cell
mljs = require(await FileAttachment("mljs-noglpk-module.js").url())
/* "https://www.doc.gold.ac.uk/~esoer001/mljs-noglpk-module.js" */
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// we've put mljs-noglpk-module.js and lalolibworker.js together in one file…
lab = new mljs.Lalolab(
"labname",
false,
(await FileAttachment("mljs-noglpk-module-with-worker@3.js").url()) +
"#" /* "https://raw.githack.com/lauerfab/MLweb/master/lalolab/" /*+ "lalolibworker.js"*/
/* path */
)
Insert cell
{
const n = 500; // maximum for eigs() is about n ~= 1300
var A = Array.from({ length: n }, () =>
Array.from({ length: n }, Math.random)
);
return new Promise(resolve => {
lab.load(A, "A");
lab.do('E = eigs(A, 4, "smallest")');
lab.getObject("E", resolve);
});
}
Insert cell
Insert cell
function eigen({ matrix, n, what }) {
return mljs.eigs(matrix, n, what);
}
Insert cell
Insert cell
EIGENWORKER = Generators.queue(
worker(
eigen,
{ matrix: C, n: 3, what: "smallest" },
`
importScripts("https://www.doc.gold.ac.uk/~esoer001/mljs-module_old.min.js");
`
)
)
Insert cell
EIGENWORKER.V
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more