| 443 | } // namespace |
| 444 | |
| 445 | XGB_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 | |
| 479 | XGB_DLL SEXP XGDMatrixCreateFromCSR_R(SEXP indptr, SEXP indices, SEXP data, SEXP num_col, |
| 480 | SEXP missing, SEXP n_threads) { |
nothing calls this directly
no test coverage detected