看板 R_Language 關於我們 聯絡資訊
※ 引述《gsuper (Logit(odds))》之銘言: : cppFunction( : ' : int fx(NumericVector x) : { int ss = x.size(); : return ss; : } : ' : ) : --------------- : 在上述的 function 中 : 1.NumericVector : 是否是 Rcpp 提供的特殊變數宣告方式? : 還是這是正常的 C語言 之宣告? : [SEXP object] : Integer(Vector|Matrix) ; integer vectors and matrices : Numeric(Vector|Matrix) ; numeric : Logical(Vector|Matrix) ; logical : Character(Vector|Matrix) ; character : Raw(Vector|Matrix) ; raw : Complex(Vector|Matrix) ; complex : GenericVector ; list : -------------- 以小弟初淺的C++概念稍微解釋一下... NumericVector是Rcpp於C++中 浮點數vector 的class (精度不確定) 而R定義的是SEXP,Rcpp提供更多不同的class供使用者使用 : 2. x.size() : 這是類似 size(x) 的感覺 : 請問 size() 是 C 的 function 還是 R 的? : --- : 查了以後發現是 C++ 的 vector::size() 的關係 : 但為何不需要寫 #include <vector>? : http://www.cplusplus.com/reference/set/ size 是 NumericVector的 member function 他底層 我不確定是不是利用vector這個標準庫 但如果是,會在定義NumericVector的header file include 另外,建議可以用Rcpp attribute去學 可能會比較容易一點 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.230.166.124 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1422361444.A.96F.html ※ 編輯: celestialgod (125.230.166.124), 01/27/2015 20:34:10
Wush978: NumericVector是Rcpp定義的 01/27 21:06
Wush978: R中定義SEXP和相關, 如REAL等巨集供C使用 01/27 21:08
Wush978: Rcpp提供c++物件帶來的好處,提供如 01/27 21:09
Wush978: NumericVector等物件讓我們用的更簡單 01/27 21:10
什麼! 跟我想的不一樣QQ 我不就誤導了... 更正我的內文... 我看了一下發現 NumericVector等都是在Rcpp的namespace... ※ 編輯: celestialgod (125.230.166.124), 01/27/2015 21:46:56