The repository contains the R standalone Math Library, built to be used with the Statslabs.Stats C++ library.
- Clone the repository.
git clone [email protected]:statslabs/rmath.git
- Configure the project.
cd rmath mkdir build && cd build cmake ..
- Compile and install the library.
make make install
demo.c
:
#include <stdio.h>
#include "Rmath.h"
int main() {
double shape1, shape2, prob;
printf("Enter first shape parameter: ");
scanf("%lf",&shape1);
printf("Enter second shape parameter: ");
scanf("%lf",&shape2);
printf("Enter probability level: ");
scanf("%lf",&prob);
printf("Critical value is %lf\n",qbeta(prob,shape1,shape2,1,0));
return 0;
}
To make the project simple enough, we will create a CMake project for demo.c
.
-
Make a project folder.
mkdir example && cd example
-
Create
demo.cc
andCMakeLists.txt
in the project folder where fileCMakeLists.txt
should look like:cmake_minimum_required(VERSION 3.0) project(example) add_executable(example demo.c) find_package(Rmath 1.0.0 REQUIRED) target_link_libraries(example Rmath::Rmath)
-
Perform a out-of-source build.
mkdir build && cd build cmake .. make
-
Run the program.
./example
A quick check on whether the program works:
Enter first shape parameter: 1.5 Enter second shape parameter: 0.3 Enter probability level: .10 Critical value is 0.478398
This corresponds to the following call in R:
> qbeta(.10,1.5,.3) [1] 0.4783981