From 527f755af78e05d6c3dbbbfae01b68a7ed632e02 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 12 Mar 2020 23:15:48 -0500 Subject: [PATCH] reverted SEXP stuff --- include/LightGBM/R_object_helper.h | 8 +- include/LightGBM/lightgbm_R.h | 456 ++++++++++++++--------------- src/lightgbm_R.cpp | 372 +++++++++++------------ 3 files changed, 418 insertions(+), 418 deletions(-) diff --git a/include/LightGBM/R_object_helper.h b/include/LightGBM/R_object_helper.h index 20efc1ed1a58..a5e9c5d61604 100644 --- a/include/LightGBM/R_object_helper.h +++ b/include/LightGBM/R_object_helper.h @@ -151,7 +151,7 @@ typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN; #define R_ADDR(x) (reinterpret_cast DATAPTR(x)) - inline void R_SET_PTR(SEXP x, void* ptr) { + inline void R_SET_PTR(LGBM_SE x, void* ptr) { if (ptr == nullptr) { R_ADDR(x)[0] = (int64_t)(NULL); } else { @@ -159,7 +159,7 @@ typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN; } } - inline void* R_GET_PTR(SEXP x) { + inline void* R_GET_PTR(LGBM_SE x) { if (R_IS_NULL(x)) { return nullptr; } else { @@ -175,7 +175,7 @@ typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN; #define R_ADDR(x) (reinterpret_cast DATAPTR(x)) - inline void R_SET_PTR(SEXP x, void* ptr) { + inline void R_SET_PTR(LGBM_SE x, void* ptr) { if (ptr == nullptr) { R_ADDR(x)[0] = (int32_t)(NULL); } else { @@ -183,7 +183,7 @@ typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN; } } - inline void* R_GET_PTR(SEXP x) { + inline void* R_GET_PTR(LGBM_SE x) { if (R_IS_NULL(x)) { return nullptr; } else { diff --git a/include/LightGBM/lightgbm_R.h b/include/LightGBM/lightgbm_R.h index 02c9490770c6..2ac05384d87e 100644 --- a/include/LightGBM/lightgbm_R.h +++ b/include/LightGBM/lightgbm_R.h @@ -19,10 +19,10 @@ * \return err_msg error information * \return error information */ -LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R( - SEXP buf_len, - SEXP actual_len, - SEXP err_msg +LIGHTGBM_C_EXPORT LGBM_SE LGBM_GetLastError_R( + LGBM_SE buf_len, + LGBM_SE actual_len, + LGBM_SE err_msg ); // --- start Dataset interface @@ -35,12 +35,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R( * \param out created dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( - SEXP filename, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromFile_R( + LGBM_SE filename, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -56,17 +56,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( * \param out created dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( - SEXP indptr, - SEXP indices, - SEXP data, - SEXP nindptr, - SEXP nelem, - SEXP num_row, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromCSC_R( + LGBM_SE indptr, + LGBM_SE indices, + LGBM_SE data, + LGBM_SE nindptr, + LGBM_SE nelem, + LGBM_SE num_row, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -79,14 +79,14 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( * \param out created dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( - SEXP data, - SEXP nrow, - SEXP ncol, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromMat_R( + LGBM_SE data, + LGBM_SE nrow, + LGBM_SE ncol, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -98,13 +98,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( * \param out created dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R( - SEXP handle, - SEXP used_row_indices, - SEXP len_used_row_indices, - SEXP parameters, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetSubset_R( + LGBM_SE handle, + LGBM_SE used_row_indices, + LGBM_SE len_used_row_indices, + LGBM_SE parameters, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -113,10 +113,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R( * \param feature_names feature names * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R( - SEXP handle, - SEXP feature_names, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSetFeatureNames_R( + LGBM_SE handle, + LGBM_SE feature_names, + LGBM_SE call_state ); /*! @@ -125,12 +125,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R( * \param feature_names feature names * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R( - SEXP handle, - SEXP buf_len, - SEXP actual_len, - SEXP feature_names, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetFeatureNames_R( + LGBM_SE handle, + LGBM_SE buf_len, + LGBM_SE actual_len, + LGBM_SE feature_names, + LGBM_SE call_state ); /*! @@ -139,10 +139,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R( * \param filename file name * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R( - SEXP handle, - SEXP filename, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSaveBinary_R( + LGBM_SE handle, + LGBM_SE filename, + LGBM_SE call_state ); /*! @@ -150,9 +150,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R( * \param handle an instance of dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R( - SEXP handle, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetFree_R( + LGBM_SE handle, + LGBM_SE call_state ); /*! @@ -165,12 +165,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R( * \param num_element number of element in field_data * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R( - SEXP handle, - SEXP field_name, - SEXP field_data, - SEXP num_element, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSetField_R( + LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE field_data, + LGBM_SE num_element, + LGBM_SE call_state ); /*! @@ -180,11 +180,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R( * \param out size of info vector from dataset * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R( - SEXP handle, - SEXP field_name, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetFieldSize_R( + LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -194,11 +194,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R( * \param field_data pointer to vector * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R( - SEXP handle, - SEXP field_name, - SEXP field_data, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetField_R( + LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE field_data, + LGBM_SE call_state ); /*! @@ -207,10 +207,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R( * \param new_params New dataset parameters * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R( - SEXP old_params, - SEXP new_params, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetUpdateParamChecking_R( + LGBM_SE old_params, + LGBM_SE new_params, + LGBM_SE call_state ); /*! @@ -219,10 +219,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R( * \param out The address to hold number of data * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R( - SEXP handle, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumData_R( + LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -231,10 +231,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R( * \param out The output of number of features * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R( - SEXP handle, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumFeature_R( + LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state ); // --- start Booster interfaces @@ -246,11 +246,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R( * \param out handle of created Booster * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R( - SEXP train_data, - SEXP parameters, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreate_R( + LGBM_SE train_data, + LGBM_SE parameters, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -258,9 +258,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R( * \param handle handle to be freed * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R( - SEXP handle, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterFree_R( + LGBM_SE handle, + LGBM_SE call_state ); /*! @@ -269,10 +269,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R( * \param out handle of created Booster * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R( - SEXP filename, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreateFromModelfile_R( + LGBM_SE filename, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -281,10 +281,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R( * \param out handle of created Booster * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R( - SEXP model_str, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterLoadModelFromString_R( + LGBM_SE model_str, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -293,10 +293,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R( * \param other_handle * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R( - SEXP handle, - SEXP other_handle, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterMerge_R( + LGBM_SE handle, + LGBM_SE other_handle, + LGBM_SE call_state ); /*! @@ -305,10 +305,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R( * \param valid_data validation data set * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R( - SEXP handle, - SEXP valid_data, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterAddValidData_R( + LGBM_SE handle, + LGBM_SE valid_data, + LGBM_SE call_state ); /*! @@ -317,10 +317,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R( * \param train_data training data set * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R( - SEXP handle, - SEXP train_data, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetTrainingData_R( + LGBM_SE handle, + LGBM_SE train_data, + LGBM_SE call_state ); /*! @@ -329,10 +329,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R( * \param parameters format: 'key1=value1 key2=value2' * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R( - SEXP handle, - SEXP parameters, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetParameter_R( + LGBM_SE handle, + LGBM_SE parameters, + LGBM_SE call_state ); /*! @@ -341,10 +341,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R( * \param out number of classes * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R( - SEXP handle, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumClasses_R( + LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -352,9 +352,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R( * \param handle handle * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R( - SEXP handle, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIter_R( + LGBM_SE handle, + LGBM_SE call_state ); /*! @@ -366,12 +366,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R( * \param len length of grad/hess * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R( - SEXP handle, - SEXP grad, - SEXP hess, - SEXP len, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIterCustom_R( + LGBM_SE handle, + LGBM_SE grad, + LGBM_SE hess, + LGBM_SE len, + LGBM_SE call_state ); /*! @@ -379,9 +379,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R( * \param handle handle * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R( - SEXP handle, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterRollbackOneIter_R( + LGBM_SE handle, + LGBM_SE call_state ); /*! @@ -389,10 +389,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R( * \param out iteration of boosting rounds * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R( - SEXP handle, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetCurrentIteration_R( + LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -401,10 +401,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R( * \param[out] out_results Result pointing to max value * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R( - SEXP handle, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetUpperBoundValue_R( + LGBM_SE handle, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -413,10 +413,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R( * \param[out] out_results Result pointing to min value * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R( - SEXP handle, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetLowerBoundValue_R( + LGBM_SE handle, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -424,12 +424,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R( * \param eval_names eval names * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R( - SEXP handle, - SEXP buf_len, - SEXP actual_len, - SEXP eval_names, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetEvalNames_R( + LGBM_SE handle, + LGBM_SE buf_len, + LGBM_SE actual_len, + LGBM_SE eval_names, + LGBM_SE call_state ); /*! @@ -439,11 +439,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R( * \param out_result float array contains result * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( - SEXP handle, - SEXP data_idx, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetEval_R( + LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -453,11 +453,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( * \param out size of predict * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( - SEXP handle, - SEXP data_idx, - SEXP out, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumPredict_R( + LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out, + LGBM_SE call_state ); /*! @@ -468,11 +468,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( * \param out_result, used to store predict result, should pre-allocate memory * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( - SEXP handle, - SEXP data_idx, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetPredict_R( + LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -486,17 +486,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( * \return 0 when succeed, -1 when failure happens * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( - SEXP handle, - SEXP data_filename, - SEXP data_has_header, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP result_filename, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE 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 num_iteration, + LGBM_SE parameter, + LGBM_SE result_filename, + LGBM_SE call_state ); /*! @@ -509,15 +509,15 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( * \param out_len length of prediction * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( - SEXP handle, - SEXP num_row, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP out_len, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCalcNumPredict_R( + LGBM_SE handle, + LGBM_SE num_row, + LGBM_SE is_rawscore, + LGBM_SE is_leafidx, + LGBM_SE is_predcontrib, + LGBM_SE num_iteration, + LGBM_SE out_len, + LGBM_SE call_state ); /*! @@ -538,21 +538,21 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( * \param out prediction result * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( - SEXP handle, - SEXP indptr, - SEXP indices, - SEXP data, - SEXP nindptr, - SEXP nelem, - SEXP num_row, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterPredictForCSC_R( + LGBM_SE handle, + 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 num_iteration, + LGBM_SE parameter, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -570,18 +570,18 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( * \param out prediction result * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( - SEXP handle, - SEXP data, - SEXP nrow, - SEXP ncol, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP out_result, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE 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 num_iteration, + LGBM_SE parameter, + LGBM_SE out_result, + LGBM_SE call_state ); /*! @@ -591,11 +591,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( * \param filename file name * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R( - SEXP handle, - SEXP num_iteration, - SEXP filename, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterSaveModel_R( + LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE filename, + LGBM_SE call_state ); /*! @@ -605,13 +605,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R( * \param out_str string of model * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R( - SEXP handle, - SEXP num_iteration, - SEXP buffer_len, - SEXP actual_len, - SEXP out_str, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterSaveModelToString_R( + LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE buffer_len, + LGBM_SE actual_len, + LGBM_SE out_str, + LGBM_SE call_state ); /*! @@ -621,13 +621,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R( * \param out_str json format string of model * \return 0 when succeed, -1 when failure happens */ -LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R( - SEXP handle, - SEXP num_iteration, - SEXP buffer_len, - SEXP actual_len, - SEXP out_str, - SEXP call_state +LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterDumpModel_R( + LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE buffer_len, + LGBM_SE actual_len, + LGBM_SE out_str, + LGBM_SE call_state ); #endif // LIGHTGBM_R_H_ diff --git a/src/lightgbm_R.cpp b/src/lightgbm_R.cpp index c292a93dc3c9..7d3a8dcafe80 100644 --- a/src/lightgbm_R.cpp +++ b/src/lightgbm_R.cpp @@ -38,7 +38,7 @@ using LightGBM::Common::Join; using LightGBM::Common::Split; using LightGBM::Log; -SEXP EncodeChar(SEXP dest, const char* src, SEXP buf_len, SEXP actual_len, size_t str_len) { +LGBM_SE EncodeChar(LGBM_SE dest, const char* src, LGBM_SE 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"); } @@ -51,15 +51,15 @@ SEXP EncodeChar(SEXP dest, const char* src, SEXP buf_len, SEXP actual_len, size_ return dest; } -SEXP LGBM_GetLastError_R(SEXP buf_len, SEXP actual_len, SEXP err_msg) { +LGBM_SE LGBM_GetLastError_R(LGBM_SE buf_len, LGBM_SE actual_len, LGBM_SE err_msg) { return EncodeChar(err_msg, LGBM_GetLastError(), buf_len, actual_len, std::strlen(LGBM_GetLastError()) + 1); } -SEXP LGBM_DatasetCreateFromFile_R(SEXP filename, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetCreateFromFile_R(LGBM_SE filename, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); DatasetHandle handle = nullptr; CHECK_CALL(LGBM_DatasetCreateFromFile(R_CHAR_PTR(filename), R_CHAR_PTR(parameters), @@ -68,16 +68,16 @@ SEXP LGBM_DatasetCreateFromFile_R(SEXP filename, R_API_END(); } -SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr, - SEXP indices, - SEXP data, - SEXP num_indptr, - SEXP nelem, - SEXP num_row, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr, + LGBM_SE indices, + LGBM_SE data, + LGBM_SE num_indptr, + LGBM_SE nelem, + LGBM_SE num_row, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); const int* p_indptr = R_INT_PTR(indptr); const int* p_indices = R_INT_PTR(indices); @@ -94,13 +94,13 @@ SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr, R_API_END(); } -SEXP LGBM_DatasetCreateFromMat_R(SEXP data, - SEXP num_row, - SEXP num_col, - SEXP parameters, - SEXP reference, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetCreateFromMat_R(LGBM_SE data, + LGBM_SE num_row, + LGBM_SE num_col, + LGBM_SE parameters, + LGBM_SE reference, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); int32_t nrow = static_cast(R_AS_INT(num_row)); int32_t ncol = static_cast(R_AS_INT(num_col)); @@ -112,12 +112,12 @@ SEXP LGBM_DatasetCreateFromMat_R(SEXP data, R_API_END(); } -SEXP LGBM_DatasetGetSubset_R(SEXP handle, - SEXP used_row_indices, - SEXP len_used_row_indices, - SEXP parameters, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetSubset_R(LGBM_SE handle, + LGBM_SE used_row_indices, + LGBM_SE len_used_row_indices, + LGBM_SE parameters, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); int len = R_AS_INT(len_used_row_indices); std::vector idxvec(len); @@ -134,9 +134,9 @@ SEXP LGBM_DatasetGetSubset_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle, - SEXP feature_names, - SEXP call_state) { +LGBM_SE LGBM_DatasetSetFeatureNames_R(LGBM_SE handle, + LGBM_SE feature_names, + LGBM_SE call_state) { R_API_BEGIN(); auto vec_names = Split(R_CHAR_PTR(feature_names), '\t'); std::vector vec_sptr; @@ -149,11 +149,11 @@ SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle, - SEXP buf_len, - SEXP actual_len, - SEXP feature_names, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetFeatureNames_R(LGBM_SE handle, + LGBM_SE buf_len, + LGBM_SE actual_len, + LGBM_SE feature_names, + LGBM_SE call_state) { R_API_BEGIN(); int len = 0; CHECK_CALL(LGBM_DatasetGetNumFeature(R_GET_PTR(handle), &len)); @@ -172,17 +172,17 @@ SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetSaveBinary_R(SEXP handle, - SEXP filename, - SEXP call_state) { +LGBM_SE LGBM_DatasetSaveBinary_R(LGBM_SE handle, + LGBM_SE filename, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_DatasetSaveBinary(R_GET_PTR(handle), R_CHAR_PTR(filename))); R_API_END(); } -SEXP LGBM_DatasetFree_R(SEXP handle, - SEXP call_state) { +LGBM_SE LGBM_DatasetFree_R(LGBM_SE handle, + LGBM_SE call_state) { R_API_BEGIN(); if (R_GET_PTR(handle) != nullptr) { CHECK_CALL(LGBM_DatasetFree(R_GET_PTR(handle))); @@ -191,11 +191,11 @@ SEXP LGBM_DatasetFree_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetSetField_R(SEXP handle, - SEXP field_name, - SEXP field_data, - SEXP num_element, - SEXP call_state) { +LGBM_SE LGBM_DatasetSetField_R(LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE field_data, + LGBM_SE num_element, + LGBM_SE call_state) { R_API_BEGIN(); int len = static_cast(R_AS_INT(num_element)); const char* name = R_CHAR_PTR(field_name); @@ -219,10 +219,10 @@ SEXP LGBM_DatasetSetField_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetGetField_R(SEXP handle, - SEXP field_name, - SEXP field_data, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetField_R(LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE field_data, + LGBM_SE call_state) { R_API_BEGIN(); const char* name = R_CHAR_PTR(field_name); int out_len = 0; @@ -253,10 +253,10 @@ SEXP LGBM_DatasetGetField_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetGetFieldSize_R(SEXP handle, - SEXP field_name, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetFieldSize_R(LGBM_SE handle, + LGBM_SE field_name, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); const char* name = R_CHAR_PTR(field_name); int out_len = 0; @@ -270,16 +270,16 @@ SEXP LGBM_DatasetGetFieldSize_R(SEXP handle, R_API_END(); } -SEXP LGBM_DatasetUpdateParamChecking_R(SEXP old_params, - SEXP new_params, - SEXP call_state) { +LGBM_SE LGBM_DatasetUpdateParamChecking_R(LGBM_SE old_params, + LGBM_SE new_params, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_DatasetUpdateParamChecking(R_CHAR_PTR(old_params), R_CHAR_PTR(new_params))); R_API_END(); } -SEXP LGBM_DatasetGetNumData_R(SEXP handle, SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetNumData_R(LGBM_SE handle, LGBM_SE out, + LGBM_SE call_state) { int nrow; R_API_BEGIN(); CHECK_CALL(LGBM_DatasetGetNumData(R_GET_PTR(handle), &nrow)); @@ -287,9 +287,9 @@ SEXP LGBM_DatasetGetNumData_R(SEXP handle, SEXP out, R_API_END(); } -SEXP LGBM_DatasetGetNumFeature_R(SEXP handle, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_DatasetGetNumFeature_R(LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state) { int nfeature; R_API_BEGIN(); CHECK_CALL(LGBM_DatasetGetNumFeature(R_GET_PTR(handle), &nfeature)); @@ -299,8 +299,8 @@ SEXP LGBM_DatasetGetNumFeature_R(SEXP handle, // --- start Booster interfaces -SEXP LGBM_BoosterFree_R(SEXP handle, - SEXP call_state) { +LGBM_SE LGBM_BoosterFree_R(LGBM_SE handle, + LGBM_SE call_state) { R_API_BEGIN(); if (R_GET_PTR(handle) != nullptr) { CHECK_CALL(LGBM_BoosterFree(R_GET_PTR(handle))); @@ -309,10 +309,10 @@ SEXP LGBM_BoosterFree_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterCreate_R(SEXP train_data, - SEXP parameters, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterCreate_R(LGBM_SE train_data, + LGBM_SE parameters, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); BoosterHandle handle = nullptr; CHECK_CALL(LGBM_BoosterCreate(R_GET_PTR(train_data), R_CHAR_PTR(parameters), &handle)); @@ -320,9 +320,9 @@ SEXP LGBM_BoosterCreate_R(SEXP train_data, R_API_END(); } -SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterCreateFromModelfile_R(LGBM_SE filename, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); int out_num_iterations = 0; BoosterHandle handle = nullptr; @@ -331,9 +331,9 @@ SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename, R_API_END(); } -SEXP LGBM_BoosterLoadModelFromString_R(SEXP model_str, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterLoadModelFromString_R(LGBM_SE model_str, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); int out_num_iterations = 0; BoosterHandle handle = nullptr; @@ -342,41 +342,41 @@ SEXP LGBM_BoosterLoadModelFromString_R(SEXP model_str, R_API_END(); } -SEXP LGBM_BoosterMerge_R(SEXP handle, - SEXP other_handle, - SEXP call_state) { +LGBM_SE LGBM_BoosterMerge_R(LGBM_SE handle, + LGBM_SE other_handle, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterMerge(R_GET_PTR(handle), R_GET_PTR(other_handle))); R_API_END(); } -SEXP LGBM_BoosterAddValidData_R(SEXP handle, - SEXP valid_data, - SEXP call_state) { +LGBM_SE LGBM_BoosterAddValidData_R(LGBM_SE handle, + LGBM_SE valid_data, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterAddValidData(R_GET_PTR(handle), R_GET_PTR(valid_data))); R_API_END(); } -SEXP LGBM_BoosterResetTrainingData_R(SEXP handle, - SEXP train_data, - SEXP call_state) { +LGBM_SE LGBM_BoosterResetTrainingData_R(LGBM_SE handle, + LGBM_SE train_data, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterResetTrainingData(R_GET_PTR(handle), R_GET_PTR(train_data))); R_API_END(); } -SEXP LGBM_BoosterResetParameter_R(SEXP handle, - SEXP parameters, - SEXP call_state) { +LGBM_SE LGBM_BoosterResetParameter_R(LGBM_SE handle, + LGBM_SE parameters, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterResetParameter(R_GET_PTR(handle), R_CHAR_PTR(parameters))); R_API_END(); } -SEXP LGBM_BoosterGetNumClasses_R(SEXP handle, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetNumClasses_R(LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state) { int num_class; R_API_BEGIN(); CHECK_CALL(LGBM_BoosterGetNumClasses(R_GET_PTR(handle), &num_class)); @@ -384,19 +384,19 @@ SEXP LGBM_BoosterGetNumClasses_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterUpdateOneIter_R(SEXP handle, - SEXP call_state) { +LGBM_SE LGBM_BoosterUpdateOneIter_R(LGBM_SE handle, + LGBM_SE call_state) { int is_finished = 0; R_API_BEGIN(); CHECK_CALL(LGBM_BoosterUpdateOneIter(R_GET_PTR(handle), &is_finished)); R_API_END(); } -SEXP LGBM_BoosterUpdateOneIterCustom_R(SEXP handle, - SEXP grad, - SEXP hess, - SEXP len, - SEXP call_state) { +LGBM_SE LGBM_BoosterUpdateOneIterCustom_R(LGBM_SE handle, + LGBM_SE grad, + LGBM_SE hess, + LGBM_SE len, + LGBM_SE call_state) { int is_finished = 0; R_API_BEGIN(); int int_len = R_AS_INT(len); @@ -410,16 +410,16 @@ SEXP LGBM_BoosterUpdateOneIterCustom_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterRollbackOneIter_R(SEXP handle, - SEXP call_state) { +LGBM_SE LGBM_BoosterRollbackOneIter_R(LGBM_SE handle, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterRollbackOneIter(R_GET_PTR(handle))); R_API_END(); } -SEXP LGBM_BoosterGetCurrentIteration_R(SEXP handle, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetCurrentIteration_R(LGBM_SE handle, + LGBM_SE out, + LGBM_SE call_state) { int out_iteration; R_API_BEGIN(); CHECK_CALL(LGBM_BoosterGetCurrentIteration(R_GET_PTR(handle), &out_iteration)); @@ -427,29 +427,29 @@ SEXP LGBM_BoosterGetCurrentIteration_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterGetUpperBoundValue_R(SEXP handle, - SEXP out_result, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetUpperBoundValue_R(LGBM_SE handle, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); double* ptr_ret = R_REAL_PTR(out_result); CHECK_CALL(LGBM_BoosterGetUpperBoundValue(R_GET_PTR(handle), ptr_ret)); R_API_END(); } -SEXP LGBM_BoosterGetLowerBoundValue_R(SEXP handle, - SEXP out_result, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetLowerBoundValue_R(LGBM_SE handle, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); double* ptr_ret = R_REAL_PTR(out_result); CHECK_CALL(LGBM_BoosterGetLowerBoundValue(R_GET_PTR(handle), ptr_ret)); R_API_END(); } -SEXP LGBM_BoosterGetEvalNames_R(SEXP handle, - SEXP buf_len, - SEXP actual_len, - SEXP eval_names, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetEvalNames_R(LGBM_SE handle, + LGBM_SE buf_len, + LGBM_SE actual_len, + LGBM_SE eval_names, + LGBM_SE call_state) { R_API_BEGIN(); int len; CHECK_CALL(LGBM_BoosterGetEvalCounts(R_GET_PTR(handle), &len)); @@ -477,10 +477,10 @@ SEXP LGBM_BoosterGetEvalNames_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterGetEval_R(SEXP handle, - SEXP data_idx, - SEXP out_result, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetEval_R(LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); int len; CHECK_CALL(LGBM_BoosterGetEvalCounts(R_GET_PTR(handle), &len)); @@ -491,10 +491,10 @@ SEXP LGBM_BoosterGetEval_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterGetNumPredict_R(SEXP handle, - SEXP data_idx, - SEXP out, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetNumPredict_R(LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out, + LGBM_SE call_state) { R_API_BEGIN(); int64_t len; CHECK_CALL(LGBM_BoosterGetNumPredict(R_GET_PTR(handle), R_AS_INT(data_idx), &len)); @@ -502,10 +502,10 @@ SEXP LGBM_BoosterGetNumPredict_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterGetPredict_R(SEXP handle, - SEXP data_idx, - SEXP out_result, - SEXP call_state) { +LGBM_SE LGBM_BoosterGetPredict_R(LGBM_SE handle, + LGBM_SE data_idx, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); double* ptr_ret = R_REAL_PTR(out_result); int64_t out_len; @@ -513,7 +513,7 @@ SEXP LGBM_BoosterGetPredict_R(SEXP handle, R_API_END(); } -int GetPredictType(SEXP is_rawscore, SEXP is_leafidx, SEXP is_predcontrib) { +int GetPredictType(LGBM_SE is_rawscore, LGBM_SE is_leafidx, LGBM_SE is_predcontrib) { int pred_type = C_API_PREDICT_NORMAL; if (R_AS_INT(is_rawscore)) { pred_type = C_API_PREDICT_RAW_SCORE; @@ -527,16 +527,16 @@ int GetPredictType(SEXP is_rawscore, SEXP is_leafidx, SEXP is_predcontrib) { return pred_type; } -SEXP LGBM_BoosterPredictForFile_R(SEXP handle, - SEXP data_filename, - SEXP data_has_header, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP result_filename, - SEXP call_state) { +LGBM_SE 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 num_iteration, + LGBM_SE parameter, + LGBM_SE result_filename, + LGBM_SE call_state) { 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), @@ -545,14 +545,14 @@ SEXP LGBM_BoosterPredictForFile_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle, - SEXP num_row, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP out_len, - SEXP call_state) { +LGBM_SE LGBM_BoosterCalcNumPredict_R(LGBM_SE handle, + LGBM_SE num_row, + LGBM_SE is_rawscore, + LGBM_SE is_leafidx, + LGBM_SE is_predcontrib, + LGBM_SE num_iteration, + LGBM_SE out_len, + LGBM_SE call_state) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); int64_t len = 0; @@ -562,20 +562,20 @@ SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterPredictForCSC_R(SEXP handle, - SEXP indptr, - SEXP indices, - SEXP data, - SEXP num_indptr, - SEXP nelem, - SEXP num_row, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP out_result, - SEXP call_state) { +LGBM_SE 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 num_iteration, + LGBM_SE parameter, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); @@ -595,17 +595,17 @@ SEXP LGBM_BoosterPredictForCSC_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterPredictForMat_R(SEXP handle, - SEXP data, - SEXP num_row, - SEXP num_col, - SEXP is_rawscore, - SEXP is_leafidx, - SEXP is_predcontrib, - SEXP num_iteration, - SEXP parameter, - SEXP out_result, - SEXP call_state) { +LGBM_SE 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 num_iteration, + LGBM_SE parameter, + LGBM_SE out_result, + LGBM_SE call_state) { R_API_BEGIN(); int pred_type = GetPredictType(is_rawscore, is_leafidx, is_predcontrib); @@ -622,21 +622,21 @@ SEXP LGBM_BoosterPredictForMat_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterSaveModel_R(SEXP handle, - SEXP num_iteration, - SEXP filename, - SEXP call_state) { +LGBM_SE LGBM_BoosterSaveModel_R(LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE filename, + LGBM_SE call_state) { R_API_BEGIN(); CHECK_CALL(LGBM_BoosterSaveModel(R_GET_PTR(handle), 0, R_AS_INT(num_iteration), R_CHAR_PTR(filename))); R_API_END(); } -SEXP LGBM_BoosterSaveModelToString_R(SEXP handle, - SEXP num_iteration, - SEXP buffer_len, - SEXP actual_len, - SEXP out_str, - SEXP call_state) { +LGBM_SE LGBM_BoosterSaveModelToString_R(LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE buffer_len, + LGBM_SE actual_len, + LGBM_SE out_str, + LGBM_SE call_state) { R_API_BEGIN(); int64_t out_len = 0; std::vector inner_char_buf(R_AS_INT(buffer_len)); @@ -645,12 +645,12 @@ SEXP LGBM_BoosterSaveModelToString_R(SEXP handle, R_API_END(); } -SEXP LGBM_BoosterDumpModel_R(SEXP handle, - SEXP num_iteration, - SEXP buffer_len, - SEXP actual_len, - SEXP out_str, - SEXP call_state) { +LGBM_SE LGBM_BoosterDumpModel_R(LGBM_SE handle, + LGBM_SE num_iteration, + LGBM_SE buffer_len, + LGBM_SE actual_len, + LGBM_SE out_str, + LGBM_SE call_state) { R_API_BEGIN(); int64_t out_len = 0; std::vector inner_char_buf(R_AS_INT(buffer_len));