← QE npm index — QE Package Index

@qe-libs/libqe-wasm

v0.2.5 · dev 0.2.6-dev.9001 — WebAssembly bindings for libqe — shared C++ core for Quantitative Ethnography

Install
# Add to .npmrc once:
    @qe-libs:registry=https://gitlab.com/api/v4/projects/22522458/packages/npm/

    # Then install:
    npm install @qe-libs/libqe-wasm
npm install @qe-libs/libqe-wasm@dev   # latest dev build
Browse on GitLab Package Registry →

@qe-libs/libqe-wasm

WebAssembly bindings for libqe — the shared C++ core for Quantitative Ethnography packages.

Exposes the full libqe API as a zero-dependency ES module usable in browsers and Node.js.

Install

# one-time: tell npm where to find the @qe-libs scope
echo "@qe-libs:registry=https://gitlab.com/api/v4/projects/22522458/packages/npm/" >> ~/.npmrc

npm install @qe-libs/libqe-wasm

Usage

On qe-libs.org/npm/qe-libs-libqe-wasm/ the js run examples have a Run button: they run in your browser on this WebAssembly build, with console.log printed under the example.

⌘/Ctrl + Enter

A 2D trajectory: fit a polynomial through noisy points and evaluate it.

⌘/Ctrl + Enter

Matrix convention

All matrix inputs are flat Float64Array in row-major order with explicit rows and cols arguments. Return values are plain objects:

{ data: Float64Array, rows: number, cols: number }

Access a cell: data[row * cols + col]

API reference

The ENA model code (rotations, node positions, ena_correlation, CCD) is in @qe-libs/rena-wasm and all accumulation in @qe-libs/tma-wasm; both were removed from this package in 0.2.0.

Adjacency

FunctionDescription
`connection_names(names[, diagonal])``string[]` → pair labels `["A & B", ...]`; `diagonal` adds `"A & A"`
`connection_indices(len[, diagonal])`Upper-triangle index pairs `{ rows, cols }`; `diagonal` adds (i, i)
`code_connections(data, n_codes)`Code vector → connection vector
`fold_directed_network(data[, diagonal])`n² directed vector → upper-tri; `diagonal` keeps A→A once
`network_to_vector(data, rows, cols, full[, diagonal])`Matrix → flat vector; `diagonal` keeps the diagonal in the upper-tri

Normalization

FunctionDescription
`normalize_networks(data, rows, cols)`Row-wise L2 normalization
`scale_networks(data, rows, cols)`Max-norm scaling

Modeling

FunctionDescription
`center_points(data, rows, cols)`Subtract column means
`mean_ci(data, rows, cols, conf_level)`t-based CI → `n_dims × 3` `[mean, lower, upper]`
`outlier_ci(data, rows, cols, iqr_factor)`IQR-based interval → `n_dims × 2` `[lower, upper]`

Door

FunctionDescription
`door_lookback_block(data, rows, cols, lookbackSize, aggregateMean, weightingLinear, segmentIds)`Lookback pooling over one unit block; JS wrapper supplies default `segmentIds = []`.
`door_ema_block(data, rows, cols, alpha, segmentIds)`EMA smoothing over one unit block; JS wrapper supplies default `segmentIds = []`.

Trajectory

FunctionDescription
`fit_trajectory_poly(data, rows, cols, t, maxDegree, fixedDegree, criterion, basis)`Fit a 2D polynomial trajectory; JS wrapper defaults to `criterion = "loocv"` and `basis = "orthogonal"`.
`eval_trajectory_curve(coeffsX, coeffsY, tEval)`Evaluate fitted trajectory coordinates.
`eval_trajectory_derivatives(coeffsX, coeffsY, tEval)`Evaluate velocity, acceleration, speed, heading rate, and curvature.
`integrated_trajectory_distance(...)`Integrated Euclidean distance between two curves.
`lagged_trajectory_distance(...)`Normalized lagged follower/leader curve distance.
`signed_turn_lag(...)` / `sweep_signed_turn_lags(...)`Discrete signed turn-lag distance metrics.
`dist_dist_correlation(X, xr, xc, Y, yr, yc)`Correlation between pairwise distance structures.

Nesting

FunctionDescription
`nesting_candidates(data, rows, cols, threshold, minRows)`Nested-code candidates from a lines × codes 0/1 matrix (row-major). JS wrapper defaults `threshold = 0.95`, `minRows = 5`. Returns `{ cooccurrence: matObj, pairs: [{ sub, parent, containment }], duplicates: [{ a, b }] }` with 0-based column indices; `NaN` is absent.

Building from source

Prerequisites

Steps

# From the libqe repo root:
sh wasm/scripts/build.sh

# Output: wasm/dist/libqe.js  wasm/dist/libqe.wasm

The build uses ../include/libqe/ headers directly — no Conan registry fetch needed. Conan is only used to install Armadillo for the Emscripten cross-compilation.

Notes on Armadillo and BLAS

libqe uses Armadillo for linear algebra. The WASM build compiles with ARMA_DONT_USE_BLAS and ARMA_DONT_USE_LAPACK so Armadillo uses its own built-in LU/QR routines instead of calling external symbols that Emscripten cannot resolve. For ENA's typical data sizes this has no meaningful performance impact.

Running tests

cd wasm
npm ci
npm test   # requires dist/ — run build first

Powered by GitLab CI — Package registry — QE Package Index