Skip to main content

ExactNumArray

Struct ExactNumArray 

Source
pub struct ExactNumArray { /* private fields */ }
Expand description

Batch of ExactNum values at a shared precision p, row-major.

Implementations§

Source§

impl ExactNumArray

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Error>

Encode shape, shared p, and every element.

Source

pub fn write_bytes(&self, dest: &mut [u8]) -> Result<usize, Error>

Write the array record into dest without allocating.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>

Decode an array record. Shape product must match the element count.

Source§

impl ExactNumArray

Source

pub fn to_csv_string(&self) -> Result<String, Error>

Encode each cell as Display@p=<bits>.

Source

pub fn from_csv_str(text: &str) -> Result<Self, Error>

Parse CSV of Display / Display@p= cells. Empty → NaN.

Source

pub fn to_csv<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Write Self::to_csv_string to path.

Source

pub fn from_csv<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Read Self::from_csv_str from path.

Source§

impl ExactNumArray

Source

pub fn new(p: usize) -> Self

Empty 0×0 array at precision p.

Source

pub fn filled(p: usize, n: usize, fill: &ExactNum) -> Self

Row vector: n copies of fill (rounded to p).

Source

pub fn filled_2d( p: usize, rows: usize, cols: usize, fill: &ExactNum, ) -> Option<Self>

rows×cols filled with fill (rounded to p).

Source

pub fn from_values(p: usize, vals: &[ExactNum]) -> Self

From values as a row vector; each is rounded to p.

Source

pub fn from_shape( p: usize, rows: usize, cols: usize, vals: &[ExactNum], ) -> Option<Self>

Row-major rows×cols. Length must be rows*cols.

Source

pub fn precision(&self) -> usize

Shared precision.

Source

pub fn shape(&self) -> (usize, usize)

(rows, cols).

Source

pub fn reshape(&self, rows: usize, cols: usize) -> Option<Self>

Reinterpret the same buffer as rows×cols when the product matches.

Source

pub fn len(&self) -> usize

Number of lanes.

Source

pub fn is_empty(&self) -> bool

True if there are no lanes.

Source

pub fn get(&self, i: usize) -> Option<&ExactNum>

Lane i in storage order.

Source

pub fn get2(&self, i: usize, j: usize) -> Option<&ExactNum>

Entry (i, j), or None if out of range.

Source

pub fn as_slice(&self) -> &[ExactNum]

All values in row-major order.

Source

pub fn add(&self, rhs: &Self) -> Option<Self>

Elementwise add at p.

Source

pub fn add_scalar(&self, s: &ExactNum) -> Self

Add a scalar to every lane.

Source

pub fn sub(&self, rhs: &Self) -> Option<Self>

Elementwise sub.

Source

pub fn mul(&self, rhs: &Self) -> Option<Self>

Elementwise mul.

Source

pub fn mul_scalar(&self, s: &ExactNum) -> Self

Multiply every lane by a scalar.

Source

pub fn div(&self, rhs: &Self) -> Option<Self>

Elementwise div.

Source

pub fn sum(&self) -> ExactNum

Sequential sum at p.

Source

pub fn dot(&self, rhs: &Self) -> Option<ExactNum>

Sequential dot product at p.

Source

pub fn matmul(&self, rhs: &Self) -> Option<Self>

Software matmul: (m×k)(k×n) → (m×n). Sequential mul-then-add at p.

Source

pub fn int(&self) -> Self

Elementwise integer part.

Source

pub fn fract(&self) -> Self

Elementwise fractional part.

Source

pub fn ceil(&self) -> Self

Elementwise ceil.

Source

pub fn floor(&self) -> Self

Elementwise floor.

Source

pub fn round(&self, n: usize, rm: RoundingMode) -> Self

Elementwise round with n binary fractional bits.

Source

pub fn abs(&self) -> Self

Elementwise absolute value.

Source

pub fn signum(&self) -> Self

Elementwise signum.

Source

pub fn neg(&self) -> Self

Elementwise negation.

Source

pub fn reciprocal(&self, p: usize, rm: RoundingMode) -> Self

Elementwise reciprocal.

Source

pub fn nth_root(&self, n: usize, p: usize, rm: RoundingMode) -> Self

Elementwise nth_root.

Source

pub fn powi(&self, n: usize, p: usize, rm: RoundingMode) -> Self

Elementwise powi.

Source

