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

Function XGDMatrixCreateFromCSR_R

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

Source from the content-addressed store, hash-verified

477}
478
479XGB_DLL SEXP XGDMatrixCreateFromCSR_R(SEXP indptr, SEXP indices, SEXP data, SEXP num_col,
480 SEXP missing, SEXP n_threads) {
481 SEXP ret = Rf_protect(R_MakeExternalPtr(nullptr, R_NilValue, R_NilValue));
482 R_API_BEGIN();
483 std::int32_t threads = Rf_asInteger(n_threads);
484 DMatrixHandle handle;
485
486 int res_code;
487 {
488 using xgboost::Integer;
489 using xgboost::Json;
490 using xgboost::Object;
491
492 std::string sindptr, sindices, sdata;
493 CreateFromSparse(indptr, indices, data, &sindptr, &sindices, &sdata);
494 auto ncol = static_cast<std::size_t>(INTEGER(num_col)[0]);
495
496 Json jconfig{Object{}};
497 // Construct configuration
498 jconfig["nthread"] = Integer{threads};
499 AddMissingToJson(&jconfig, missing, TYPEOF(data));
500 std::string config;
501 Json::Dump(jconfig, &config);
502 res_code = XGDMatrixCreateFromCSR(sindptr.c_str(), sindices.c_str(), sdata.c_str(), ncol,
503 config.c_str(), &handle);
504 }
505 CHECK_CALL(res_code);
506 R_SetExternalPtrAddr(ret, handle);
507 R_RegisterCFinalizerEx(ret, _DMatrixFinalizer, TRUE);
508 R_API_END();
509 Rf_unprotect(1);
510 return ret;
511}
512
513XGB_DLL SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset, SEXP allow_groups) {
514 SEXP ret = Rf_protect(R_MakeExternalPtr(nullptr, R_NilValue, R_NilValue));

Callers

nothing calls this directly

Calls 4

CreateFromSparseFunction · 0.85
AddMissingToJsonFunction · 0.85
XGDMatrixCreateFromCSRFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected