File: cholmod.h.patch

package info (click to toggle)
rmatrix 1.7-4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,096 kB
  • sloc: ansic: 97,203; makefile: 280; sh: 165
file content (704 lines) | stat: -rw-r--r-- 24,738 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
--- inst/include/Matrix/cholmod.h	2024-08-30 23:28:08
+++ inst/include/Matrix/cholmod.h-patched.h	2024-08-30 23:07:12
@@ -46,8 +46,8 @@
 // CHOLMOD's Partition Module.
 // -----------------------------------------------------------------------------
 
-#ifndef CHOLMOD_H
-#define CHOLMOD_H
+#ifndef R_MATRIX_CHOLMOD_H
+#define R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // CHOLMOD conventions
@@ -259,6 +259,8 @@
 extern "C" {
 #endif
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 int cholmod_version     // returns CHOLMOD_VERSION, defined above
 (
     // if version is not NULL, then cholmod_version returns its contents as:
@@ -268,6 +270,8 @@
     int version [3]
 ) ;
 int cholmod_l_version (int version [3]) ;
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 #ifdef __cplusplus
 }
@@ -287,6 +291,8 @@
 // particular, you must use -DNLARGEFILE for MATLAB 6.5 or earlier (which does
 // not have the io64.h include file).
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 // skip all of this if NLARGEFILE is defined at the compiler command line
 #ifndef NLARGEFILE
     #if defined(MATLAB_MEX_FILE) || defined(MATHWORKS)
@@ -301,10 +307,14 @@
     #endif
 #endif
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //------------------------------------------------------------------------------
 // SuiteSparse_config: definitions for all SuiteSparse packages
 //------------------------------------------------------------------------------
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 #include "SuiteSparse_config.h"
 
 #define CHOLMOD__VERSION SUITESPARSE__VERCODE(5,2,0)
@@ -313,6 +323,13 @@
 #error "CHOLMOD 5.2.0 requires SuiteSparse_config 7.6.0 or later"
 #endif
 
+#else
+
+#include <stdint.h>
+#include <stddef.h>
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //------------------------------------------------------------------------------
 // CHOLMOD configuration
 //------------------------------------------------------------------------------
@@ -354,6 +371,8 @@
 //  affect the license itself; see CHOLMOD/Doc/License.txt for your actual
 //  license.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 #ifdef NGPL
     #undef  NMATRIXOPS
     #define NMATRIXOPS
@@ -362,6 +381,8 @@
     #undef  NSUPERNODAL
     #define NSUPERNODAL
 #endif
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:Utility Module
@@ -926,6 +947,8 @@
 #define CHOLMOD_ASSEMBLE_TIME       cholmod_assemble_time
 #define CHOLMOD_ASSEMBLE_TIME2      cholmod_assemble_time2
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_start:  first call to CHOLMOD
 //------------------------------------------------------------------------------
@@ -1066,6 +1089,8 @@
     double *cr, double *ci      // c (real, imaginary)
 ) ;
 int cholmod_l_divcomplex (double, double, double, double, double *, double *) ;
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // cholmod_sparse: a sparse matrix in compressed-column (CSC) form
@@ -1110,6 +1135,8 @@
     int packed ;    // true if packed (A->nz ignored), false if unpacked
 
 } cholmod_sparse ;
+
+#ifndef R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // cholmod_allocate_sparse:  allocate a sparse matrix
@@ -1421,8 +1448,8 @@
     int sorted,         // ignored; C is now always returned as sorted
     cholmod_common *Common
 ) ;
-cholmod_sparse *cholmod_l_add (cholmod_sparse *, cholmod_sparse *, double *,
-    double *, int, int, cholmod_common *) ;
+cholmod_sparse *cholmod_l_add (cholmod_sparse *, cholmod_sparse *, double [2],
+    double [2], int, int, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
 // cholmod_sparse_xtype: change the xtype and/or dtype of a sparse matrix
@@ -1438,6 +1465,8 @@
 ) ;
 int cholmod_l_sparse_xtype (int, cholmod_sparse *, cholmod_common *) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //==============================================================================
 // cholmod_factor: symbolic or numeric factorization (simplicial or supernodal)
 //==============================================================================
@@ -1558,6 +1587,8 @@
 
 } cholmod_factor ;
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_allocate_factor: allocate a numerical factor
 //------------------------------------------------------------------------------
@@ -1701,6 +1732,8 @@
 ) ;
 int cholmod_l_factor_xtype (int, cholmod_factor *, cholmod_common *) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //==============================================================================
 // cholmod_dense: a dense matrix, held by column
 //==============================================================================
