[Lme4-commits] r1643 - pkg/lme4Eigen/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 10 21:25:38 CET 2012
Author: dmbates
Date: 2012-03-10 21:25:38 +0100 (Sat, 10 Mar 2012)
New Revision: 1643
Modified:
pkg/lme4Eigen/src/predModule.cpp
pkg/lme4Eigen/src/predModule.h
Log:
Updates for changed identifier names in RcppEigen-0.2.0
Modified: pkg/lme4Eigen/src/predModule.cpp
===================================================================
--- pkg/lme4Eigen/src/predModule.cpp 2012-03-06 22:23:52 UTC (rev 1642)
+++ pkg/lme4Eigen/src/predModule.cpp 2012-03-10 20:25:38 UTC (rev 1643)
@@ -66,7 +66,7 @@
// This complicated code bypasses problems caused by Eigen's
// sparse/sparse matrix multiplication pruning zeros. The
// Cholesky decomposition croaks if the structure of d_LamtUt changes.
- MVec(d_LamtUt._valuePtr(), d_LamtUt.nonZeros()).setZero();
+ MVec(d_LamtUt.valuePtr(), d_LamtUt.nonZeros()).setZero();
for (Index j = 0; j < d_Ut.outerSize(); ++j) {
for(MSpMatrixd::InnerIterator rhsIt(d_Ut, j); rhsIt; ++rhsIt) {
Scalar y(rhsIt.value());
@@ -132,15 +132,15 @@
// for a SparseMatrix<double>, not a MappedSparseMatrix<double>.
SpMatrixd m(d_LamtUt.rows(), d_LamtUt.cols());
m.resizeNonZeros(d_LamtUt.nonZeros());
- std::copy(d_LamtUt._valuePtr(),
- d_LamtUt._valuePtr() + d_LamtUt.nonZeros(),
- m._valuePtr());
- std::copy(d_LamtUt._innerIndexPtr(),
- d_LamtUt._innerIndexPtr() + d_LamtUt.nonZeros(),
- m._innerIndexPtr());
- std::copy(d_LamtUt._outerIndexPtr(),
- d_LamtUt._outerIndexPtr() + d_LamtUt.cols() + 1,
- m._outerIndexPtr());
+ std::copy(d_LamtUt.valuePtr(),
+ d_LamtUt.valuePtr() + d_LamtUt.nonZeros(),
+ m.valuePtr());
+ std::copy(d_LamtUt.innerIndexPtr(),
+ d_LamtUt.innerIndexPtr() + d_LamtUt.nonZeros(),
+ m.innerIndexPtr());
+ std::copy(d_LamtUt.outerIndexPtr(),
+ d_LamtUt.outerIndexPtr() + d_LamtUt.cols() + 1,
+ m.outerIndexPtr());
d_L.factorize_p(m, Eigen::ArrayXi(), 1.);
d_ldL2 = ::M_chm_factor_ldetL2(d_L.factor());
}
@@ -152,7 +152,7 @@
std::copy(theta.data(), theta.data() + theta.size(), d_theta.data());
// update Lambdat
int *lipt = d_Lind.data();
- double *LamX = d_Lambdat._valuePtr(), *thpt = d_theta.data();
+ double *LamX = d_Lambdat.valuePtr(), *thpt = d_theta.data();
for (int i = 0; i < d_Lind.size(); ++i) {
LamX[i] = thpt[lipt[i] - 1];
}
@@ -210,7 +210,7 @@
throw std::runtime_error("Size mismatch in updateXwts");
// More complex code to handle the pruning of zeros
- MVec(d_Ut._valuePtr(), d_Ut.nonZeros()).setZero();
+ MVec(d_Ut.valuePtr(), d_Ut.nonZeros()).setZero();
for (int j = 0; j < d_Ut.outerSize(); ++j) {
MSpMatrixd::InnerIterator lhsIt(d_Ut, j);
for (SpMatrixd::InnerIterator rhsIt(Ut, j); rhsIt; ++rhsIt, ++lhsIt) {
@@ -228,7 +228,7 @@
void merPredD::updateDecomp() { // update L, RZX and RX
updateL();
- d_RZX = d_LamtUt * d_V;
+ d_RZX = d_LamtUt * d_V;
if (d_p > 0) {
d_L.solveInPlace(d_RZX, CHOLMOD_P);
d_L.solveInPlace(d_RZX, CHOLMOD_L);
Modified: pkg/lme4Eigen/src/predModule.h
===================================================================
--- pkg/lme4Eigen/src/predModule.h 2012-03-06 22:23:52 UTC (rev 1642)
+++ pkg/lme4Eigen/src/predModule.h 2012-03-10 20:25:38 UTC (rev 1643)
@@ -12,93 +12,7 @@
#include <RcppEigen.h>
namespace lme4Eigen {
-#if 0
- class dgCMatrix : public SparseMatrix<double> { // sparse Matrix, copies contents of R object
- public:
- dgCMatrix(const S4& xp)
- : SparseMatrix<double>(as<SparseMatrix<double> >(xp)) {}
- double* xPt() {return _valuePtr();}
- VectorXd diag() const {
- VectorXd ans(outerSize());
- for (int j = 0; j < outerSize(); ++j) {
- SparseMatrix<double>::InnerIterator it(*this, j);
- if (it.index() != j) // because *this is ColMajor and Lower
- throw runtime_error("first element of column in lower is not a diagonal");
- ans[j] = it.value();
- }
- return ans;
- }
- };
-
- class modelMatrix {
- protected:
- const IntegerVector d_assign;
- const List d_contrasts;
- public:
- modelMatrix(const S4& xp)
- : d_assign( xp.slot("assign")),
- d_contrasts(xp.slot("contrasts")) {}
-
- const IntegerVector &assign() const {return d_assign;}
- const List &contrasts() const {return d_contrasts;}
- };
-
- class ddenseModelMatrix : public Map<MatrixXd>, public modelMatrix {
- protected:
- S4 d_xp;
- public:
- typedef MatrixXd MatrixType;
- ddenseModelMatrix(const S4& xp)
- : Map<MatrixXd>(NumericVector(xp.slot("x")).begin(),
- ::Rf_asInteger(xp.slot("Dim")),
- IntegerVector(xp.slot("Dim"))[1]),
- modelMatrix(xp), d_xp(xp) {}
- };
-
- class dsparseModelMatrix : public MappedSparseMatrix<double>, public modelMatrix {
- protected:
- S4 d_xp;
- public:
- typedef SparseMatrix<double> MatrixType;
- dsparseModelMatrix(const S4& xp)
- : MappedSparseMatrix<double>(as<MappedSparseMatrix<double> >(xp)),
- modelMatrix(xp), d_xp(xp) {}
- };
-
- namespace traits {
- template<typename Xtype> struct merPred_XTraits;
- template<> struct merPred_XTraits<ddenseModelMatrix> {
- enum {
- RowsAtCompileTime = ddenseModelMatrix::RowsAtCompileTime,
- ColsAtCompileTime = ddenseModelMatrix::ColsAtCompileTime,
- MaxColsAtCompileTime = ddenseModelMatrix::MaxColsAtCompileTime
- };
- typedef typename ddenseModelMatrix::Index Index;
- typedef typename ddenseModelMatrix::Scalar Scalar;
-// typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> MatrixType;
-// typedef SelfAdjointView<MatrixType, Lower> LowerSymType;
- // typedef dsyMatrixU UpperSymType;
- // typedef TriangularView<MatrixType, Lower> LowerTriType;
- // typedef TriangularView<MatrixType, Upper> UpperTriType;
- // typedef Eigen::LLT<MatrixType, Upper> LLtUpperType;
- // typedef Eigen::LLT<MatrixType, Lower> LLtLowerType;
- };
-
- template<> struct merPred_XTraits<dsparseModelMatrix> {
- typedef typename dsparseModelMatrix::Index Index;
- typedef typename dsparseModelMatrix::Scalar Scalar;
- // typedef SparseMatrix<Scalar, Eigen::ColMajor, Index> MatrixType;
- // typedef Eigen::SparseSelfAdjointView<MatrixType, Lower> LowerSymType;
- // typedef Eigen::SparseSelfAdjointView<MatrixType, Upper> UpperSymType;
- // typedef Eigen::SparseTriangularView<MatrixType, Lower> LowerTriType;
- // typedef Eigen::SparseTriangularView<MatrixType, Upper> UpperTriType;
- // typedef Eigen::SimplicialLLt<MatrixType, Lower> LLtLowerType;
- // typedef Eigen::SimplicialLLt<MatrixType, Upper> LLtUpperType;
- };
- }
-#endif
-
using Eigen::LLT;
using Eigen::MatrixXd;
using Eigen::VectorXd;
More information about the Lme4-commits
mailing list