Skip to main content

Module math

Module math 

Source

EnumsΒ§

MathError
Structured error type for math/linear algebra operations.

StaticsΒ§

__BUILTIN_REG_BUILTIN_ABS πŸ”’
__BUILTIN_REG_BUILTIN_ACOS πŸ”’
__BUILTIN_REG_BUILTIN_ACOSH πŸ”’
__BUILTIN_REG_BUILTIN_APPEND πŸ”’
__BUILTIN_REG_BUILTIN_ARG πŸ”’
__BUILTIN_REG_BUILTIN_ARRAY_IND πŸ”’
__BUILTIN_REG_BUILTIN_ASIN πŸ”’
__BUILTIN_REG_BUILTIN_ASINH πŸ”’
__BUILTIN_REG_BUILTIN_AS_COMPLEX πŸ”’
__BUILTIN_REG_BUILTIN_ATAN πŸ”’
__BUILTIN_REG_BUILTIN_ATAN2 πŸ”’
__BUILTIN_REG_BUILTIN_ATANH πŸ”’
__BUILTIN_REG_BUILTIN_BESSEL_J πŸ”’
__BUILTIN_REG_BUILTIN_BESSEL_Y πŸ”’
__BUILTIN_REG_BUILTIN_BETA πŸ”’
__BUILTIN_REG_BUILTIN_BITW_AND πŸ”’
__BUILTIN_REG_BUILTIN_BITW_NOT πŸ”’
__BUILTIN_REG_BUILTIN_BITW_OR πŸ”’
__BUILTIN_REG_BUILTIN_BITW_SHIFT_L πŸ”’
__BUILTIN_REG_BUILTIN_BITW_SHIFT_R πŸ”’
__BUILTIN_REG_BUILTIN_BITW_XOR πŸ”’
__BUILTIN_REG_BUILTIN_CBRT πŸ”’
__BUILTIN_REG_BUILTIN_CEILING πŸ”’
__BUILTIN_REG_BUILTIN_CHOL πŸ”’
__BUILTIN_REG_BUILTIN_CHOOSE πŸ”’
__BUILTIN_REG_BUILTIN_COEF πŸ”’
__BUILTIN_REG_BUILTIN_COL πŸ”’
__BUILTIN_REG_BUILTIN_COL_MEANS πŸ”’
__BUILTIN_REG_BUILTIN_COL_SUMS πŸ”’
__BUILTIN_REG_BUILTIN_COMBN πŸ”’
__BUILTIN_REG_BUILTIN_COMPLEX πŸ”’
__BUILTIN_REG_BUILTIN_CONJ πŸ”’
__BUILTIN_REG_BUILTIN_COS πŸ”’
__BUILTIN_REG_BUILTIN_COSH πŸ”’
__BUILTIN_REG_BUILTIN_CROSSPROD πŸ”’
__BUILTIN_REG_BUILTIN_CUMALL πŸ”’
__BUILTIN_REG_BUILTIN_CUMANY πŸ”’
__BUILTIN_REG_BUILTIN_CUMMAX πŸ”’
__BUILTIN_REG_BUILTIN_CUMMIN πŸ”’
__BUILTIN_REG_BUILTIN_CUMPROD πŸ”’
__BUILTIN_REG_BUILTIN_CUMSUM πŸ”’
__BUILTIN_REG_BUILTIN_DET πŸ”’
__BUILTIN_REG_BUILTIN_DIAG πŸ”’
__BUILTIN_REG_BUILTIN_DIFF πŸ”’
__BUILTIN_REG_BUILTIN_DIGAMMA πŸ”’
__BUILTIN_REG_BUILTIN_DROPLEVELS πŸ”’
__BUILTIN_REG_BUILTIN_EIGEN πŸ”’
__BUILTIN_REG_BUILTIN_EXP πŸ”’
__BUILTIN_REG_BUILTIN_EXPM1 πŸ”’
__BUILTIN_REG_BUILTIN_FACTORIAL πŸ”’
__BUILTIN_REG_BUILTIN_FLOOR πŸ”’
__BUILTIN_REG_BUILTIN_GAMMA πŸ”’
__BUILTIN_REG_BUILTIN_HEAD πŸ”’
__BUILTIN_REG_BUILTIN_HYPOT πŸ”’
__BUILTIN_REG_BUILTIN_IM πŸ”’
__BUILTIN_REG_BUILTIN_IS_COMPLEX πŸ”’
__BUILTIN_REG_BUILTIN_KRONECKER πŸ”’
__BUILTIN_REG_BUILTIN_LBETA πŸ”’
__BUILTIN_REG_BUILTIN_LGAMMA πŸ”’
__BUILTIN_REG_BUILTIN_LOG πŸ”’
__BUILTIN_REG_BUILTIN_LOG2 πŸ”’
__BUILTIN_REG_BUILTIN_LOG1P πŸ”’
__BUILTIN_REG_BUILTIN_LOG10 πŸ”’
__BUILTIN_REG_BUILTIN_LOWER_TRI πŸ”’
__BUILTIN_REG_BUILTIN_MAX πŸ”’
__BUILTIN_REG_BUILTIN_MEAN πŸ”’
__BUILTIN_REG_BUILTIN_MEDIAN πŸ”’
__BUILTIN_REG_BUILTIN_MIN πŸ”’
__BUILTIN_REG_BUILTIN_MOD_COMPLEX πŸ”’
__BUILTIN_REG_BUILTIN_NORM πŸ”’
__BUILTIN_REG_BUILTIN_ORDER πŸ”’
__BUILTIN_REG_BUILTIN_PMAX πŸ”’
__BUILTIN_REG_BUILTIN_PMIN πŸ”’
__BUILTIN_REG_BUILTIN_PROD πŸ”’
__BUILTIN_REG_BUILTIN_QR πŸ”’
__BUILTIN_REG_BUILTIN_QUANTILE πŸ”’
__BUILTIN_REG_BUILTIN_RANGE πŸ”’
__BUILTIN_REG_BUILTIN_RANK πŸ”’
__BUILTIN_REG_BUILTIN_RE πŸ”’
__BUILTIN_REG_BUILTIN_REP πŸ”’
__BUILTIN_REG_BUILTIN_REP_INT πŸ”’
__BUILTIN_REG_BUILTIN_REP_LEN πŸ”’
__BUILTIN_REG_BUILTIN_REV πŸ”’
__BUILTIN_REG_BUILTIN_ROUND πŸ”’
__BUILTIN_REG_BUILTIN_ROW πŸ”’
__BUILTIN_REG_BUILTIN_ROW_MEANS πŸ”’
__BUILTIN_REG_BUILTIN_ROW_SUMS πŸ”’
__BUILTIN_REG_BUILTIN_SD πŸ”’
__BUILTIN_REG_BUILTIN_SEQ πŸ”’
__BUILTIN_REG_BUILTIN_SEQ_ALONG πŸ”’
__BUILTIN_REG_BUILTIN_SEQ_LEN πŸ”’
__BUILTIN_REG_BUILTIN_SIGN πŸ”’
__BUILTIN_REG_BUILTIN_SIGNIF πŸ”’
__BUILTIN_REG_BUILTIN_SIN πŸ”’
__BUILTIN_REG_BUILTIN_SINH πŸ”’
__BUILTIN_REG_BUILTIN_SLICE_INDEX πŸ”’
__BUILTIN_REG_BUILTIN_SOLVE πŸ”’
__BUILTIN_REG_BUILTIN_SORT πŸ”’
__BUILTIN_REG_BUILTIN_SORT_UNIQUE πŸ”’
__BUILTIN_REG_BUILTIN_SQRT πŸ”’
__BUILTIN_REG_BUILTIN_SUM πŸ”’
__BUILTIN_REG_BUILTIN_SVD πŸ”’
__BUILTIN_REG_BUILTIN_SWEEP πŸ”’
__BUILTIN_REG_BUILTIN_T πŸ”’
__BUILTIN_REG_BUILTIN_TAIL πŸ”’
__BUILTIN_REG_BUILTIN_TAN πŸ”’
__BUILTIN_REG_BUILTIN_TANH πŸ”’
__BUILTIN_REG_BUILTIN_TCROSSPROD πŸ”’
__BUILTIN_REG_BUILTIN_TRIGAMMA πŸ”’
__BUILTIN_REG_BUILTIN_TRUNC πŸ”’
__BUILTIN_REG_BUILTIN_UNIQUE πŸ”’
__BUILTIN_REG_BUILTIN_UPPER_TRI πŸ”’
__BUILTIN_REG_BUILTIN_VAR πŸ”’
__BUILTIN_REG_BUILTIN_WHICH πŸ”’
__BUILTIN_REG_BUILTIN_WHICH_MAX πŸ”’
__BUILTIN_REG_BUILTIN_WHICH_MIN πŸ”’
__INTERP_REG_INTERP_LM πŸ”’
__INTERP_REG_INTERP_SUMMARY_LM πŸ”’

