@nirs4all/methods 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ /** Float row-major matrix view passed to nirs4all-methods. */
2
+ export interface Matrix {
3
+ /** Row-major data buffer. Length must be `rows * cols`. */
4
+ data: Float64Array;
5
+ rows: number;
6
+ cols: number;
7
+ }
8
+ /** Mirror of the C enum n4m_status_t. */
9
+ export declare enum Status {
10
+ OK = 0,
11
+ ERR_INVALID_ARGUMENT = 1,
12
+ ERR_NULL_POINTER = 2,
13
+ ERR_OUT_OF_MEMORY = 3,
14
+ ERR_DTYPE_MISMATCH = 4,
15
+ ERR_SHAPE_MISMATCH = 5,
16
+ ERR_DIM_MISMATCH = 6,
17
+ ERR_NUMERICAL_FAILURE = 7,
18
+ ERR_NOT_FITTED = 8,
19
+ ERR_INTERNAL = 9,
20
+ ERR_ABI_MISMATCH = 10,
21
+ ERR_VERSION_INCOMPATIBLE = 11,
22
+ ERR_BACKEND_UNAVAILABLE = 12,
23
+ ERR_IO = 13,
24
+ ERR_PERMISSION = 14,
25
+ ERR_NOT_IMPLEMENTED = 15,
26
+ ERR_TIMEOUT = 16,
27
+ ERR_CANCELED = 17
28
+ }
29
+ /** Mirror of n4m_dtype_t (cpp/include/n4m/n4m.h §2). */
30
+ export declare enum Dtype {
31
+ UNKNOWN = 0,
32
+ F64 = 1,
33
+ F32 = 2,
34
+ I32 = 3,
35
+ I64 = 4
36
+ }
37
+ /** Mirror of n4m_algorithm_t. Values must match cpp/include/n4m/n4m.h. */
38
+ export declare enum Algorithm {
39
+ PLS_REGRESSION = 0,
40
+ PLS_CANONICAL = 1,
41
+ PLS_SVD = 2,
42
+ PLS_DA = 3,
43
+ OPLS = 4,
44
+ OPLS_DA = 5,
45
+ SPARSE_PLS = 6,
46
+ MB_PLS = 7,
47
+ LW_PLS = 8,
48
+ AOM_PLS = 9,
49
+ PCR = 10
50
+ }
51
+ /** Mirror of n4m_solver_t. */
52
+ export declare enum Solver {
53
+ NIPALS = 0,
54
+ SIMPLS = 1,
55
+ ORTHOGONAL_SCORES = 2,
56
+ KERNEL_ALGORITHM = 3,
57
+ WIDE_KERNEL = 4,
58
+ SVD = 5,
59
+ POWER = 6,
60
+ RANDOMIZED_SVD = 7
61
+ }
62
+ /** Mirror of n4m_deflation_t. */
63
+ export declare enum Deflation {
64
+ REGRESSION = 0,
65
+ CANONICAL = 1,
66
+ X_ONLY = 2,
67
+ XY = 3,
68
+ ORTHOGONAL = 4
69
+ }
70
+ export declare class N4mError extends Error {
71
+ readonly status: number;
72
+ constructor(status: number, message: string);
73
+ }
package/dist/types.js ADDED
@@ -0,0 +1,76 @@
1
+ // SPDX-License-Identifier: CECILL-2.1
2
+ /** Mirror of the C enum n4m_status_t. */
3
+ export var Status;
4
+ (function (Status) {
5
+ Status[Status["OK"] = 0] = "OK";
6
+ Status[Status["ERR_INVALID_ARGUMENT"] = 1] = "ERR_INVALID_ARGUMENT";
7
+ Status[Status["ERR_NULL_POINTER"] = 2] = "ERR_NULL_POINTER";
8
+ Status[Status["ERR_OUT_OF_MEMORY"] = 3] = "ERR_OUT_OF_MEMORY";
9
+ Status[Status["ERR_DTYPE_MISMATCH"] = 4] = "ERR_DTYPE_MISMATCH";
10
+ Status[Status["ERR_SHAPE_MISMATCH"] = 5] = "ERR_SHAPE_MISMATCH";
11
+ Status[Status["ERR_DIM_MISMATCH"] = 6] = "ERR_DIM_MISMATCH";
12
+ Status[Status["ERR_NUMERICAL_FAILURE"] = 7] = "ERR_NUMERICAL_FAILURE";
13
+ Status[Status["ERR_NOT_FITTED"] = 8] = "ERR_NOT_FITTED";
14
+ Status[Status["ERR_INTERNAL"] = 9] = "ERR_INTERNAL";
15
+ Status[Status["ERR_ABI_MISMATCH"] = 10] = "ERR_ABI_MISMATCH";
16
+ Status[Status["ERR_VERSION_INCOMPATIBLE"] = 11] = "ERR_VERSION_INCOMPATIBLE";
17
+ Status[Status["ERR_BACKEND_UNAVAILABLE"] = 12] = "ERR_BACKEND_UNAVAILABLE";
18
+ Status[Status["ERR_IO"] = 13] = "ERR_IO";
19
+ Status[Status["ERR_PERMISSION"] = 14] = "ERR_PERMISSION";
20
+ Status[Status["ERR_NOT_IMPLEMENTED"] = 15] = "ERR_NOT_IMPLEMENTED";
21
+ Status[Status["ERR_TIMEOUT"] = 16] = "ERR_TIMEOUT";
22
+ Status[Status["ERR_CANCELED"] = 17] = "ERR_CANCELED";
23
+ })(Status || (Status = {}));
24
+ /** Mirror of n4m_dtype_t (cpp/include/n4m/n4m.h §2). */
25
+ export var Dtype;
26
+ (function (Dtype) {
27
+ Dtype[Dtype["UNKNOWN"] = 0] = "UNKNOWN";
28
+ Dtype[Dtype["F64"] = 1] = "F64";
29
+ Dtype[Dtype["F32"] = 2] = "F32";
30
+ Dtype[Dtype["I32"] = 3] = "I32";
31
+ Dtype[Dtype["I64"] = 4] = "I64";
32
+ })(Dtype || (Dtype = {}));
33
+ /** Mirror of n4m_algorithm_t. Values must match cpp/include/n4m/n4m.h. */
34
+ export var Algorithm;
35
+ (function (Algorithm) {
36
+ Algorithm[Algorithm["PLS_REGRESSION"] = 0] = "PLS_REGRESSION";
37
+ Algorithm[Algorithm["PLS_CANONICAL"] = 1] = "PLS_CANONICAL";
38
+ Algorithm[Algorithm["PLS_SVD"] = 2] = "PLS_SVD";
39
+ Algorithm[Algorithm["PLS_DA"] = 3] = "PLS_DA";
40
+ Algorithm[Algorithm["OPLS"] = 4] = "OPLS";
41
+ Algorithm[Algorithm["OPLS_DA"] = 5] = "OPLS_DA";
42
+ Algorithm[Algorithm["SPARSE_PLS"] = 6] = "SPARSE_PLS";
43
+ Algorithm[Algorithm["MB_PLS"] = 7] = "MB_PLS";
44
+ Algorithm[Algorithm["LW_PLS"] = 8] = "LW_PLS";
45
+ Algorithm[Algorithm["AOM_PLS"] = 9] = "AOM_PLS";
46
+ Algorithm[Algorithm["PCR"] = 10] = "PCR";
47
+ })(Algorithm || (Algorithm = {}));
48
+ /** Mirror of n4m_solver_t. */
49
+ export var Solver;
50
+ (function (Solver) {
51
+ Solver[Solver["NIPALS"] = 0] = "NIPALS";
52
+ Solver[Solver["SIMPLS"] = 1] = "SIMPLS";
53
+ Solver[Solver["ORTHOGONAL_SCORES"] = 2] = "ORTHOGONAL_SCORES";
54
+ Solver[Solver["KERNEL_ALGORITHM"] = 3] = "KERNEL_ALGORITHM";
55
+ Solver[Solver["WIDE_KERNEL"] = 4] = "WIDE_KERNEL";
56
+ Solver[Solver["SVD"] = 5] = "SVD";
57
+ Solver[Solver["POWER"] = 6] = "POWER";
58
+ Solver[Solver["RANDOMIZED_SVD"] = 7] = "RANDOMIZED_SVD";
59
+ })(Solver || (Solver = {}));
60
+ /** Mirror of n4m_deflation_t. */
61
+ export var Deflation;
62
+ (function (Deflation) {
63
+ Deflation[Deflation["REGRESSION"] = 0] = "REGRESSION";
64
+ Deflation[Deflation["CANONICAL"] = 1] = "CANONICAL";
65
+ Deflation[Deflation["X_ONLY"] = 2] = "X_ONLY";
66
+ Deflation[Deflation["XY"] = 3] = "XY";
67
+ Deflation[Deflation["ORTHOGONAL"] = 4] = "ORTHOGONAL";
68
+ })(Deflation || (Deflation = {}));
69
+ export class N4mError extends Error {
70
+ status;
71
+ constructor(status, message) {
72
+ super(`n4m error ${status}: ${message}`);
73
+ this.name = "N4mError";
74
+ this.status = status;
75
+ }
76
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@nirs4all/methods",
3
+ "version": "1.0.6",
4
+ "description": "WebAssembly build of libn4m (nirs4all-methods) — portable PLS/NIRS engine, full 188-method surface.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./n4m.wasm": "./dist/n4m.wasm"
14
+ },
15
+ "files": [
16
+ "dist/"
17
+ ],
18
+ "scripts": {
19
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
20
+ "build": "npm run clean && tsc -p .",
21
+ "stage:wasm": "node -e \"const fs=require('fs'),p='../../build/emscripten/bindings/js/';fs.mkdirSync('dist',{recursive:true});for(const f of ['n4m.js','n4m.wasm']){if(!fs.existsSync(p+f))throw new Error('missing WASM artifact '+p+f+' — run: cmake --preset emscripten && cmake --build --preset emscripten --target n4m_wasm');fs.copyFileSync(p+f,'dist/'+f)}console.log('staged n4m.js + n4m.wasm into dist/')\"",
22
+ "prepack": "npm run build && npm run stage:wasm",
23
+ "test": "node --experimental-vm-modules test/run_smoke.mjs && node --experimental-vm-modules test/run_api.mjs && node --experimental-vm-modules test/run_generic_method.mjs && node --experimental-vm-modules test/run_pop_aom.mjs && node --experimental-vm-modules test/run_new_pack.mjs"
24
+ },
25
+ "license": "CECILL-2.1",
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "provenance": true
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/GBeurier/nirs4all-methods.git",
33
+ "directory": "bindings/js"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "^5.4.0"
37
+ }
38
+ }