File: C:/Program Files/R/R-4.4.0/library/Matrix/scripts/api.patch
--- inst/include/Matrix/cholmod.h 2024-01-17 13:47:18
+++ inst/include/Matrix/cholmod.h-patched.h 2024-01-17 02:18:32
@@ -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,1,1)
@@ -313,6 +323,13 @@
#error "CHOLMOD 5.1.1 requires SuiteSparse_config 7.5.0 or later"
#endif
+#else
+
+#include <stdint.h>
+#include <stddef.h>
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
//------------------------------------------------------------------------------
// CHOLMOD configuration
//------------------------------------------------------------------------------
@@ -353,6 +370,8 @@
// existence of this #define here, and its use in these 3 modules, does not
// affect the license itself; see CHOLMOD/Doc/License.txt for your actual
// license.
+
+#ifndef R_MATRIX_CHOLMOD_H
#ifdef NGPL
#undef NMATRIXOPS
@@ -363,6 +382,8 @@
#define NSUPERNODAL
#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
//==============================================================================
// CHOLMOD:Utility Module
//==============================================================================
@@ -923,6 +944,8 @@
#define CHOLMOD_GPU_POTRF_TIME cholmod_gpu_potrf_time
#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
@@ -1065,6 +1088,8 @@
) ;
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
//==============================================================================
@@ -1109,6 +1134,8 @@
} cholmod_sparse ;
+#ifndef R_MATRIX_CHOLMOD_H
+
//------------------------------------------------------------------------------
// cholmod_allocate_sparse: allocate a sparse matrix
//------------------------------------------------------------------------------
@@ -1436,6 +1463,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)
//==============================================================================
@@ -1556,6 +1585,8 @@
} cholmod_factor ;
+#ifndef R_MATRIX_CHOLMOD_H
+
//------------------------------------------------------------------------------
// cholmod_allocate_factor: allocate a numerical factor
//------------------------------------------------------------------------------
@@ -1698,6 +1729,8 @@
cholmod_common *Common
) ;
int cholmod_l_factor_xtype (int, cholmod_factor *, cholmod_common *) ;
+
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
//==============================================================================
// cholmod_dense: a dense matrix, held by column
@@ -1716,6 +1749,8 @@
} cholmod_dense ;
+#ifndef R_MATRIX_CHOLMOD_H
+
//------------------------------------------------------------------------------
// cholmod_allocate_dense: allocate a dense matrix (contents not initialized)
//------------------------------------------------------------------------------
@@ -1893,6 +1928,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
//=============================================================================
@@ -1934,6 +1971,8 @@
int dtype ; // x and z are double or single
} cholmod_triplet ;
+
+#ifndef R_MATRIX_CHOLMOD_H
//------------------------------------------------------------------------------
// cholmod_allocate_triplet: allocate a triplet matrix
@@ -2033,6 +2072,8 @@
) ;
int cholmod_l_triplet_xtype (int, cholmod_triplet *, cholmod_common *) ;
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
+
//------------------------------------------------------------------------------
// memory allocation: malloc/calloc/realloc/free
//------------------------------------------------------------------------------
@@ -2046,6 +2087,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:
@@ -2108,6 +2151,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
//------------------------------------------------------------------------------
@@ -2115,6 +2160,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.)
@@ -2122,14 +2169,14 @@
#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
// file:
@@ -2180,6 +2227,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
//------------------------------------------------------------------------------
@@ -2518,6 +2567,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
#define CHOLMOD_MM_UNSYMMETRIC 2
@@ -2527,6 +2578,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:
@@ -2554,14 +2607,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
@@ -2602,6 +2653,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)
//------------------------------------------------------------------------------
@@ -2706,6 +2759,8 @@
// 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 */
#define CHOLMOD_LD 2 /* solve LDx=b */
@@ -2715,6 +2770,8 @@
#define CHOLMOD_D 6 /* solve Dx=b */
#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
(
@@ -3076,14 +3133,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
@@ -3102,6 +3157,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
//------------------------------------------------------------------------------
@@ -3167,12 +3224,16 @@
// 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
(
// input:
@@ -3308,13 +3369,11 @@
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
@@ -3349,6 +3408,8 @@
//
// Requires the Utility module. Not required by any other CHOLMOD module.
+#ifndef R_MATRIX_CHOLMOD_H
+
//------------------------------------------------------------------------------
// cholmod_updown: multiple rank update/downdate
//------------------------------------------------------------------------------
@@ -3600,7 +3661,7 @@
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)
@@ -3632,7 +3693,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
@@ -3694,7 +3755,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)
@@ -3703,7 +3764,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
@@ -3820,13 +3881,11 @@
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
@@ -3860,6 +3919,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
//------------------------------------------------------------------------------
@@ -3888,10 +3949,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:
@@ -3972,7 +4037,7 @@
int cholmod_l_super_ltsolve (cholmod_factor *, cholmod_dense *, cholmod_dense *,
cholmod_common *) ;
-#endif
+#endif /* !defined(R_MATRIX_CHOLMOD_H) */
#ifdef __cplusplus
}
@@ -3997,11 +4062,15 @@
}
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
@@ -4048,6 +4117,8 @@
void *d_RelativeMap ;
} cholmod_gpu_pointers ;
+
+#ifndef R_MATRIX_CHOLMOD_H
int cholmod_gpu_memorysize // GPU memory size available, 1 if no GPU
(
@@ -4078,11 +4149,124 @@
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_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 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 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 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) */
+