FunctionsΒ§

apply_length_out_cloneable πŸ”’
Truncate or cycle-extend a Vec<T: Clone> to the requested length.out.
array2_to_rvalue πŸ”’
Convert an ndarray Array2 back to an RValue matrix
bitwise_binary_op πŸ”’
bitwise_binary_op_fallible πŸ”’
builtin_abs πŸ”’
Absolute value.
builtin_acos πŸ”’
Inverse cosine (arc cosine).
builtin_acosh πŸ”’
Inverse hyperbolic cosine.
builtin_append πŸ”’
Append elements to a vector.
builtin_arg πŸ”’
Argument (phase angle) of complex numbers, in radians.
builtin_array_ind πŸ”’
Convert linear indices to array (row, col) subscripts.
builtin_as_complex πŸ”’
Coerce to complex type.
builtin_asin πŸ”’
Inverse sine (arc sine).
builtin_asinh πŸ”’
Inverse hyperbolic sine.
builtin_atan πŸ”’
Inverse tangent (arc tangent).
builtin_atan2 πŸ”’
Two-argument inverse tangent.
builtin_atanh πŸ”’
Inverse hyperbolic tangent.
builtin_bessel_j πŸ”’
Bessel function of the first kind, J_nu(x).
builtin_bessel_y πŸ”’
Bessel function of the second kind, Y_nu(x).
builtin_beta πŸ”’
Beta function: gamma(a) * gamma(b) / gamma(a + b).
builtin_bitw_and πŸ”’
Bitwise AND.
builtin_bitw_not πŸ”’
Bitwise NOT (ones’ complement).
builtin_bitw_or πŸ”’
Bitwise OR.
builtin_bitw_shift_l πŸ”’
Bitwise left shift.
builtin_bitw_shift_r πŸ”’
Bitwise right shift.
builtin_bitw_xor πŸ”’
Bitwise XOR.
builtin_cbrt πŸ”’
Cube root.
builtin_ceiling πŸ”’
Ceiling (smallest integer not less than x).
builtin_chol πŸ”’
chol(x) β€” Cholesky decomposition (upper triangular R such that x = R’R).
builtin_choose πŸ”’
Binomial coefficient: choose(n, k) = n! / (k! * (n - k)!).
builtin_coef πŸ”’
Extract coefficients from a model object.
builtin_col πŸ”’
Return a matrix of column indices (same dim as input, each element = its column number).
builtin_col_means πŸ”’
Mean of each column of a matrix or data frame.
builtin_col_sums πŸ”’
Sum of each column of a matrix or data frame.
builtin_combn πŸ”’
All combinations of n elements taken k at a time.
builtin_complex πŸ”’
Construct complex numbers from real and imaginary parts.
builtin_conj πŸ”’
Complex conjugate.
builtin_cos πŸ”’
Cosine (in radians).
builtin_cosh πŸ”’
Hyperbolic cosine.
builtin_crossprod πŸ”’
crossprod(x, y) = t(x) %*% y
builtin_cumall πŸ”’
Cumulative all: TRUE while all preceding elements are TRUE.
builtin_cumany πŸ”’
Cumulative any: TRUE once any preceding element is TRUE.
builtin_cummax πŸ”’
Cumulative maximum.
builtin_cummin πŸ”’
Cumulative minimum.
builtin_cumprod πŸ”’
Cumulative product.
builtin_cumsum πŸ”’
Cumulative sum.
builtin_det πŸ”’
det(x) β€” matrix determinant via LU decomposition.
builtin_diag πŸ”’
Diagonal of a matrix, or construct a diagonal matrix.
builtin_diff πŸ”’
Lagged differences.
builtin_digamma πŸ”’
Digamma function (psi function): the logarithmic derivative of the gamma function.
builtin_droplevels πŸ”’
Drop unused factor levels.
builtin_eigen πŸ”’
eigen(x) β€” Eigenvalue decomposition via nalgebra.
builtin_exp πŸ”’
Exponential function (e^x).
builtin_expm1 πŸ”’
Numerically stable exp(x) - 1.
builtin_factorial πŸ”’
Factorial: n! = 1 * 2 * … * n.
builtin_floor πŸ”’
Floor (largest integer not greater than x).
builtin_gamma πŸ”’
Gamma function.
builtin_head πŸ”’
Return the first n elements of a vector.
builtin_hypot πŸ”’
Euclidean distance: sqrt(x^2 + y^2) without overflow.
builtin_im πŸ”’
Extract the imaginary part of complex numbers.
builtin_is_complex πŸ”’
Test if an object is of complex type.
builtin_kronecker πŸ”’
Kronecker product of two matrices (or vectors treated as single-column matrices).
builtin_lbeta πŸ”’
Natural logarithm of the beta function.
builtin_lgamma πŸ”’
Natural logarithm of the absolute value of the gamma function.
builtin_log πŸ”’
Logarithm. With one argument, computes the natural log. With a second positional argument or named base argument, computes log in that base via the change-of-base formula: log(x, base) = ln(x) / ln(base).
builtin_log2 πŸ”’
Base-2 logarithm.
builtin_log1p πŸ”’
Numerically stable log(1 + x).
builtin_log10 πŸ”’
Base-10 logarithm.
builtin_lower_tri πŸ”’
Lower triangle of a matrix.
builtin_max πŸ”’
Maximum value across all arguments.
builtin_mean πŸ”’
Arithmetic mean.
builtin_median πŸ”’
Median value.
builtin_min πŸ”’
Minimum value across all arguments.
builtin_mod_complex πŸ”’
Modulus (absolute value) of complex numbers.
builtin_norm πŸ”’
norm(x, type = "O") β€” matrix/vector norm.
builtin_order πŸ”’
Permutation which rearranges a vector into ascending order.
builtin_pmax πŸ”’
Parallel (element-wise) maximum across vectors.
builtin_pmin πŸ”’
Parallel (element-wise) minimum across vectors.
builtin_prod πŸ”’
Product of all elements.
builtin_qr πŸ”’
qr(x) β€” QR decomposition via nalgebra’s column-pivoted QR.
builtin_quantile πŸ”’
Sample quantiles.
builtin_range πŸ”’
Range (minimum and maximum) of all values.
builtin_rank πŸ”’
Return the ranks of values in a numeric vector.
builtin_re πŸ”’
Extract the real part of complex numbers.
builtin_rep πŸ”’
Replicate elements of a vector.
builtin_rep_int πŸ”’
Replicate elements a specified number of times.
builtin_rep_len πŸ”’
Replicate elements to a specified length.
builtin_rev πŸ”’
Reverse a vector.
builtin_round πŸ”’
Round to the specified number of decimal places using IEEE 754 round-half-to-even (banker’s rounding): when the fractional part is exactly 0.5, round to the nearest even number.
builtin_row πŸ”’
Return a matrix of row indices (same dim as input, each element = its row number).
builtin_row_means πŸ”’
Mean of each row of a matrix or data frame.
builtin_row_sums πŸ”’
Sum of each row of a matrix or data frame.
builtin_sd πŸ”’
Sample standard deviation (square root of var).
builtin_seq πŸ”’
Generate a regular sequence.
builtin_seq_along πŸ”’
Generate 1:length(along.with) as an integer vector.
builtin_seq_len πŸ”’
Generate 1:n as an integer vector.
builtin_sign πŸ”’
Sign of each element (-1, 0, or 1).
builtin_signif πŸ”’
Round to the specified number of significant digits.
builtin_sin πŸ”’
Sine (in radians).
builtin_sinh πŸ”’
Hyperbolic sine.
builtin_slice_index πŸ”’
Return an array of indices along a specified margin.
builtin_solve πŸ”’
solve(a, b) β€” solve linear system or compute matrix inverse via LU decomposition.
builtin_sort πŸ”’
Sort a vector.
builtin_sort_unique πŸ”’
miniR extension: single-pass sorted unique using BTreeSet. Faster than sort(unique(x)) for large vectors.
builtin_sqrt πŸ”’
Square root.
builtin_sum πŸ”’
Sum of all elements.
builtin_svd πŸ”’
svd(x) β€” Singular Value Decomposition via nalgebra’s bidiagonal SVD.
builtin_sweep πŸ”’
Sweep a summary statistic from each row or column of a matrix.
builtin_t πŸ”’
t(x) β€” matrix transpose.
builtin_tail πŸ”’
Return the last n elements of a vector.
builtin_tan πŸ”’
Tangent (in radians).
builtin_tanh πŸ”’
Hyperbolic tangent.
builtin_tcrossprod πŸ”’
tcrossprod(x, y) = x %*% t(y)
builtin_trigamma πŸ”’
Trigamma function: the derivative of the digamma function.
builtin_trunc πŸ”’
Truncation (round toward zero).
builtin_unique πŸ”’
Remove duplicate elements, preserving first occurrence order.
builtin_upper_tri πŸ”’
Upper triangle of a matrix.
builtin_var πŸ”’
Sample variance (Bessel-corrected, divides by n-1).
builtin_which πŸ”’
Indices of TRUE elements.
builtin_which_max πŸ”’
Index of the maximum element.
builtin_which_min πŸ”’
Index of the minimum element.
collect_additive_terms πŸ”’
Recursively collect symbol names from additive terms (x1 + x2 + x3).
df_column_doubles πŸ”’
Extract a named column from a data frame (RList) as a Vec<Option>.
digamma_f64 πŸ”’
Compute digamma(x) using asymptotic expansion and recurrence.
dmatrix_to_rvalue πŸ”’
Convert a nalgebra DMatrix back to an RValue matrix.
eval_kronecker
Evaluate the %x% (Kronecker product) operator.
eval_kronecker_with_fn πŸ”’
interp_lm πŸ”’
Fit a linear model using ordinary least squares.
interp_summary_lm πŸ”’
Print a summary of a linear model.
kronecker_dims_and_data πŸ”’
Extract matrix dimensions from a value, treating plain vectors as column vectors.
math_binary πŸ”’
Helper for binary math builtins: applies (f64, f64) -> f64 element-wise with recycling.
matrix_dimnames πŸ”’
matrix_dims πŸ”’
Helper: extract matrix dimensions (nrow, ncol) from any matrix-like object.
matrix_dims_and_data πŸ”’
Helper: extract matrix dimensions and data as doubles.
parallel_minmax πŸ”’
parse_formula_terms πŸ”’
Extract the response and predictor names from a formula expression.
partition_na_doubles πŸ”’
Separate non-NA f64 values from NA count.
partition_na_options πŸ”’
Separate non-NA Option values from NA count for Clone types.
reassemble_with_na πŸ”’
Reassemble sorted non-NA values with NAs placed according to na_last.
rep_each_then_times πŸ”’
Repeat each element each times, then repeat the whole result times times.
rep_each_then_times_copy πŸ”’
Same as rep_each_then_times but for Copy types (Raw/u8).
rep_vector πŸ”’
Helper: replicate a vector with each, times, and optional length.out.
round_half_to_even πŸ”’
IEEE 754 round-half-to-even: if the fractional part is exactly 0.5, round to the nearest even integer. Otherwise round normally.
rvalue_to_array2 πŸ”’
Convert an RValue to an ndarray Array2 (column-major)
rvalue_to_dmatrix πŸ”’
Convert an RValue matrix to a nalgebra DMatrix (column-major β€” zero-copy reorder).
set_matrix_attrs πŸ”’
solve_linear_system πŸ”’
Solve a linear system A * x = b using Gaussian elimination with partial pivoting. A must be square (ncol x ncol), b must have length ncol.
tri_matrix πŸ”’
trigamma_f64 πŸ”’
Compute trigamma(x) using asymptotic expansion and recurrence.

Type AliasesΒ§

DimNameVec πŸ”’
MatrixDimNames πŸ”’