/ concept-collection / fastandaccurate
Sign in
concept-collection / fastandaccurate
fastandaccurate / src / app / matlabSources.ts
30 lines · 988 BBlameHistoryRaw
1// The MATLAB sources, inlined into the bundle by vite. Used by the worker
2// and by the problem page's source listing; the node CLI reads the same
3// files from disk.
5import { getSolver, solverSourceDir } from "../solvers";
7const files = import.meta.glob("../{problems,solvers}/**/*.m", {
8 query: "?raw",
9 import: "default",
10 eager: true,
11}) as Record<string, string>;
13function get(path: string): string {
14 const src = files[path];
15 if (!src) throw new Error(`missing MATLAB source: ${path}`);
16 return src;
19export function matlabBase() {
20 return {
21 buildProblem: get("../problems/laplace2d/matlab/build_problem.m"),
22 bdata: get("../problems/laplace2d/matlab/laplace2d_bdata.m"),
23 };
26/** The solver.m of a registry solver, resolved through its manifest so
27 * that entries sharing a file (mfs and mfs-mat) read the one source. */
28export function solverSource(solverId: string): string {
29 return get(`../solvers/${solverSourceDir(getSolver(solverId))}/solver.m`);
moveopenescclose