pub fn powsi(&self, n: isize, p: usize, rm: RoundingMode) -> Self

Elementwise powsi.

Source

pub fn sin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::sin. cc is the constants cache, not a global.

Source

pub fn cos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::cos. cc is the constants cache, not a global.

Source

pub fn tan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::tan. cc is the constants cache, not a global.

Source

pub fn asin(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::asin. cc is the constants cache, not a global.

Source

pub fn acos(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::acos. cc is the constants cache, not a global.

Source

pub fn atan(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::atan. cc is the constants cache, not a global.

Source

pub fn sinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::sinh. cc is the constants cache, not a global.

Source

pub fn cosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::cosh. cc is the constants cache, not a global.

Source

pub fn tanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::tanh. cc is the constants cache, not a global.

Source

pub fn asinh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::asinh. cc is the constants cache, not a global.

Source

pub fn acosh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::acosh. cc is the constants cache, not a global.

Source

pub fn atanh(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::atanh. cc is the constants cache, not a global.

Source

pub fn exp(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::exp. cc is the constants cache, not a global.

Source

pub fn exp2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::exp2. cc is the constants cache, not a global.

Source

pub fn exp10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::exp10. cc is the constants cache, not a global.

Source

pub fn expm1(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::expm1. cc is the constants cache, not a global.

Source

pub fn ln(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::ln. cc is the constants cache, not a global.

Source

pub fn log2(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::log2. cc is the constants cache, not a global.

Source

pub fn log10(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::log10. cc is the constants cache, not a global.

Source

pub fn log1p(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::log1p. cc is the constants cache, not a global.

Source

pub fn erf(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::erf. cc is the constants cache, not a global.

Source

pub fn erfc(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::erfc. cc is the constants cache, not a global.

Source

pub fn gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::gamma. cc is the constants cache, not a global.

Source

pub fn ln_gamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::ln_gamma. cc is the constants cache, not a global.

Source

pub fn digamma(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::digamma. cc is the constants cache, not a global.

Source

pub fn ei(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::ei. cc is the constants cache, not a global.

Source

pub fn si(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::si. cc is the constants cache, not a global.

Source

pub fn ci(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::ci. cc is the constants cache, not a global.

Source

pub fn li(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::li. cc is the constants cache, not a global.

Source

pub fn fresnel_s(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::fresnel_s. cc is the constants cache, not a global.

Source

pub fn fresnel_c(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::fresnel_c. cc is the constants cache, not a global.

Source

pub fn ai(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::ai. cc is the constants cache, not a global.

Source

pub fn bi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::bi. cc is the constants cache, not a global.

Source

pub fn elliptic_k(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::elliptic_k. cc is the constants cache, not a global.

Source

pub fn elliptic_e_complete( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise ExactNum::elliptic_e_complete. cc is the constants cache, not a global.

Source

pub fn rem_pi(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Self

Elementwise ExactNum::rem_pi. cc is the constants cache, not a global.

Source

pub fn sin_cos( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> (Self, Self)

Elementwise (sin, cos) with a shared argument reduction.

Source

pub fn sinh_cosh( &self, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> (Self, Self)

Elementwise (sinh, cosh) with a shared evaluation.

Source

pub fn sqrt(&self, p: usize, rm: RoundingMode) -> Self

Elementwise sqrt.

Source

pub fn cbrt(&self, p: usize, rm: RoundingMode) -> Self

Elementwise cbrt.

Source

pub fn legendre_p(&self, n: u32, p: usize, rm: RoundingMode) -> Self

Elementwise P_n(self).

Source

pub fn assoc_legendre_p( &self, n: u32, m: i32, p: usize, rm: RoundingMode, ) -> Self

Elementwise P_n^m(self).

Source

pub fn hypot(&self, other: &ExactNum, p: usize, rm: RoundingMode) -> Self

Elementwise hypot(self, other).

Source

pub fn atan2( &self, x: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise atan2(self, x). cc is the constants cache, not a global.

Source

pub fn pow( &self, n: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise pow(self, n).

Source

pub fn log( &self, base: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise log(self, base).

Source

pub fn gammainc( &self, x: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise γ(self, x).

Source

pub fn gammainc_upper( &self, x: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise Γ(self, x).

Source

pub fn bessel_j( &self, n: usize, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise integer-order J_n(self).

Source

pub fn bessel_j_nu( &self, nu: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise J_ν(self).

Source

pub fn bessel_y( &self, nu: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise Y_ν(self).

Source

pub fn bessel_i( &self, nu: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise I_ν(self).

Source

pub fn bessel_k( &self, nu: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise K_ν(self).

Source

pub fn elliptic_f( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise F(self | m).

Source

pub fn jacobi_sn( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise sn(self | m).

Source

pub fn jacobi_cn( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise cn(self | m).

Source

pub fn jacobi_dn( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise dn(self | m).

Source

pub fn jacobi_am( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise am(self | m).

Source

pub fn jacobi_cd( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise cd(self | m).

Source

pub fn jacobi_ns( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise ns(self | m).

Source

pub fn jacobi_nc( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise nc(self | m).

Source

pub fn jacobi_nd( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise nd(self | m).

Source

pub fn jacobi_sc( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise sc(self | m).

Source

pub fn jacobi_sd( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise sd(self | m).

Source

pub fn jacobi_cs( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise cs(self | m).

Source

pub fn jacobi_ds( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise ds(self | m).

Source

pub fn jacobi_dc( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise dc(self | m).

Source

pub fn elliptic_e( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise incomplete E(self | m).

Source

pub fn elliptic_pi_complete( &self, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise complete Π(n, m) with self = n.

Source

pub fn elliptic_pi( &self, x: &ExactNum, m: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise Π(self; x | m).

Source

pub fn hypergeom_2f1( &self, b: &ExactNum, c: &ExactNum, z: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise {}_2F_1(self, b; c; z).

Source

pub fn betainc( &self, b: &ExactNum, x: &ExactNum, p: usize, rm: RoundingMode, cc: &mut Consts, ) -> Self

Elementwise I_x(self, b).

Source

pub fn lu_decomp( &self, p: usize, rm: RoundingMode, ) -> Option<(Self, Self, Vec<usize>)>

LU with partial pivoting: (L, U, P) such that row i of P·A is original row P[i], and P·A = L·U at (p, rm).

L is unit lower (n×n). U is upper (n×m). A zero pivot (singular) or a failed heap reserve (MemoryAllocation) returns None.

Source

pub fn transpose(&self) -> Self

Row–column transpose.

Source

pub fn qr_decomp(&self, p: usize, rm: RoundingMode) -> Option<(Self, Self)>

Modified Gram–Schmidt QR at (p, rm).

Returns (Q, R) with Q m×k having orthonormal columns, R k×n upper triangular, k = min(m, n). A rank-deficient column is a zero column of Q and a zero diagonal entry of R — not a panic.

Source

pub fn svd_decomp( &self, p: usize, rm: RoundingMode, ) -> Option<(Self, Self, Self)>

Golub–Reinsch SVD at (p, rm).

Returns (U, Σ, V^T) with U m×k (orthonormal columns), Σ k×k diagonal (non-negative, descending), V^T k×n (orthonormal rows), k = min(m, n), so that U · Σ · V^T = A at working precision. Empty input, a NaN/Inf entry, a failed heap reserve, or failure to converge within SVD_ITER_MAX sweeps per singular value returns None.

Source

pub fn eigen_decomp(&self, p: usize, rm: RoundingMode) -> Option<(Self, Self)>

Symmetric QR eigendecomposition at (p, rm).

Returns (Λ, V) where Λ is a 1×n row of eigenvalues (descending) and V is n×n with orthonormal columns, so A V = V diag(Λ) and V diag(Λ) V^T = A at working precision. Non-square, non-symmetric, empty, non-finite, or failure to converge within EIGEN_ITER_MAX sweeps per value returns None.

Source

pub fn fft(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Option<Self>

Radix-2 Cooley–Tukey DFT at (p, rm, cc).

A (1, n) or (n, 1) array is real. A (2, n) array is complex (row 0 real, row 1 imaginary). n must be a power of two and at most FFT_MAX_POINTS. Returns a (2, n) spectrum (unnormalized). Empty, non-finite, or a bad shape returns None.

Source

pub fn ifft(&self, p: usize, rm: RoundingMode, cc: &mut Consts) -> Option<Self>

Inverse radix-2 DFT at (p, rm, cc). Same layout as Self::fft. The result is divided by n (unitary inverse of the unnormalized DFT).

Trait Implementations§

Source§

impl Clone for ExactNumArray

Source§

fn clone(&self) -> ExactNumArray

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExactNumArray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.