10
10
#ifndef EIGEN_CHOLMODSUPPORT_H
11
11
#define EIGEN_CHOLMODSUPPORT_H
12
12
13
+ #ifndef R_MATRIX_CHOLMOD
14
+ # define R_MATRIX_CHOLMOD (_NAME_ ) cholmod_ ## _NAME_
15
+ #endif
16
+
13
17
namespace Eigen {
14
18
15
19
namespace internal {
@@ -195,23 +199,23 @@ class CholmodBase : public SparseSolverBase<Derived>
195
199
{
196
200
EIGEN_STATIC_ASSERT ((internal::is_same<double ,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
197
201
m_shiftOffset[0 ] = m_shiftOffset[1 ] = 0.0 ;
198
- cholmod_start (&m_cholmod);
202
+ R_MATRIX_CHOLMOD (start) (&m_cholmod);
199
203
}
200
204
201
205
explicit CholmodBase (const MatrixType& matrix)
202
206
: m_cholmodFactor(0 ), m_info(Success), m_factorizationIsOk(false ), m_analysisIsOk(false )
203
207
{
204
208
EIGEN_STATIC_ASSERT ((internal::is_same<double ,RealScalar>::value), CHOLMOD_SUPPORTS_DOUBLE_PRECISION_ONLY);
205
209
m_shiftOffset[0 ] = m_shiftOffset[1 ] = 0.0 ;
206
- cholmod_start (&m_cholmod);
210
+ R_MATRIX_CHOLMOD (start) (&m_cholmod);
207
211
compute (matrix);
208
212
}
209
213
210
214
~CholmodBase ()
211
215
{
212
216
if (m_cholmodFactor)
213
- cholmod_free_factor (&m_cholmodFactor, &m_cholmod);
214
- cholmod_finish (&m_cholmod);
217
+ R_MATRIX_CHOLMOD (free_factor) (&m_cholmodFactor, &m_cholmod);
218
+ R_MATRIX_CHOLMOD (finish) (&m_cholmod);
215
219
}
216
220
217
221
inline StorageIndex cols () const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n ); }
@@ -246,11 +250,11 @@ class CholmodBase : public SparseSolverBase<Derived>
246
250
{
247
251
if (m_cholmodFactor)
248
252
{
249
- cholmod_free_factor (&m_cholmodFactor, &m_cholmod);
253
+ R_MATRIX_CHOLMOD (free_factor) (&m_cholmodFactor, &m_cholmod);
250
254
m_cholmodFactor = 0 ;
251
255
}
252
256
cholmod_sparse A = viewAsCholmod (matrix.template selfadjointView <UpLo>());
253
- m_cholmodFactor = cholmod_analyze (&A, &m_cholmod);
257
+ m_cholmodFactor = R_MATRIX_CHOLMOD (analyze) (&A, &m_cholmod);
254
258
255
259
this ->m_isInitialized = true ;
256
260
this ->m_info = Success;
@@ -268,7 +272,7 @@ class CholmodBase : public SparseSolverBase<Derived>
268
272
{
269
273
eigen_assert (m_analysisIsOk && " You must first call analyzePattern()" );
270
274
cholmod_sparse A = viewAsCholmod (matrix.template selfadjointView <UpLo>());
271
- cholmod_factorize_p (&A, m_shiftOffset, 0 , 0 , m_cholmodFactor, &m_cholmod);
275
+ R_MATRIX_CHOLMOD (factorize_p) (&A, m_shiftOffset, 0 , 0 , m_cholmodFactor, &m_cholmod);
272
276
273
277
// If the factorization failed, minor is the column at which it did. On success minor == n.
274
278
this ->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);
@@ -293,15 +297,15 @@ class CholmodBase : public SparseSolverBase<Derived>
293
297
Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref (b.derived ());
294
298
295
299
cholmod_dense b_cd = viewAsCholmod (b_ref);
296
- cholmod_dense* x_cd = cholmod_solve (CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod);
300
+ cholmod_dense* x_cd = R_MATRIX_CHOLMOD (solve) (CHOLMOD_A, m_cholmodFactor, &b_cd, &m_cholmod);
297
301
if (!x_cd)
298
302
{
299
303
this ->m_info = NumericalIssue;
300
304
return ;
301
305
}
302
306
// TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
303
307
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);
308
+ R_MATRIX_CHOLMOD (free_dense) (&x_cd, &m_cholmod);
305
309
}
306
310
307
311
/* * \internal */
@@ -316,15 +320,15 @@ class CholmodBase : public SparseSolverBase<Derived>
316
320
// note: cs stands for Cholmod Sparse
317
321
Ref<SparseMatrix<typename RhsDerived::Scalar,ColMajor,typename RhsDerived::StorageIndex> > b_ref (b.const_cast_derived ());
318
322
cholmod_sparse b_cs = viewAsCholmod (b_ref);
319
- cholmod_sparse* x_cs = cholmod_spsolve (CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod);
323
+ cholmod_sparse* x_cs = R_MATRIX_CHOLMOD (spsolve) (CHOLMOD_A, m_cholmodFactor, &b_cs, &m_cholmod);
320
324
if (!x_cs)
321
325
{
322
326
this ->m_info = NumericalIssue;
323
327
return ;
324
328
}
325
329
// TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
326
330
dest.derived () = viewAsEigen<typename DestDerived::Scalar,ColMajor,typename DestDerived::StorageIndex>(*x_cs);
327
- cholmod_free_sparse (&x_cs, &m_cholmod);
331
+ R_MATRIX_CHOLMOD (free_sparse) (&x_cs, &m_cholmod);
328
332
}
329
333
#endif // EIGEN_PARSED_BY_DOXYGEN
330
334
0 commit comments