Revision 113fef63c31d21304fe8336b4013dccb13aa88e6 authored by Andrew O. Finley on 08 March 2010, 00:00:00 UTC, committed by Gabor Csardi on 08 March 2010, 00:00:00 UTC
1 parent 6bf88ae
pPCovInvDet_wrap.cpp
#include <iostream>
#include <string>
using namespace std;
#include <R.h>
#include <Rinternals.h>
#include <R_ext/Linpack.h>
#include <R_ext/Lapack.h>
#include <R_ext/BLAS.h>
#include "util.h"
#include "covmodel.h"
#include "covInvDet.h"
extern "C" {
SEXP pPCovInvDet_wrap(SEXP knotsD_r, SEXP coordsKnotsD_r, SEXP C_r, SEXP C_str_r, SEXP ct_r,
SEXP n_r, SEXP m_r, SEXP tauSq_r, SEXP sigmaSq_r, SEXP theta_r, SEXP tmp_mm_r, SEXP tmp_nm_r,
SEXP covModel_r, SEXP brute){
int nPramPtr = 1;
string covModel = CHAR(STRING_ELT(covModel_r,0));
void (covmodel::*cov1ParamPtr)(double, double &, double &) = NULL;
void (covmodel::*cov2ParamPtr)(double, double, double &, double&) = NULL;
if(covModel == "exponential"){
cov1ParamPtr = &covmodel::exponential;
}else if(covModel == "spherical"){
cov1ParamPtr = &covmodel::spherical;
}else if(covModel == "gaussian"){
cov1ParamPtr = &covmodel::gaussian;
}else if(covModel == "matern"){
cov2ParamPtr = &covmodel::matern;
nPramPtr = 2;
}else{
error("c++ error: cov.model is not correctly specified");
}
//my covmodel object for calling cov function
covmodel *covModelObj = new covmodel;
SEXP logDet_r;
PROTECT(logDet_r = allocVector(REALSXP, 1));
REAL(logDet_r)[0] = pPCovInvDet(REAL(knotsD_r), REAL(coordsKnotsD_r), REAL(C_r), REAL(C_str_r), REAL(ct_r),
INTEGER(n_r)[0], INTEGER(m_r)[0], REAL(tauSq_r)[0], REAL(sigmaSq_r)[0], REAL(theta_r),
REAL(tmp_mm_r), REAL(tmp_nm_r),
covModel, nPramPtr, covModelObj, cov1ParamPtr, cov2ParamPtr, INTEGER(brute)[0]);
UNPROTECT(1);
return(logDet_r);
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...