Skip to content

Commit

Permalink
Reducing running time in examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroguarderas committed Jan 30, 2018
1 parent 65da3b9 commit ffdf092
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 102 deletions.
42 changes: 8 additions & 34 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ weight_pow_dist <- function(x, y, w, p) {
#' @param n Number of uniform division to compute the integral.
#' @return Vector with integrals while the x coordinate is fixed.
#' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
#' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
#' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
#' @export
vector_integrate_kernel <- function(Kern, x, a, b, n) {
.Call('_KRIG_vector_integrate_kernel', PACKAGE = 'KRIG', Kern, x, a, b, n)
Expand All @@ -57,7 +57,7 @@ vector_integrate_kernel <- function(Kern, x, a, b, n) {
#' @param n Number of uniform division to compute the integral.
#' @return Real value with the integral value.
#' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
#' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
#' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
#' @export
integrate_kernel <- function(Kern, a, b, n) {
.Call('_KRIG_integrate_kernel', PACKAGE = 'KRIG', Kern, a, b, n)
Expand All @@ -78,7 +78,7 @@ integrate_kernel <- function(Kern, a, b, n) {
#' be evaluated.
#' @return List with one coordinate integrals and complete kernel integrals.
#' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
#' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
#' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
#' @export
list_integrate_kernel <- function(Kernels, X) {
.Call('_KRIG_list_integrate_kernel', PACKAGE = 'KRIG', Kernels, X)
Expand All @@ -102,35 +102,10 @@ list_integrate_kernel <- function(Kernels, X) {
#' @return List with containing the Gamma 3D array where the different combination variance are
#' stocked and the total matrix variance named Kanova.
#' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
#' @examples
#' library( KRIG )
#' options( stringsAsFactors = FALSE )
#'
#' kernel_1<-function( x, y ) exp( -0.5*(x-y)^2)
#' kernel_2<-function( x, y ) exp( -0.7*(x-y)^2)
#' kernel_3<-function( x, y ) exp( -0.1*(x-y)^2)
#'
#' Kernels<-data.frame( kernel = c( 'kernel_1', 'kernel_2', 'kernel_3' ),
#' min = c( -1, -1, -5 ),
#' max = c( 1, 1, 5 ),
#' n = c( 500, 500, 500 ) )
#'
#' n<-20
#' X<-matrix( c( seq( -1, 1, length.out = n ),
#' seq( -1, 1, length.out = n ),
#' seq( -5, 5, length.out = n ) ), n, 3 )
#'
#' KI<-list_integrate_kernel( Kernels, X )
#' GK<-Kanova( Kernels, KI, X )
#'
#' f<-function( x ) x[1] + 30 * x[2] + 60 * x[3]
#' Func<-apply( X, 1, FUN = f )
#'
#' KF<-solve( GK$Kanova + diag( 1e-8, n, n ), Func )
#' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
#' @references
#' \insertRef{Kanova:2013}{KRIG}
#' \insertRef{Aronszajn:ThRK}{KRIG}
#'
#' @export
Kanova <- function(Kernels, Integral, X) {
.Call('_KRIG_Kanova', PACKAGE = 'KRIG', Kernels, Integral, X)
Expand Down Expand Up @@ -391,7 +366,6 @@ Krig <- function(Z, K, k, G, g, type = "ordinary", cinv = "syminv") {
#' @references
#' \insertRef{Kanova:2013}{KRIG}
#' \insertRef{Aronszajn:ThRK}{KRIG}
#'
#' @export
Krigidx <- function(KF, comb, X, Gamma) {
.Call('_KRIG_Krigidx', PACKAGE = 'KRIG', KF, comb, X, Gamma)
Expand All @@ -412,14 +386,14 @@ Krigidx <- function(KF, comb, X, Gamma) {
#' kernel_3<-function( x, y ) exp( -0.1*(x-y)^2)
#'
#' Kernels<-data.frame( kernel = c( 'kernel_1', 'kernel_2', 'kernel_3' ),
#' min = c( -1, -1, -5 ),
#' max = c( 1, 1, 5 ),
#' n = c( 500, 500, 500 ) )
#' min = c( -1, -1, -2 ),
#' max = c( 1, 1, 2 ),
#' n = c( 100, 100, 100 ) )
#'
#' n<-20
#' X<-matrix( c( seq( -1, 1, length.out = n ),
#' seq( -1, 1, length.out = n ),
#' seq( -5, 5, length.out = n ) ), n, 3 )
#' seq( -2, 2, length.out = n ) ), n, 3 )
#'
#' KI<-list_integrate_kernel( Kernels, X )
#' GK<-Kanova( Kernels, KI, X )
Expand Down
29 changes: 3 additions & 26 deletions man/Kanova.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/Krigvar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/integrate_kernel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/list_integrate_kernel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/vector_integrate_kernel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 5 additions & 30 deletions src/krig_integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace Rcpp;
//' @param n Number of uniform division to compute the integral.
//' @return Vector with integrals while the x coordinate is fixed.
//' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
//' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
//' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
//' @export
// [[Rcpp::export]]
arma::colvec vector_integrate_kernel( Function Kern, const arma::colvec x,
Expand All @@ -39,7 +39,7 @@ arma::colvec vector_integrate_kernel( Function Kern, const arma::colvec x,
//' @param n Number of uniform division to compute the integral.
//' @return Real value with the integral value.
//' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
//' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
//' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
//' @export
// [[Rcpp::export]]
double integrate_kernel( Function Kern, const double& a, const double& b, const double& n );
Expand All @@ -60,7 +60,7 @@ double integrate_kernel( Function Kern, const double& a, const double& b, const
//' be evaluated.
//' @return List with one coordinate integrals and complete kernel integrals.
//' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
//' @seealso For a complete application you can check the documentation of \code{\link{Kanova}}.
//' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
//' @export
// [[Rcpp::export]]
List list_integrate_kernel( const DataFrame& Kernels, const arma::mat& X );
Expand All @@ -84,37 +84,12 @@ List list_integrate_kernel( const DataFrame& Kernels, const arma::mat& X );
//' @return List with containing the Gamma 3D array where the different combination variance are
//' stocked and the total matrix variance named Kanova.
//' @author Pedro Guarderas \email{pedro.felipe.guarderas@@gmail.com}.
//' @examples
//' library( KRIG )
//' options( stringsAsFactors = FALSE )
//'
//' kernel_1<-function( x, y ) exp( -0.5*(x-y)^2)
//' kernel_2<-function( x, y ) exp( -0.7*(x-y)^2)
//' kernel_3<-function( x, y ) exp( -0.1*(x-y)^2)
//'
//' Kernels<-data.frame( kernel = c( 'kernel_1', 'kernel_2', 'kernel_3' ),
//' min = c( -1, -1, -5 ),
//' max = c( 1, 1, 5 ),
//' n = c( 500, 500, 500 ) )
//'
//' n<-20
//' X<-matrix( c( seq( -1, 1, length.out = n ),
//' seq( -1, 1, length.out = n ),
//' seq( -5, 5, length.out = n ) ), n, 3 )
//'
//' KI<-list_integrate_kernel( Kernels, X )
//' GK<-Kanova( Kernels, KI, X )
//'
//' f<-function( x ) x[1] + 30 * x[2] + 60 * x[3]
//' Func<-apply( X, 1, FUN = f )
//'
//' KF<-solve( GK$Kanova + diag( 1e-8, n, n ), Func )
//' @seealso For a complete application you can check the documentation of \code{\link{Krigvar}}.
//' @references
//' \insertRef{Kanova:2013}{KRIG}
//' \insertRef{Aronszajn:ThRK}{KRIG}
//'
//' @export
// [[Rcpp::export]]
List Kanova( const DataFrame& Kernels, const List& Integral, const arma::mat& X );

#endif
#endif
9 changes: 4 additions & 5 deletions src/krig_sensitivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ using namespace Rcpp;
//' @references
//' \insertRef{Kanova:2013}{KRIG}
//' \insertRef{Aronszajn:ThRK}{KRIG}
//'
//' @export
// [[Rcpp::export]]
double Krigidx( const arma::colvec KF,
Expand All @@ -46,14 +45,14 @@ double Krigidx( const arma::colvec KF,
//' kernel_3<-function( x, y ) exp( -0.1*(x-y)^2)
//'
//' Kernels<-data.frame( kernel = c( 'kernel_1', 'kernel_2', 'kernel_3' ),
//' min = c( -1, -1, -5 ),
//' max = c( 1, 1, 5 ),
//' n = c( 500, 500, 500 ) )
//' min = c( -1, -1, -2 ),
//' max = c( 1, 1, 2 ),
//' n = c( 100, 100, 100 ) )
//'
//' n<-20
//' X<-matrix( c( seq( -1, 1, length.out = n ),
//' seq( -1, 1, length.out = n ),
//' seq( -5, 5, length.out = n ) ), n, 3 )
//' seq( -2, 2, length.out = n ) ), n, 3 )
//'
//' KI<-list_integrate_kernel( Kernels, X )
//' GK<-Kanova( Kernels, KI, X )
Expand Down

0 comments on commit ffdf092

Please sign in to comment.