R/RcppExports.R

Defines functions pinv_cpp invert_general_cpp invert_spd_cpp compute_sufficient_stats_cpp cevcmm_rcpp_check

Documented in cevcmm_rcpp_check

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Verify the Rcpp / RcppArmadillo toolchain is wired up
#'
#' Internal stub used by Day 15's profiling script to confirm
#' the C++ compiler, Rcpp dispatch, and Armadillo linking all work
#' before the real ports on Days 16-18. Performs a trivial 3x3
#' identity-matrix trace to exercise the linker.
#'
#' @return A character string of the form
#'   "OK (Armadillo X.Y.Z; trace(I_3) = 3)".
#'
#' @keywords internal
#' @export
cevcmm_rcpp_check <- function() {
    .Call(`_cevcmm_cevcmm_rcpp_check`)
}

#' Sufficient-statistics core in C++
#'
#' Internal RcppArmadillo implementation of the six cross-products
#' that make up a VCMM per-node summary. Called by
#' \code{compute_sufficient_stats()} when \code{use_cpp = TRUE}
#' (the default since Day 16).
#'
#' @param y Numeric vector, length n.
#' @param X Numeric matrix, n by p.
#' @param Z Numeric matrix, n by q.
#' @return A plain \code{list} (no class) with elements
#'   \code{a, b, C, ZtZ, Zty, XtZ, n_obs}.
#' @keywords internal
#' @noRd
compute_sufficient_stats_cpp <- function(y, X, Z) {
    .Call(`_cevcmm_compute_sufficient_stats_cpp`, y, X, Z)
}

#' Cholesky-based inverse for symmetric positive-definite matrices
#'
#' Internal RcppArmadillo backend for the fast path of
#' \code{\link{invert_matrix}}. Uses LAPACK \code{dpotrf} + \code{dpotri}.
#'
#' Throws an R error if \code{A} is not symmetric positive-definite; the
#' R wrapper catches this and falls back to \code{invert_general_cpp}.
#'
#' @param A Symmetric positive-definite square matrix.
#' @return Inverse of A.
#' @keywords internal
#' @noRd
invert_spd_cpp <- function(A) {
    .Call(`_cevcmm_invert_spd_cpp`, A)
}

#' General matrix inverse via LU factorisation
#'
#' Internal RcppArmadillo backend used as a fallback by
#' \code{\link{invert_matrix}} when Cholesky fails. Uses LAPACK
#' \code{dgetrf} + \code{dgetri}.
#'
#' @param A Square invertible matrix.
#' @return Inverse of A.
#' @keywords internal
#' @noRd
invert_general_cpp <- function(A) {
    .Call(`_cevcmm_invert_general_cpp`, A)
}

#' SVD-based Moore-Penrose pseudo-inverse
#'
#' Internal RcppArmadillo backend used as the final fallback by
#' \code{\link{invert_matrix}}. Uses LAPACK \code{dgesvd} via
#' \code{arma::pinv}.
#'
#' @param A Numeric matrix.
#' @param tol Tolerance below which singular values are treated as zero.
#'   If \code{<= 0}, use Armadillo's default
#'   (\code{max(dim(A)) * eps_machine * max(svd(A))}).
#' @return Moore-Penrose pseudo-inverse of A.
#' @keywords internal
#' @noRd
pinv_cpp <- function(A, tol = -1.0) {
    .Call(`_cevcmm_pinv_cpp`, A, tol)
}

Try the cevcmm package in your browser

Any scripts or data that you put into this service are public.

cevcmm documentation built on July 24, 2026, 5:07 p.m.