GithubHelp home page GithubHelp logo

ttrikalin / rmath Goto Github PK

View Code? Open in Web Editor NEW

This project forked from statslabs/rmath

0.0 1.0 0.0 226 KB

The R Standalone Math Library with modern CMake support

Home Page: https://cran.r-project.org/doc/manuals/r-release/R-admin.html#The-standalone-Rmath-library

License: GNU General Public License v2.0

C++ 1.91% C 97.30% CMake 0.78%

rmath's Introduction

Rmath - The R Standalone Math Library

The repository contains the R standalone Math Library, built to be used with the Statslabs.Stats C++ library.

Installation on Ubuntu / macOS

  1. Clone the repository.
    git clone [email protected]:statslabs/rmath.git
  2. Configure the project.
    cd rmath
    mkdir build && cd build
    cmake ..
  3. Compile and install the library.
    make
    make install

Example program

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;
}

Integration of Rmath in your own project

To make the project simple enough, we will create a CMake project for demo.c.

  1. Make a project folder.

    mkdir example && cd example
  2. Create demo.cc and CMakeLists.txt in the project folder where file CMakeLists.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)
  3. Perform a out-of-source build.

    mkdir build && cd build
    cmake ..
    make
  4. 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

rmath's People

Contributors

ypan1988 avatar statslabs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.