R/Monomial.R

Defines functions polyCalc vanderMat

Documented in polyCalc vanderMat

# Copyright Avraham Adler (c) 2024
# SPDX-License-Identifier: MPL-2.0+

# Create Vandermonde matrix to a polynomial degree n, or n + 1 terms.
vanderMat <- function(x, n) {
  np1 <- n + 1L
  matrix(rep(x, each = np1) ^ (seq_len(np1) - 1L), ncol = np1, byrow = TRUE)
}

# polyCalc uses a Compensated Horner Method based on Langlois et al.(2006)
# https://drops.dagstuhl.de/opus/volltexte/2006/442/
# As primary bottleneck, it was ported to C for speed.
polyCalc <- function(x, a) {
  .Call(compHorner_c, as.double(x), as.double(a))
}

Try the minimaxApprox package in your browser

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

minimaxApprox documentation built on June 22, 2024, 10:13 a.m.