pub struct JsSolver { /* private fields */ }Expand description
Top-level solver handle exposed to JavaScript.
Wraps the algorithm router and iterative solvers, providing a high-level API that accepts CSR arrays directly from JS typed arrays.
Implementations§
Source§impl JsSolver
impl JsSolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new solver with default parameters.
max_iterations: 1000tolerance: 1e-6alpha(PageRank teleport): 0.15
Sourcepub fn set_max_iterations(&mut self, max_iterations: usize)
pub fn set_max_iterations(&mut self, max_iterations: usize)
Set the maximum number of iterations for iterative solvers.
Sourcepub fn set_tolerance(&mut self, tolerance: f64)
pub fn set_tolerance(&mut self, tolerance: f64)
Set the convergence tolerance.
Sourcepub fn solve(
&self,
values: &[f32],
col_indices: &[u32],
row_ptrs: &[u32],
rows: usize,
cols: usize,
rhs: &[f32],
) -> Result<JsValue, JsError>
pub fn solve( &self, values: &[f32], col_indices: &[u32], row_ptrs: &[u32], rows: usize, cols: usize, rhs: &[f32], ) -> Result<JsValue, JsError>
Solve a sparse linear system Ax = b.
The matrix A is provided in CSR format via three flat arrays.
Returns a JSON-serialisable result object on success.
§Arguments
values- Non-zero values (Float32Array).col_indices- Column indices for each non-zero (Uint32Array).row_ptrs- Row pointers of lengthrows + 1(Uint32Array).rows- Number of rows.cols- Number of columns.rhs- Right-hand side vectorb(Float32Array).
§Errors
Returns JsError on invalid input or non-convergence.
Sourcepub fn pagerank(
&self,
values: &[f32],
col_indices: &[u32],
row_ptrs: &[u32],
rows: usize,
source: usize,
tolerance: f64,
) -> Result<JsValue, JsError>
pub fn pagerank( &self, values: &[f32], col_indices: &[u32], row_ptrs: &[u32], rows: usize, source: usize, tolerance: f64, ) -> Result<JsValue, JsError>
Compute Personalized PageRank from a single source node.
Uses the power-iteration method with teleportation probability alpha
(configurable via set_alpha).
§Arguments
values- Edge weights (Float32Array).col_indices- Column indices (Uint32Array).row_ptrs- Row pointers (Uint32Array).rows- Number of nodes.source- Source node index.tolerance- Convergence tolerance (L1 residual).
§Errors
Returns JsError on invalid input.
Sourcepub fn estimate_complexity(
&self,
values: &[f32],
col_indices: &[u32],
row_ptrs: &[u32],
rows: usize,
cols: usize,
) -> Result<JsValue, JsError>
pub fn estimate_complexity( &self, values: &[f32], col_indices: &[u32], row_ptrs: &[u32], rows: usize, cols: usize, ) -> Result<JsValue, JsError>
Estimate the computational complexity of solving a system with the given matrix without performing the actual solve.
Returns a JSON object with the selected algorithm, estimated FLOPS, estimated iterations, memory usage, and complexity class.
Trait Implementations§
Source§impl FromWasmAbi for JsSolver
impl FromWasmAbi for JsSolver
Source§impl IntoWasmAbi for JsSolver
impl IntoWasmAbi for JsSolver
Source§impl LongRefFromWasmAbi for JsSolver
impl LongRefFromWasmAbi for JsSolver
Source§impl OptionFromWasmAbi for JsSolver
impl OptionFromWasmAbi for JsSolver
Source§impl OptionIntoWasmAbi for JsSolver
impl OptionIntoWasmAbi for JsSolver
Source§impl RefFromWasmAbi for JsSolver
impl RefFromWasmAbi for JsSolver
Source§impl RefMutFromWasmAbi for JsSolver
impl RefMutFromWasmAbi for JsSolver
Source§impl TryFromJsValue for JsSolver
impl TryFromJsValue for JsSolver
Source§impl VectorFromWasmAbi for JsSolver
impl VectorFromWasmAbi for JsSolver
Source§impl VectorIntoWasmAbi for JsSolver
impl VectorIntoWasmAbi for JsSolver
impl SupportsConstructor for JsSolver
impl SupportsInstanceProperty for JsSolver
impl SupportsStaticProperty for JsSolver
Auto Trait Implementations§
impl Freeze for JsSolver
impl RefUnwindSafe for JsSolver
impl Send for JsSolver
impl Sync for JsSolver
impl Unpin for JsSolver
impl UnsafeUnpin for JsSolver
impl UnwindSafe for JsSolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.