File: quadrature.nodes.weights.R

package info (click to toggle)
r-cran-spc 1%3A0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: ansic: 22,279; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
quadrature.nodes.weights <- function(n, type="GL", x1=-1, x2=1) {
  if ( n < 1 )			stop("n has to be a natural number")
  qtyp <- pmatch(type, c("GL", "Ra")) - 1
  if ( is.na(qtyp) )		stop("invalid quadrature type")
  if ( x1 >= x2 )		stop("x1 must be smaller than x2")
  
  nw <- .C("quadrature_nodes_weights",
           as.integer(n),
           as.double(x1), as.double(x2),
           as.integer(qtyp),
           ans=double(length=2*n), PACKAGE="spc")$ans
           
  qnw <- data.frame(nodes=nw[1:n], weights=nw[-(1:n)])         
  qnw
}