[#1263] More functions to RREGDEF needed in init.c

View Trackers | Feature Requests | Download .csv | Monitor

2011-01-31 14:34
Submitted by:
Henrik Alsing Friberg (alsing)
Assigned to:
Martin Maechler (mmaechler)
Operating System:
More functions to RREGDEF needed in init.c

Detailed description
In "Matrix_stubs.c" the function M_as_cholmod_triplet is defined and depends on a call to

R_GetCCallable("Matrix", "as_cholmod_triplet");

Unfortunately in init.c the RREGDEF macro has not been called for the "as_cholmod_triplet" function why it is not available. This actually qualifies as a bug.

But actually, I belive that more functions should be available to support the validation of Matrix structures obtained as input SEXP objects through the .Call function of the R interface. Currently I am forced to hardcode my assumption of the object classes supported by the Matrix package, fx by defining the array

const char *valid_csparse[] =
{"dgCMatrix", "dsCMatrix", "dtCMatrix",
"lgCMatrix", "lsCMatrix", "ltCMatrix",
"ngCMatrix", "nsCMatrix", "ntCMatrix",
"zgCMatrix", "zsCMatrix", "ztCMatrix", ""};

and perform the operations of the "Matrix_check_class_etc" and "Matrix_check_class_and_super" already defined in Mutils.c. Why not make these char* arrays available in Matrix_stubs.c and the functions available through the RREGDEF macro in init.c?

Alternatively, define a set of functions

bool Matrix_isclass_csparse(SEXP x);
bool Matrix_isclass_triplet(SEXP x);
bool Matrix_isclass_dense(SEXP x);
bool Matrix_isclass_factor(SEXP x);

defined along the lines
bool Matrix_isclass_csparse(SEXP x) {
return Matrix_check_class_etc(x, valid_csparse) >= 0;

which returns the correctness of the assumptions within the corresponding conversion functions M_as_cholmod_sparse, M_as_cholmod_triplet, etc.. This way you have a chance of avoiding the call to Rf_error(), when e.g. a SEXP object pointing to a dgeMatrix is given as input to the "as_cholmod_sparse" function in chm_common.c, where the GET_SLOT(x, Matrix_iSym) request fails immediately.

Please write back if you do not understand my problem and requested solution.

Thank you very much for this otherwise perfect Matrix package!


Date: 2015-04-01 09:04
Sender: Martin Maechler

I think all the wishes above have been fulfilled for a long time.
Date: 2011-08-26 12:49
Sender: Martin Maechler

Could we switch to e-mail for a more indepth discussion? Please contact us at Thanks in advance: Doug Bates and Martin Maechler

Attached Files:


Field Old Value Date By
assigned_tonone2015-04-01 09:04mmaechler
close_dateNone2015-04-01 09:04mmaechler
status_idOpen2015-04-01 09:04mmaechler
Operating SystemNone2011-08-26 12:49mmaechler
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge