From aedfdd0d1e4ac570b539d17d74de1610acd099df Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 3 May 2021 11:10:37 -0500 Subject: [PATCH] [R-package] use R standard routine to access read-only ints passed to C++ (#4246) * [R-package] replace R_AS_INT with R built-in * update header * more changes * Apply suggestions from code review Co-authored-by: Nikita Titov Co-authored-by: Nikita Titov --- R-package/src/R_object_helper.h | 2 - R-package/src/lightgbm_R.cpp | 162 ++++++++++++++++---------------- R-package/src/lightgbm_R.h | 108 ++++++++++----------- 3 files changed, 136 insertions(+), 136 deletions(-) diff --git a/R-package/src/R_object_helper.h b/R-package/src/R_object_helper.h index a51927baf428..0d51902da1dd 100644 --- a/R-package/src/R_object_helper.h +++ b/R-package/src/R_object_helper.h @@ -102,8 +102,6 @@ typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN; #define R_REAL_PTR(x) (reinterpret_cast DATAPTR(x)) -#define R_AS_INT(x) (*(reinterpret_cast DATAPTR(x))) - #define R_IS_NULL(x) ((*reinterpret_cast(x)).sxpinfo.type == 0) // 64bit pointer diff --git a/R-package/src/lightgbm_R.cpp b/R-package/src/lightgbm_R.cpp index 3bffdc40dda7..4d4adb84be3b 100644 --- a/R-package/src/lightgbm_R.cpp +++ b/R-package/src/lightgbm_R.cpp @@ -43,12 +43,12 @@ using LightGBM::Common::Join; using LightGBM::Common::Split; using LightGBM::Log; -LGBM_SE EncodeChar(LGBM_SE dest, const char* src, LGBM_SE buf_len, LGBM_SE actual_len, size_t str_len) { +LGBM_SE EncodeChar(LGBM_SE dest, const char* src, SEXP buf_len, LGBM_SE actual_len, size_t str_len) { if (str_len > INT32_MAX) { Log::Fatal("Don't support large string in R-package"); } R_INT_PTR(actual_len)[0] = static_cast(str_len); - if (R_AS_INT(buf_len) < static_cast(str_len)) { + if (Rf_asInteger(buf_len) < static_cast(str_len)) { return dest; } auto ptr = R_CHAR_PTR(dest); @@ -79,9 +79,9 @@ SEXP LGBM_DatasetCreateFromFile_R(LGBM_SE filename, SEXP LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr, LGBM_SE indices, LGBM_SE data, - LGBM_SE num_indptr, - LGBM_SE nelem, - LGBM_SE num_row, + SEXP num_indptr, + SEXP nelem, + SEXP num_row, LGBM_SE parameters, LGBM_SE reference, LGBM_SE out) { @@ -90,9 +90,9 @@ SEXP LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr, const int* p_indices = R_INT_PTR(indices); const double* p_data = R_REAL_PTR(data); - int64_t nindptr = static_cast(R_AS_INT(num_indptr)); - int64_t ndata = static_cast(R_AS_INT(nelem)); - int64_t nrow = static_cast(R_AS_INT(num_row)); + int64_t nindptr = static_cast(Rf_asInteger(num_indptr)); + int64_t ndata = static_cast(Rf_asInteger(nelem)); + int64_t nrow = static_cast(Rf_asInteger(num_row)); DatasetHandle handle = nullptr; CHECK_CALL(LGBM_DatasetCreateFromCSC(p_indptr, C_API_DTYPE_INT32, p_indices, p_data, C_API_DTYPE_FLOAT64, nindptr, ndata, @@ -102,14 +102,14 @@ SEXP LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr, } SEXP LGBM_DatasetCreateFromMat_R(LGBM_SE data, - LGBM_SE num_row, - LGBM_SE num_col, + SEXP num_row, + SEXP num_col, LGBM_SE parameters, LGBM_SE reference, LGBM_SE out) { R_API_BEGIN(); - int32_t nrow = static_cast(R_AS_INT(num_row)); - int32_t ncol = static_cast(R_AS_INT(num_col)); + int32_t nrow = static_cast(Rf_asInteger(num_row)); + int32_t ncol = static_cast(Rf_asInteger(num_col)); double* p_mat = R_REAL_PTR(data); DatasetHandle handle = nullptr; CHECK_CALL(LGBM_DatasetCreateFromMat(p_mat, C_API_DTYPE_FLOAT64, nrow, ncol, COL_MAJOR, @@ -120,11 +120,11 @@ SEXP LGBM_DatasetCreateFromMat_R(LGBM_SE data, SEXP LGBM_DatasetGetSubset_R(LGBM_SE handle, LGBM_SE used_row_indices, - LGBM_SE len_used_row_indices, + SEXP len_used_row_indices, LGBM_SE parameters, LGBM_SE out) { R_API_BEGIN(); - int len = R_AS_INT(len_used_row_indices); + int len = Rf_asInteger(len_used_row_indices); std::vector idxvec(len); // convert from one-based to zero-based index #pragma omp parallel for schedule(static, 512) if (len >= 1024) @@ -154,7 +154,7 @@ SEXP LGBM_DatasetSetFeatureNames_R(LGBM_SE handle, } SEXP LGBM_DatasetGetFeatureNames_R(LGBM_SE handle, - LGBM_SE buf_len, + SEXP buf_len, LGBM_SE actual_len, LGBM_SE feature_names) { R_API_BEGIN(); @@ -202,9 +202,9 @@ SEXP LGBM_DatasetFree_R(LGBM_SE handle) { SEXP LGBM_DatasetSetField_R(LGBM_SE handle, LGBM_SE field_name, LGBM_SE field_data, - LGBM_SE num_element) { + SEXP num_element) { R_API_BEGIN(); - int len = static_cast(R_AS_INT(num_element)); + int len = static_cast(Rf_asInteger(num_element)); const char* name = R_CHAR_PTR(field_name); if (!strcmp("group", name) || !strcmp("query", name)) { std::vector vec(len); @@ -387,10 +387,10 @@ SEXP LGBM_BoosterUpdateOneIter_R(LGBM_SE handle) { SEXP LGBM_BoosterUpdateOneIterCustom_R(LGBM_SE handle, LGBM_SE grad, LGBM_SE hess, - LGBM_SE len) { + SEXP len) { int is_finished = 0; R_API_BEGIN(); - int int_len = R_AS_INT(len); + int int_len = Rf_asInteger(len); std::vector tgrad(int_len), thess(int_len); #pragma omp parallel for schedule(static, 512) if (int_len >= 1024) for (int j = 0; j < int_len; ++j) { @@ -433,7 +433,7 @@ SEXP LGBM_BoosterGetLowerBoundValue_R(LGBM_SE handle, } SEXP LGBM_BoosterGetEvalNames_R(LGBM_SE handle, - LGBM_SE buf_len, + SEXP buf_len, LGBM_SE actual_len, LGBM_SE eval_names) { R_API_BEGIN(); @@ -464,47 +464,47 @@ SEXP LGBM_BoosterGetEvalNames_R(LGBM_SE handle, } SEXP LGBM_BoosterGetEval_R(LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out_result) { R_API_BEGIN(); int len; CHECK_CALL(LGBM_BoosterGetEvalCounts(R_GET_PTR(handle), &len)); double* ptr_ret = R_REAL_PTR(out_result); int out_len; - CHECK_CALL(LGBM_BoosterGetEval(R_GET_PTR(handle), R_AS_INT(data_idx), &out_len, ptr_ret)); + CHECK_CALL(LGBM_BoosterGetEval(R_GET_PTR(handle), Rf_asInteger(data_idx), &out_len, ptr_ret)); CHECK_EQ(out_len, len); R_API_END(); } SEXP LGBM_BoosterGetNumPredict_R(LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out) { R_API_BEGIN(); int64_t len; - CHECK_CALL(LGBM_BoosterGetNumPredict(R_GET_PTR(handle), R_AS_INT(data_idx), &len)); + CHECK_CALL(LGBM_BoosterGetNumPredict(R_GET_PTR(handle), Rf_asInteger(data_idx), &len)); R_INT_PTR(out)[0] = static_cast(len); R_API_END(); } SEXP LGBM_BoosterGetPredict_R(LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out_result) { R_API_BEGIN(); double* ptr_ret = R_REAL_PTR(out_result); int64_t out_len; - CHECK_CALL(LGBM_BoosterGetPredict(R_GET_PTR(handle), R_AS_INT(data_idx), &out_len, ptr_ret)); + CHECK_CALL(LGBM_BoosterGetPredict(R_GET_PTR(handle), Rf_asInteger(data_idx), &out_len, ptr_ret)); R_API_END(); } -int GetPredictType(LGBM_SE is_rawscore, LGBM_SE is_leafidx, LGBM_SE is_predcontrib) { +int GetPredictType(SEXP is_rawscore, SEXP is_leafidx, SEXP is_predcontrib) { int pred_type = C_API_PREDICT_NORMAL; - if (R_AS_INT(is_rawscore)) { + if (Rf_asInteger(is_rawscore)) { pred_type = C_API_PREDICT_RAW_SCORE; } - if (R_AS_INT(is_leafidx)) { + if (Rf_asInteger(is_leafidx)) { pred_type = C_API_PREDICT_LEAF_INDEX; } - if (R_AS_INT(is_predcontrib)) { + if (Rf_asInteger(is_predcontrib)) { pred_type = C_API_PREDICT_CONTRIB; } return pred_type; @@ -512,35 +512,35 @@ int GetPredictType(LGBM_SE is_rawscore, LGBM_SE is_leafidx, LGBM_SE is_predcontr SEXP LGBM_BoosterPredictForFile_R(LGBM_SE handle, LGBM_SE data_filename, - LGBM_SE data_has_header, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP data_has_header, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE result_filename) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); CHECK_CALL(LGBM_BoosterPredictForFile(R_GET_PTR(handle), R_CHAR_PTR(data_filename), - R_AS_INT(data_has_header), pred_type, R_AS_INT(start_iteration), R_AS_INT(num_iteration), R_CHAR_PTR(parameter), + Rf_asInteger(data_has_header), pred_type, Rf_asInteger(start_iteration), Rf_asInteger(num_iteration), R_CHAR_PTR(parameter), R_CHAR_PTR(result_filename))); R_API_END(); } SEXP LGBM_BoosterCalcNumPredict_R(LGBM_SE handle, - LGBM_SE num_row, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_row, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE out_len) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); int64_t len = 0; - CHECK_CALL(LGBM_BoosterCalcNumPredict(R_GET_PTR(handle), R_AS_INT(num_row), - pred_type, R_AS_INT(start_iteration), R_AS_INT(num_iteration), &len)); + CHECK_CALL(LGBM_BoosterCalcNumPredict(R_GET_PTR(handle), Rf_asInteger(num_row), + pred_type, Rf_asInteger(start_iteration), Rf_asInteger(num_iteration), &len)); R_INT_PTR(out_len)[0] = static_cast(len); R_API_END(); } @@ -549,14 +549,14 @@ SEXP LGBM_BoosterPredictForCSC_R(LGBM_SE handle, LGBM_SE indptr, LGBM_SE indices, LGBM_SE data, - LGBM_SE num_indptr, - LGBM_SE nelem, - LGBM_SE num_row, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_indptr, + SEXP nelem, + SEXP num_row, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE out_result) { R_API_BEGIN(); @@ -566,78 +566,80 @@ SEXP LGBM_BoosterPredictForCSC_R(LGBM_SE handle, const int* p_indices = R_INT_PTR(indices); const double* p_data = R_REAL_PTR(data); - int64_t nindptr = R_AS_INT(num_indptr); - int64_t ndata = R_AS_INT(nelem); - int64_t nrow = R_AS_INT(num_row); + int64_t nindptr = Rf_asInteger(num_indptr); + int64_t ndata = Rf_asInteger(nelem); + int64_t nrow = Rf_asInteger(num_row); double* ptr_ret = R_REAL_PTR(out_result); int64_t out_len; CHECK_CALL(LGBM_BoosterPredictForCSC(R_GET_PTR(handle), p_indptr, C_API_DTYPE_INT32, p_indices, p_data, C_API_DTYPE_FLOAT64, nindptr, ndata, - nrow, pred_type, R_AS_INT(start_iteration), R_AS_INT(num_iteration), R_CHAR_PTR(parameter), &out_len, ptr_ret)); + nrow, pred_type, Rf_asInteger(start_iteration), Rf_asInteger(num_iteration), R_CHAR_PTR(parameter), &out_len, ptr_ret)); R_API_END(); } SEXP LGBM_BoosterPredictForMat_R(LGBM_SE handle, LGBM_SE data, - LGBM_SE num_row, - LGBM_SE num_col, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_row, + SEXP num_col, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE out_result) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); - int32_t nrow = R_AS_INT(num_row); - int32_t ncol = R_AS_INT(num_col); + int32_t nrow = Rf_asInteger(num_row); + int32_t ncol = Rf_asInteger(num_col); const double* p_mat = R_REAL_PTR(data); double* ptr_ret = R_REAL_PTR(out_result); int64_t out_len; CHECK_CALL(LGBM_BoosterPredictForMat(R_GET_PTR(handle), p_mat, C_API_DTYPE_FLOAT64, nrow, ncol, COL_MAJOR, - pred_type, R_AS_INT(start_iteration), R_AS_INT(num_iteration), R_CHAR_PTR(parameter), &out_len, ptr_ret)); + pred_type, Rf_asInteger(start_iteration), Rf_asInteger(num_iteration), R_CHAR_PTR(parameter), &out_len, ptr_ret)); R_API_END(); } SEXP LGBM_BoosterSaveModel_R(LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, + SEXP num_iteration, + SEXP feature_importance_type, LGBM_SE filename) { R_API_BEGIN(); - CHECK_CALL(LGBM_BoosterSaveModel(R_GET_PTR(handle), 0, R_AS_INT(num_iteration), R_AS_INT(feature_importance_type), R_CHAR_PTR(filename))); + CHECK_CALL(LGBM_BoosterSaveModel(R_GET_PTR(handle), 0, Rf_asInteger(num_iteration), Rf_asInteger(feature_importance_type), R_CHAR_PTR(filename))); R_API_END(); } SEXP LGBM_BoosterSaveModelToString_R(LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, - LGBM_SE buffer_len, + SEXP num_iteration, + SEXP feature_importance_type, + SEXP buffer_len, LGBM_SE actual_len, LGBM_SE out_str) { R_API_BEGIN(); int64_t out_len = 0; - std::vector inner_char_buf(R_AS_INT(buffer_len)); - CHECK_CALL(LGBM_BoosterSaveModelToString(R_GET_PTR(handle), 0, R_AS_INT(num_iteration), R_AS_INT(feature_importance_type), R_AS_INT(buffer_len), &out_len, inner_char_buf.data())); + int64_t buf_len = static_cast(Rf_asInteger(buffer_len)); + std::vector inner_char_buf(buf_len); + CHECK_CALL(LGBM_BoosterSaveModelToString(R_GET_PTR(handle), 0, Rf_asInteger(num_iteration), Rf_asInteger(feature_importance_type), buf_len, &out_len, inner_char_buf.data())); EncodeChar(out_str, inner_char_buf.data(), buffer_len, actual_len, static_cast(out_len)); R_API_END(); } SEXP LGBM_BoosterDumpModel_R(LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, - LGBM_SE buffer_len, + SEXP num_iteration, + SEXP feature_importance_type, + SEXP buffer_len, LGBM_SE actual_len, LGBM_SE out_str) { R_API_BEGIN(); int64_t out_len = 0; - std::vector inner_char_buf(R_AS_INT(buffer_len)); - CHECK_CALL(LGBM_BoosterDumpModel(R_GET_PTR(handle), 0, R_AS_INT(num_iteration), R_AS_INT(feature_importance_type), R_AS_INT(buffer_len), &out_len, inner_char_buf.data())); + int64_t buf_len = static_cast(Rf_asInteger(buffer_len)); + std::vector inner_char_buf(buf_len); + CHECK_CALL(LGBM_BoosterDumpModel(R_GET_PTR(handle), 0, Rf_asInteger(num_iteration), Rf_asInteger(feature_importance_type), buf_len, &out_len, inner_char_buf.data())); EncodeChar(out_str, inner_char_buf.data(), buffer_len, actual_len, static_cast(out_len)); R_API_END(); } diff --git a/R-package/src/lightgbm_R.h b/R-package/src/lightgbm_R.h index c262c3172ca4..5ef54385f256 100644 --- a/R-package/src/lightgbm_R.h +++ b/R-package/src/lightgbm_R.h @@ -44,7 +44,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( * \param indptr pointer to row headers * \param indices findex * \param data fvalue -* \param nindptr number of cols in the matrix + 1 +* \param num_indptr number of cols in the matrix + 1 * \param nelem number of nonzero elements in the matrix * \param num_row number of rows * \param parameters additional parameters @@ -56,9 +56,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( LGBM_SE indptr, LGBM_SE indices, LGBM_SE data, - LGBM_SE nindptr, - LGBM_SE nelem, - LGBM_SE num_row, + SEXP num_indptr, + SEXP nelem, + SEXP num_row, LGBM_SE parameters, LGBM_SE reference, LGBM_SE out @@ -67,8 +67,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( /*! * \brief create dataset from dense matrix * \param data matric data -* \param nrow number of rows -* \param ncol number columns +* \param num_row number of rows +* \param num_col number columns * \param parameters additional parameters * \param reference used to align bin mapper with other dataset, nullptr means not used * \param out created dataset @@ -76,8 +76,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( LGBM_SE data, - LGBM_SE nrow, - LGBM_SE ncol, + SEXP num_row, + SEXP num_col, LGBM_SE parameters, LGBM_SE reference, LGBM_SE out @@ -95,7 +95,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R( LGBM_SE handle, LGBM_SE used_row_indices, - LGBM_SE len_used_row_indices, + SEXP len_used_row_indices, LGBM_SE parameters, LGBM_SE out ); @@ -119,7 +119,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R( LGBM_SE handle, - LGBM_SE buf_len, + SEXP buf_len, LGBM_SE actual_len, LGBM_SE feature_names ); @@ -158,7 +158,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R( LGBM_SE handle, LGBM_SE field_name, LGBM_SE field_data, - LGBM_SE num_element + SEXP num_element ); /*! @@ -343,7 +343,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R( LGBM_SE handle, LGBM_SE grad, LGBM_SE hess, - LGBM_SE len + SEXP len ); /*! @@ -394,7 +394,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R( LGBM_SE handle, - LGBM_SE buf_len, + SEXP buf_len, LGBM_SE actual_len, LGBM_SE eval_names ); @@ -408,7 +408,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out_result ); @@ -421,7 +421,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out ); @@ -435,7 +435,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( LGBM_SE handle, - LGBM_SE data_idx, + SEXP data_idx, LGBM_SE out_result ); @@ -453,12 +453,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( LGBM_SE handle, LGBM_SE data_filename, - LGBM_SE data_has_header, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP data_has_header, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE result_filename ); @@ -475,12 +475,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( LGBM_SE handle, - LGBM_SE num_row, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_row, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE out_len ); @@ -493,7 +493,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( * \param indptr pointer to row headers * \param indices findex * \param data fvalue -* \param nindptr number of cols in the matrix + 1 +* \param num_indptr number of cols in the matrix + 1 * \param nelem number of non-zero elements in the matrix * \param num_row number of rows * \param is_rawscore @@ -507,14 +507,14 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( LGBM_SE indptr, LGBM_SE indices, LGBM_SE data, - LGBM_SE nindptr, - LGBM_SE nelem, - LGBM_SE num_row, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_indptr, + SEXP nelem, + SEXP num_row, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE out_result ); @@ -526,8 +526,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( * for leaf index, its length is equal to num_class * num_data * num_iteration * \param handle handle * \param data pointer to the data space -* \param nrow number of rows -* \param ncol number columns +* \param num_row number of rows +* \param num_col number columns * \param is_rawscore * \param is_leafidx * \param num_iteration number of iteration for prediction, <= 0 means no limit @@ -537,13 +537,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( LGBM_SE handle, LGBM_SE data, - LGBM_SE nrow, - LGBM_SE ncol, - LGBM_SE is_rawscore, - LGBM_SE is_leafidx, - LGBM_SE is_predcontrib, - LGBM_SE start_iteration, - LGBM_SE num_iteration, + SEXP num_row, + SEXP num_col, + SEXP is_rawscore, + SEXP is_leafidx, + SEXP is_predcontrib, + SEXP start_iteration, + SEXP num_iteration, LGBM_SE parameter, LGBM_SE out_result ); @@ -557,8 +557,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R( LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, + SEXP num_iteration, + SEXP feature_importance_type, LGBM_SE filename ); @@ -571,9 +571,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R( LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, - LGBM_SE buffer_len, + SEXP num_iteration, + SEXP feature_importance_type, + SEXP buffer_len, LGBM_SE actual_len, LGBM_SE out_str ); @@ -587,9 +587,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R( */ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R( LGBM_SE handle, - LGBM_SE num_iteration, - LGBM_SE feature_importance_type, - LGBM_SE buffer_len, + SEXP num_iteration, + SEXP feature_importance_type, + SEXP buffer_len, LGBM_SE actual_len, LGBM_SE out_str );