A collection of efficient C++ functions using RcppArmadillo for common matrix operations, including solving linear systems, computing matrix inverses, approximating normal CDFs, and fast elementwise transformations.
Value
solve1()
: A numeric matrix, the inverse ofx
.solve2()
: A numeric matrix, the solution toA * X = B
.solve2vect()
: A numeric vector, the solution toA * x = B
.fast_pnorm()
: A numeric vector, CDF values approximated for standard normal distribution.exp_neg_div()
: A numeric matrix, elementwise exponential of-A/x
.
Examples
# -----------------------------------------
# Example for solve1
# -----------------------------------------
N <- 100
set.seed(1000)
Matrix <- matrix(rnorm(N * N), N, N)
all.equal(solve(Matrix), IASDT.R::solve1(Matrix))
#> [1] TRUE
# -----------------------------------------
# Example for solve2
# -----------------------------------------
N <- 100
set.seed(1000)
A <- matrix(rnorm(N * N), N, N)
set.seed(2000)
B <- matrix(rnorm(N * N), N, N)
all.equal(solve(A, B), IASDT.R::solve2(A, B))
#> [1] TRUE
set.seed(2000)
B <- matrix(rnorm(N), N, 1)
all.equal(solve(A, B), IASDT.R::solve2(A, B))
#> [1] TRUE
# -----------------------------------------
# Example for solve2vect
# -----------------------------------------
N <- 100
set.seed(1000)
A <- matrix(rnorm(N * N), N, N)
set.seed(2000)
B <- rnorm(N)
all.equal(solve(A, B), as.vector(IASDT.R::solve2vect(A, B)))
#> [1] TRUE
# -----------------------------------------
# Example for fast_pnorm
# -----------------------------------------
set.seed(1000)
A <- rnorm(100)
all.equal(pnorm(A), IASDT.R::fast_pnorm(A))
#> [1] TRUE
# -----------------------------------------
# Example for exp_neg_div
# -----------------------------------------
N <- 1000
set.seed(1000)
A <- matrix(rnorm(N * N), N, N)
set.seed(2000)
x <- rnorm(1)
all.equal(exp(-A / x), IASDT.R::exp_neg_div(A, x))
#> [1] TRUE