R call C Using DLL in R (ver. 1.8.1).ppt

  1. 1、本文档共6页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
R call C Using DLL in R (ver. 1.8.1).ppt

R call C Using DLL in R (ver. 1.8.1) T. B. Chen in NCTU Flow chart show how-to Building a DLL by using Visual C++ To build the DLL, use Visual C++ as follows: 1. From Microsoft Developer Studio, select File, then New. The New dialog appears with a scrolled list of options. 2. Select Project Workspace from the New dialog. The New Project Workspace dialog appears. 3. Enter the project name “AR” in the Name text field, then select Dynamic Link Library in the Project Type list (not MFCAppWizard(dll)). If you want to specify a particular location for the project workspace, you can do that in this dialog as well. 4. Click Create. A new project workspace is created in the directory you specified. 5. From the Insert menu, choose Files into Project. 6. Use the Insert Files into Project dialog to select the source code file Ar.c and the module definition file Ar.def. To view .def files, use the Files of Type dropdown. 7. Select Build, then Settings, to bring up the Project Settings dialog. Choose the C/C++ tab. 8. Add the definition DLL_LOAD to the Preprocessor Definitions text field in the Project Settings dialog. 9. Select Project and then Rebuild All from the menu bar. This builds the DLL and creates numerous files, including the DLL file, Ar.dll. 10. Copy Ar.dll to …/R/rw1081/ Ar.c Ar.def Ar.c void arsim(double *x, long *n, double *phi) { long i; for (i=1; i*n; i++) x[i] = *phi * x[i-1] + x[i] ; } Ar.def ;***************************************** ; ar.def module definition file ;***************************************** LIBRARY ar EXPORTS arsim An example show R calling a DLL dyn.load(ar.dll,arsim, cdecl) NULL Warning message: DLL attempted to change FPU control word from 8001f to 9001f Test-function(x,a,b) .C(arsim, as.double(x),as.integer(a),as.double(b)) x-rnorm(10) Test(x,10,0.7)[[1]] [1] 1.7886214 0.9355408 2.2388264 1.9190996 1.5269978 2.5275526 2.8187632 [8] 1.7084246 1.1144688 0.3400129 x [1] 1-0 1 0 0.183628

文档评论(0)

gshbzl + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档