[Rcpp-commits] r1224 - pkg/RcppGSL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 13 14:15:48 CEST 2010
Author: edd
Date: 2010-05-13 14:15:48 +0200 (Thu, 13 May 2010)
New Revision: 1224
Modified:
pkg/RcppGSL/src/fastLm.cpp
Log:
still borked
Modified: pkg/RcppGSL/src/fastLm.cpp
===================================================================
--- pkg/RcppGSL/src/fastLm.cpp 2010-05-13 12:10:00 UTC (rev 1223)
+++ pkg/RcppGSL/src/fastLm.cpp 2010-05-13 12:15:48 UTC (rev 1224)
@@ -26,32 +26,38 @@
extern "C" SEXP fastLm(SEXP ys, SEXP Xs) {
- Rcpp::NumericVector Yr(ys); // creates Rcpp vector from SEXP
- Rcpp::NumericMatrix Xr(Xs); // creates Rcpp matrix from SEXP
+ RcppGSL::vector<double> y(ys); // creates RcppGSL vector from SEXP
+ RcppGSL::matrix<double> X(Xs); // creates RcppGSL matrix from SEXP
- int i,j,n = Xr.nrow(), k = Xr.ncol();
+ //Rcpp::NumericVector Yr(ys);
+ //Rcpp::NumericMatrix Xr(Xs); // creates Rcpp matrix from SEXP
+
+ //int i, j, n = Xr.nrow(), k = Xr.ncol();
+ int i, j, n=4,k=2; // FIXME -- need coef extraction
double chisq;
- gsl_matrix *X = gsl_matrix_alloc (n, k);
- gsl_vector *y = gsl_vector_alloc (n);
- gsl_vector *c = gsl_vector_alloc (k);
+ //gsl_matrix *X = gsl_matrix_alloc (n, k);
+ //gsl_vector *y = gsl_vector_alloc (n);
+ gsl_vector *c = gsl_vector_alloc (k); // FIXME trivial ctor
gsl_matrix *cov = gsl_matrix_alloc (k, k);
- for (i = 0; i < n; i++) {
- for (j = 0; j < k; j++)
- gsl_matrix_set (X, i, j, Xr(i,j));
- gsl_vector_set (y, i, Yr(i));
- }
+ //for (i = 0; i < n; i++) {
+ // for (j = 0; j < k; j++)
+ // gsl_matrix_set (X, i, j, Xr(i,j));
+ // gsl_vector_set (y, i, Yr(i));
+ //}
gsl_multifit_linear_workspace *work = gsl_multifit_linear_alloc (n, k);
gsl_multifit_linear (X, y, c, cov, &chisq, work);
gsl_multifit_linear_free (work);
+ // FIXME need free()
- //Rcpp::NumericVector coefr = Rcpp::wrap(c);
- RcppGSL::vector<double> coefr(5);
- RcppGSL::vector<double> vec(ys);
- //return Rcpp::List::create( Rcpp::Named( "coef", coefr),
- // Rcpp::Named( "stderr", coefr));
+ //Rcpp::NumericVector coefr = Rcpp::wrap(c);
+ //RcppGSL::vector<double> coefr(5);
+ return Rcpp::List::create( Rcpp::Named( "coef", c),
+ Rcpp::Named( "stderr", c));
+ //return Rcpp::List::create( Rcpp::_["coef"] = c,
+ // Rcpp::_["stderr"], c);
return Xs;
}
More information about the Rcpp-commits
mailing list