@@ -1718,6 +1751,8 @@
 
 } cholmod_dense ;
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_allocate_dense: allocate a dense matrix (contents not initialized)
 //------------------------------------------------------------------------------
@@ -1895,6 +1930,8 @@
 ) ;
 int cholmod_l_dense_xtype (int, cholmod_dense *, cholmod_common *) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //=============================================================================
 // cholmod_triplet: a sparse matrix in triplet form
 //=============================================================================
@@ -1937,6 +1974,8 @@
 
 } cholmod_triplet ;
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_allocate_triplet: allocate a triplet matrix
 //------------------------------------------------------------------------------
@@ -2035,6 +2074,8 @@
 ) ;
 int cholmod_l_triplet_xtype (int, cholmod_triplet *, cholmod_common *) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //------------------------------------------------------------------------------
 // memory allocation: malloc/calloc/realloc/free
 //------------------------------------------------------------------------------
@@ -2048,6 +2089,8 @@
 // statistics. cholmod_realloc does not return NULL if it fails; instead, it
 // returns the pointer to the unmodified block of memory.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 void *cholmod_malloc    // return pointer to newly allocated memory
 (
     // input:
@@ -2110,6 +2153,8 @@
 int cholmod_l_realloc_multiple (size_t, int, int, void **, void **, void **,
     void **, size_t *, cholmod_common *) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 //------------------------------------------------------------------------------
 // numerical comparisons
 //------------------------------------------------------------------------------
@@ -2117,6 +2162,8 @@
 // These macros were different on Windows for older versions of CHOLMOD.
 // They are no longer needed but are kept for backward compatibility.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 #define CHOLMOD_IS_NAN(x)       isnan (x)
 #define CHOLMOD_IS_ZERO(x)      ((x) == 0.)
 #define CHOLMOD_IS_NONZERO(x)   ((x) != 0.)
@@ -2124,13 +2171,13 @@
 #define CHOLMOD_IS_GT_ZERO(x)   ((x) > 0.)
 #define CHOLMOD_IS_LE_ZERO(x)   ((x) <= 0.)
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 #endif
 
 //==============================================================================
 // CHOLMOD:Check Module
 //==============================================================================
-
-#ifndef NCHECK
 
 // Routines that check and print the 5 basic data types in CHOLMOD, and 3 kinds
 // of integer vectors (subset, perm, and parent), and read in matrices from a
@@ -2181,6 +2228,8 @@
 //
 // See cholmod_read.c for a description of the file formats supported by the
 // cholmod_read_* routines.
+
+#ifndef R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // cholmod_check_common:  check the Common object
@@ -2519,6 +2568,8 @@
 //------------------------------------------------------------------------------
 // cholmod_write_sparse: write a sparse matrix to a file
 //------------------------------------------------------------------------------
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 // return values of cholmod_symmetry and cholmod_write:
 #define CHOLMOD_MM_RECTANGULAR       1
@@ -2529,6 +2580,8 @@
 #define CHOLMOD_MM_SYMMETRIC_POSDIAG 6
 #define CHOLMOD_MM_HERMITIAN_POSDIAG 7
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 int cholmod_write_sparse    // see above, or -1 on error
 (
     // input:
@@ -2556,14 +2609,12 @@
 int cholmod_l_write_dense (FILE *, cholmod_dense *, const char *,
     cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:Cholesky Module
 //==============================================================================
 
-#ifndef NCHOLESKY
-
 // Sparse Cholesky routines: analysis, factorization, and solve.
 //
 // The primary routines are all that a user requires to order, analyze, and
@@ -2604,6 +2655,8 @@
 // Optionally uses the Supernodal and Partition modules.
 // Required by the Partition module.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_analyze:  order and analyze (simplicial or supernodal)
 //------------------------------------------------------------------------------
@@ -2697,7 +2750,7 @@
     cholmod_factor *L,  // resulting factorization
     cholmod_common *Common
 ) ;
-int cholmod_l_factorize_p (cholmod_sparse *, double *, int64_t *, size_t,
+int cholmod_l_factorize_p (cholmod_sparse *, double [2], int64_t *, size_t,
     cholmod_factor *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -2707,6 +2760,8 @@
 // Solves one of many linear systems with a dense right-hand-side, using the
 // factorization from cholmod_factorize (or as modified by any other CHOLMOD
 // routine).  D is identity for LL' factorizations.
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 #define CHOLMOD_A    0  /* solve Ax=b    */
 #define CHOLMOD_LDLt 1  /* solve LDL'x=b */
@@ -2718,6 +2773,8 @@
 #define CHOLMOD_P    7  /* permute x=Px  */
 #define CHOLMOD_Pt   8  /* permute x=P'x */
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 cholmod_dense *cholmod_solve    // returns the solution X
 (
     // input:
@@ -2895,7 +2952,7 @@
     cholmod_factor *L,
     cholmod_common *Common
 ) ;
-int cholmod_l_rowfac (cholmod_sparse *, cholmod_sparse *, double *, size_t,
+int cholmod_l_rowfac (cholmod_sparse *, cholmod_sparse *, double [2], size_t,
     size_t, cholmod_factor *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -2920,7 +2977,7 @@
     cholmod_factor *L,
     cholmod_common *Common
 ) ;
-int cholmod_l_rowfac_mask (cholmod_sparse *, cholmod_sparse *, double *,
+int cholmod_l_rowfac_mask (cholmod_sparse *, cholmod_sparse *, double [2],
     size_t, size_t, int64_t *, int64_t *, cholmod_factor *, cholmod_common *) ;
 
 int cholmod_rowfac_mask2
@@ -2939,7 +2996,7 @@
     cholmod_factor *L,
     cholmod_common *Common
 ) ;
-int cholmod_l_rowfac_mask2 (cholmod_sparse *, cholmod_sparse *, double *,
+int cholmod_l_rowfac_mask2 (cholmod_sparse *, cholmod_sparse *, double [2],
     size_t, size_t, int64_t *, int64_t, int64_t *, cholmod_factor *,
     cholmod_common *) ;
 
@@ -3078,14 +3135,12 @@
 int64_t cholmod_l_postorder (int64_t *, size_t, int64_t *, int64_t *,
     cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:MatrixOps Module
 //==============================================================================
 
-#ifndef NMATRIXOPS
-
 // Basic operations on sparse and dense matrices.
 //
 // cholmod_drop             A = entries in A with abs. value >= tol
@@ -3104,6 +3159,8 @@
 //
 // Requires the Utility module.  Not required by any other CHOLMOD module.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_drop:  drop entries with small absolute value
 //------------------------------------------------------------------------------
@@ -3169,11 +3226,15 @@
 // cholmod_scale:  A = diag(s)*A, A*diag(s), s*A or diag(s)*A*diag(s)
 //------------------------------------------------------------------------------
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 // scaling modes, selected by the scale input parameter:
 #define CHOLMOD_SCALAR 0    /* A = s*A               */
 #define CHOLMOD_ROW    1    /* A = diag(s)*A         */
 #define CHOLMOD_COL    2    /* A = A*diag(s)         */
 #define CHOLMOD_SYM    3    /* A = diag(s)*A*diag(s) */
+
+#ifndef R_MATRIX_CHOLMOD_H
 
 int cholmod_scale
 (
@@ -3204,7 +3265,7 @@
     cholmod_dense *Y,   // resulting dense matrix
     cholmod_common *Common
 ) ;
-int cholmod_l_sdmult (cholmod_sparse *, int, double *, double *,
+int cholmod_l_sdmult (cholmod_sparse *, int, double [2], double [2],
     cholmod_dense *, cholmod_dense *Y, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -3310,14 +3371,12 @@
 int cholmod_l_symmetry (cholmod_sparse *, int, int64_t *, int64_t *, int64_t *,
     int64_t *, cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:Modify Module
 //==============================================================================
 
-#ifndef NMODIFY
-
 //------------------------------------------------------------------------------
 // CHOLMOD:Modify Module. Copyright (C) 2005-2023, Timothy A. Davis and William
 // W. Hager.  http://www.suitesparse.com
@@ -3350,6 +3409,8 @@
 // cholmod_rowdel_mark      delete a row, and downdate solution to partial Lx=b
 //
 // Requires the Utility module.  Not required by any other CHOLMOD module.
+
+#ifndef R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // cholmod_updown:  multiple rank update/downdate
@@ -3504,7 +3565,7 @@
     cholmod_dense *DeltaB,  // change in b, zero on output
     cholmod_common *Common
 ) ;
-int cholmod_l_rowadd_solve (size_t, cholmod_sparse *, double *,
+int cholmod_l_rowadd_solve (size_t, cholmod_sparse *, double [2],
     cholmod_factor *, cholmod_dense *, cholmod_dense *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -3528,7 +3589,7 @@
     cholmod_dense *DeltaB,  // change in b, zero on output
     cholmod_common *Common
 ) ;
-int cholmod_l_rowadd_mark (size_t, cholmod_sparse *, double *, int64_t *,
+int cholmod_l_rowadd_mark (size_t, cholmod_sparse *, double [2], int64_t *,
     cholmod_factor *, cholmod_dense *, cholmod_dense *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -3575,7 +3636,7 @@
     cholmod_dense *DeltaB,  // change in b, zero on output
     cholmod_common *Common
 ) ;
-int cholmod_l_rowdel_solve (size_t, cholmod_sparse *, double *,
+int cholmod_l_rowdel_solve (size_t, cholmod_sparse *, double [2],
     cholmod_factor *, cholmod_dense *, cholmod_dense *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -3599,10 +3660,10 @@
     cholmod_dense *DeltaB,  // change in b, zero on output
     cholmod_common *Common
 ) ;
-int cholmod_l_rowdel_mark (size_t, cholmod_sparse *, double *, int64_t *,
+int cholmod_l_rowdel_mark (size_t, cholmod_sparse *, double [2], int64_t *,
     cholmod_factor *, cholmod_dense *, cholmod_dense *, cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:Partition Module (CAMD, CCOLAMD, and CSYMAMD)
@@ -3634,7 +3695,7 @@
 // Requires the Utility and Cholesky modules, and three packages: METIS, CAMD,
 // and CCOLAMD.  Optionally used by the Cholesky module.
 
-#ifndef NCAMD
+#ifndef R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // cholmod_ccolamd
@@ -3696,7 +3757,7 @@
 int cholmod_l_camd (cholmod_sparse *, int64_t *, size_t, int64_t *, int64_t *,
     cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //------------------------------------------------------------------------------
 // CHOLMOD:Partition Module (graph partition methods)
@@ -3705,7 +3766,7 @@
 // These routines still exist if CHOLMOD is compiled with -DNPARTITION,
 // but they return Common->status = CHOLMOD_NOT_INSTALLED in that case.
 
-#if 1
+#ifndef R_MATRIX_CHOLMOD_H
 
 //------------------------------------------------------------------------------
 // cholmod_nested_dissection
@@ -3822,14 +3883,12 @@
 int64_t cholmod_l_collapse_septree (size_t, size_t, double, size_t, int64_t *,
     int64_t *, cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 //==============================================================================
 // CHOLMOD:Supernodal Module
 //==============================================================================
 
-#ifndef NSUPERNODAL
-
 // Supernodal analysis, factorization, and solve.  The simplest way to use
 // these routines is via the Cholesky module.  It does not provide any
 // fill-reducing orderings, but does accept the orderings computed by the
@@ -3862,6 +3921,8 @@
 // Requires the Utility module, and two external packages: LAPACK and the BLAS.
 // Optionally used by the Cholesky module.
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 //------------------------------------------------------------------------------
 // cholmod_super_symbolic
 //------------------------------------------------------------------------------
@@ -3890,10 +3951,14 @@
 
 // Analyze for supernodal Cholesky or multifrontal QR
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 #define CHOLMOD_ANALYZE_FOR_SPQR     0
 #define CHOLMOD_ANALYZE_FOR_CHOLESKY 1
 #define CHOLMOD_ANALYZE_FOR_SPQRGPU  2
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 int cholmod_super_symbolic2
 (
     // input:
@@ -3929,7 +3994,7 @@
     cholmod_factor *L,  // factorization
     cholmod_common *Common
 ) ;
-int cholmod_l_super_numeric (cholmod_sparse *, cholmod_sparse *, double *,
+int cholmod_l_super_numeric (cholmod_sparse *, cholmod_sparse *, double [2],
     cholmod_factor *, cholmod_common *) ;
 
 //------------------------------------------------------------------------------
@@ -3974,7 +4039,7 @@
 int cholmod_l_super_ltsolve (cholmod_factor *, cholmod_dense *, cholmod_dense *,
     cholmod_common *) ;
 
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
 
 #ifdef __cplusplus
 }
@@ -3998,12 +4063,16 @@
     int64_t d ;
 }
 descendantScore ;
+
+#ifndef R_MATRIX_CHOLMOD_H
 
 int cholmod_score_comp   (struct cholmod_descendant_score_t *i,
                           struct cholmod_descendant_score_t *j) ;
 int cholmod_l_score_comp (struct cholmod_descendant_score_t *i,
                           struct cholmod_descendant_score_t *j) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 #ifdef __cplusplus
 }
 #endif
@@ -4051,6 +4120,8 @@
 
 } cholmod_gpu_pointers ;
 
+#ifndef R_MATRIX_CHOLMOD_H
+
 int cholmod_gpu_memorysize   // GPU memory size available, 1 if no GPU
 (
     size_t         *total_mem,
@@ -4080,11 +4151,140 @@
 int cholmod_gpu_allocate   ( cholmod_common *Common ) ;
 int cholmod_l_gpu_allocate ( cholmod_common *Common ) ;
 
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
 #ifdef __cplusplus
 }
 #endif
 
 #endif
 
+/* <<<< Matrix <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
+
+/* We declare a minimal subset of the above as "API" : */
+
+#ifndef R_MATRIX_CHOLMOD
+# define R_MATRIX_CHOLMOD(_NAME_) M_cholmod_ ## _NAME_
 #endif
 
+#ifndef R_MATRIX_INLINE
+# define R_MATRIX_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef cholmod_common  * CHM_CM;
+typedef cholmod_factor  * CHM_FR;
+typedef cholmod_sparse  * CHM_SP;
+typedef cholmod_triplet * CHM_TR;
+typedef cholmod_dense   * CHM_DN;
+
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(aat)(
+	CHM_SP, int *, size_t, int, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(add)(
+	CHM_SP, CHM_SP, double[2], double[2], int, int, CHM_CM);
+R_MATRIX_INLINE CHM_DN R_MATRIX_CHOLMOD(allocate_dense)(
+	size_t, size_t, size_t, int, CHM_CM);
+R_MATRIX_INLINE CHM_FR R_MATRIX_CHOLMOD(allocate_factor)(
+	size_t, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(allocate_sparse)(
+	size_t, size_t, size_t, int, int, int, int, CHM_CM);
+R_MATRIX_INLINE CHM_TR R_MATRIX_CHOLMOD(allocate_triplet)(
+	size_t, size_t, size_t, int, int, CHM_CM);
+R_MATRIX_INLINE CHM_FR R_MATRIX_CHOLMOD(analyze)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_FR R_MATRIX_CHOLMOD(analyze_p)(
+	CHM_SP, int *, int *, size_t, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(band_inplace)(
+	int, int, int, CHM_SP, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(change_factor)(
+	int, int, int, int, int, CHM_FR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(check_common)(
+	CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(check_dense)(
+	CHM_DN, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(check_factor)(
+	CHM_FR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(check_sparse)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(check_triplet)(
+	CHM_TR, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(copy)(
+	CHM_SP, int, int, CHM_CM);
+R_MATRIX_INLINE CHM_DN R_MATRIX_CHOLMOD(copy_dense)(
+	CHM_DN, CHM_CM);
+R_MATRIX_INLINE CHM_FR R_MATRIX_CHOLMOD(copy_factor)(
+	CHM_FR, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(copy_sparse)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_TR R_MATRIX_CHOLMOD(copy_triplet)(
+	CHM_TR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(defaults)(
+	CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(dense_to_sparse)(
+	CHM_DN, int, CHM_CM);
+R_MATRIX_INLINE   void R_MATRIX_CHOLMOD(error_handler)(
+	int, const char *, int, const char *);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(factor_to_sparse )(
+	CHM_FR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(factorize)(
+	CHM_SP, CHM_FR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(factorize_p)(
+	CHM_SP, double[2], int *, size_t, CHM_FR, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(finish)(
+	CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(free_dense)(
+	CHM_DN *, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(free_factor)(
+	CHM_FR *, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(free_sparse)(
+	CHM_SP *, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(free_triplet)(
+	CHM_TR *, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(horzcat)(
+	CHM_SP, CHM_SP, int, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(nnz)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(scale)(
+	CHM_DN, int, CHM_SP, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(sdmult)(
+	CHM_SP, int, double[2], double[2], CHM_DN, CHM_DN, CHM_CM);
+R_MATRIX_INLINE CHM_DN R_MATRIX_CHOLMOD(solve)(
+	int, CHM_FR, CHM_DN, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(solve2)(
+	int, CHM_FR, CHM_DN, CHM_DN *, CHM_DN *, CHM_DN *, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(sort)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_DN R_MATRIX_CHOLMOD(sparse_to_dense)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_TR R_MATRIX_CHOLMOD(sparse_to_triplet)(
+	CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(speye)(
+	size_t, size_t, int, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(spsolve)(
+	int, CHM_FR, CHM_SP, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(ssmult)(
+	CHM_SP, CHM_SP, int, int, int, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(start)(
+	CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(submatrix)(
+	CHM_SP, int *, int, int *, int, int, int, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(transpose)(
+	CHM_SP, int, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(triplet_to_sparse)(
+	CHM_TR, int, CHM_CM);
+R_MATRIX_INLINE    int R_MATRIX_CHOLMOD(updown)(
+	int, CHM_SP, CHM_FR, CHM_CM);
+R_MATRIX_INLINE CHM_SP R_MATRIX_CHOLMOD(vertcat)(
+	CHM_SP, CHM_SP, int, CHM_CM);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* >>>> Matrix >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+