#######################################################################
#func.r
func <- function(x){
  floor(x)
}

useFunc <- function(f, x){
  print(f(x))
}
#######################################################################
func <- function(theta){
  theta*sin(4*pi*theta^2)
}

#ranGolden.r
ranGolden <- function(f, a, b, nSearch, seed){
  set.seed(seed)
  bounds <- matrix(runif(2*nSearch), 2, nSearch)
  minVec <- apply(bounds, MARGIN = 2,
    FUN = function(v){
      temp  = a + (b - a)*sort(v)
      optimize(f, lower = temp[1], upper =
               temp[2])[[2]]})
  location <- order(minVec)[1]
  temp  = a + (b - a)*sort(c(bounds[1, location],
    bounds[2, location]))
  optimize(f, lower = temp[1], upper = temp[2])
}
#######################################################################
#linssGCV.r
linss <- function(x, y){
    fit <- .C("linss", as.integer(length(x)), 0., as.double(x),
        as.double(y), vector("numeric", length(x)), 0.)
    list(fit[[5]], fit[[6]])
  }
#######################################################################
