MCPcopy Create free account
hub / github.com/dmlc/xgboost / XGDMatrixCreateFromCSC_R

Function XGDMatrixCreateFromCSC_R

R-package/src/xgboost_R.cc:445–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443} // namespace
444
445XGB_DLL SEXP XGDMatrixCreateFromCSC_R(SEXP indptr, SEXP indices, SEXP data, SEXP num_row,
446 SEXP missing, SEXP n_threads) {
447 SEXP ret = Rf_protect(R_MakeExternalPtr(nullptr, R_NilValue, R_NilValue));
448 R_API_BEGIN();
449 std::int32_t threads = Rf_asInteger(n_threads);
450 DMatrixHandle handle;
451
452 int res_code;
453 {
454 using xgboost::Integer;
455 using xgboost::Json;
456 using xgboost::Object;
457 std::string sindptr, sindices, sdata;
458 CreateFromSparse(indptr, indices, data, &sindptr, &sindices, &sdata);
459 auto nrow = static_cast<std::size_t>(INTEGER(num_row)[0]);
460
461 Json jconfig{Object{}};
462 // Construct configuration
463 jconfig["nthread"] = Integer{threads};
464 AddMissingToJson(&jconfig, missing, TYPEOF(data));
465 std::string config;
466 Json::Dump(jconfig, &config);
467 res_code = XGDMatrixCreateFromCSC(sindptr.c_str(), sindices.c_str(), sdata.c_str(), nrow,
468 config.c_str(), &handle);
469 }
470 CHECK_CALL(res_code);
471
472 R_SetExternalPtrAddr(ret, handle);
473 R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
474 R_API_END();
475 Rf_unprotect(1);
476 return ret;
477}
478
479XGB_DLL SEXP XGDMatrixCreateFromCSR_R(SEXP indptr, SEXP indices, SEXP data, SEXP num_col,
480 SEXP missing, SEXP n_threads) {

Callers

nothing calls this directly

Calls 4

CreateFromSparseFunction · 0.85
AddMissingToJsonFunction · 0.85
XGDMatrixCreateFromCSCFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected