Skip to content

Commit eeaba38

Browse files
committed
first try (no rev. dep. checked yet)
1 parent 56dc0cc commit eeaba38

File tree

9 files changed

+114
-1719
lines changed

9 files changed

+114
-1719
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ License: GPL (>= 2) | file LICENSE
2424
LazyLoad: yes
2525
Depends: R (>= 3.6.0)
2626
LinkingTo: Rcpp
27-
Imports: Matrix (>= 1.1-0), Rcpp (>= 0.11.0), stats, utils
27+
Imports: Rcpp (>= 0.11.0), stats, utils
2828
Suggests: inline, tinytest, pkgKitten, microbenchmark
2929
URL: https://github.com/RcppCore/RcppEigen, https://dirk.eddelbuettel.com/code/rcpp.eigen.html
3030
BugReports: https://github.com/RcppCore/RcppEigen/issues

NAMESPACE

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
useDynLib("RcppEigen", .registration=TRUE)
22

3-
importClassesFrom("Matrix", "dgCMatrix", "dgeMatrix", "dsCMatrix", "dtCMatrix")
43
importFrom("Rcpp", "evalCpp")
54
importFrom("utils", "packageDescription", "package.skeleton")
65
importFrom("stats", "model.frame", "model.matrix", "model.response", "fitted", "coef", "printCoefmat", "pt")

inst/include/Eigen/CholmodSupport

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
#include "src/Core/util/DisableStupidWarnings.h"
1414

15-
extern "C" {
16-
#include <RcppEigenCholmod.h>
17-
}
18-
1915
/** \ingroup Support_modules
2016
* \defgroup CholmodSupport_Module CholmodSupport module
2117
*

inst/include/Eigen/src/CholmodSupport/CholmodSupport.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,23 @@ class CholmodBase : public SparseSolverBase<Derived>
195195
{
196196
EIGEN_STATIC_ASSERT((internal::is_same<double,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
197197
m_shiftOffset[0] = m_shiftOffset[1] = 0.0;
198-
cholmod_start(&m_cholmod);
198+
R_MATRIX_CHOLMOD(start)(&m_cholmod);
199199
}
200200

201201
explicit CholmodBase(const MatrixType& matrix)
202202
: m_cholmodFactor(0), m_info(Success), m_factorizationIsOk(false), m_analysisIsOk(false)
203203
{
204204
EIGEN_STATIC_ASSERT((internal::is_same<double,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
205205
m_shiftOffset[0] = m_shiftOffset[1] = 0.0;
206-
cholmod_start(&m_cholmod);
206+
R_MATRIX_CHOLMOD(start)(&m_cholmod);
207207
compute(matrix);
208208
}
209209

210210
~CholmodBase()
211211
{
212212
if(m_cholmodFactor)
213-
cholmod_free_factor(&m_cholmodFactor, &m_cholmod);
214-
cholmod_finish(&m_cholmod);
213+
R_MATRIX_CHOLMOD(free_factor)(&m_cholmodFactor, &m_cholmod);
214+
R_MATRIX_CHOLMOD(finish)(&m_cholmod);
215215
}
216216

217217
inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
@@ -246,11 +246,11 @@ class CholmodBase : public SparseSolverBase<Derived>
246246
{
247247
if(m_cholmodFactor)
248248
{
249-
cholmod_free_factor(&m_cholmodFactor, &m_cholmod);
249+
R_MATRIX_CHOLMOD(free_factor)(&m_cholmodFactor, &m_cholmod);
250250
m_cholmodFactor = 0;
251251
}
252252
cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
253-
m_cholmodFactor = cholmod_analyze(&A, &m_cholmod);
253+
m_cholmodFactor = R_MATRIX_CHOLMOD(analyze)(&A, &m_cholmod);
254254

255255
this->m_isInitialized = true;
256256
this->m_info = Success;
@@ -268,7 +268,7 @@ class CholmodBase : public SparseSolverBase<Derived>
268268
{
269269
eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
270270
cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
271-
cholmod_factorize_p(&A, m_shiftOffset, 0, 0, m_cholmodFactor, &m_cholmod);
271+
R_MATRIX_CHOLMOD(factorize_p)(&A, m_shiftOffset, 0, 0, m_cholmodFactor, &m_cholmod);
272272

273273
// If the factorization failed, minor is the column at which it did. On success minor == n.
274274
this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);
@@ -293,15 +293,15 @@ class CholmodBase : public SparseSolverBase<Derived>
293293
Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b.derived());
294294

295295
cholmod_dense b_cd = viewAsCholmod(b_ref);
296-
cholmod_dense* x_cd = cholmod_solve(CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod);
296+
cholmod_dense* x_cd = R_MATRIX_CHOLMOD(solve)(CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod);
297297
if(!x_cd)
298298
{
299299
this->m_info = NumericalIssue;
300300
return;
301301
}
302302
// TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
303303
dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
304-
cholmod_free_dense(&x_cd, &m_cholmod);
304+
R_MATRIX_CHOLMOD(free_dense)(&x_cd, &m_cholmod);
305305
}
306306

307307
/** \internal */
@@ -316,15 +316,15 @@ class CholmodBase : public SparseSolverBase<Derived>
316316
// note: cs stands for Cholmod Sparse
317317
Ref<SparseMatrix<typename RhsDerived::Scalar,ColMajor,typename RhsDerived::StorageIndex> > b_ref(b.const_cast_derived());
318318
cholmod_sparse b_cs = viewAsCholmod(b_ref);
319-
cholmod_sparse* x_cs = cholmod_spsolve(CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod);
319+
cholmod_sparse* x_cs = R_MATRIX_CHOLMOD(spsolve)(CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod);
320320
if(!x_cs)
321321
{
322322
this->m_info = NumericalIssue;
323323
return;
324324
}
325325
// TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
326326
dest.derived() = viewAsEigen<typename DestDerived::Scalar,ColMajor,typename DestDerived::StorageIndex>(*x_cs);
327-
cholmod_free_sparse(&x_cs, &m_cholmod);
327+
R_MATRIX_CHOLMOD(free_sparse)(&x_cs, &m_cholmod);
328328
}
329329
#endif // EIGEN_PARSED_BY_DOXYGEN
330330

0 commit comments

Comments
 (0)