Call R from Kotlin or embed R inside Kotlin

Submitted by Dickens A S on Fri, 11/29/2019 - 06:03

Embedded R inside Kotlin

Demo output

E Embed

R code which is running inside Kotlin, simply add number 2 all the incoming array values and return

myfunc <- function(p1) {
  cat("Incoming value from Kotlin: ", p1, "\n");

  return(p1 + 2)

The Kotlin code which runs the R

Artificial Neural Network in Kotlin - FANN

Submitted by Dickens A S on Thu, 11/28/2019 - 13:53

FANN is an open source library 

which offers C based API which can be invoked from Kotlin

Below Kotlin example shows how it can be invoked

import fann.*

fun main() 

    var ann = fann_create_standard(4, 2, 8, 9, 1)

Below is the sample output from MSYS2 terminal

Call MATLAB function octave Mex from Kotlin

Submitted by Dickens A S on Thu, 11/28/2019 - 09:06

Is one of the popular Scientific Programming Language or platform

general MATLAB functions will work in Octave

This Article explains how to trigger Mex script from Kotlin using "mex.h" and "octave.h" C API in Kotlin

Octave 5.1.0 is installed in C:\octave with below structure and files

Note: Octave 6.x.x has C++ class will not support Kotlin, Please use Octave 5.1.0

Installing R using Cygwin

Submitted by Dickens A S on Wed, 11/27/2019 - 14:37

R is amazing platform which many numerical methods and analysis options available

This article explains how to use R in Windows using Cygwin

Reason for Cygwin, it has X11 and Cygwin-X with amazing setup selection tools and many libraries

Below are the installation steps

Step 1: Download and install Cygwin and dependencies

Double click the setup will launch 
Press Next in all the windows 
For Download Site choose

Pressing next will show software selection window as shown below

Linear Algebra using Kotlin and LAPACK (OpenBLAS)

Submitted by Dickens A S on Mon, 11/25/2019 - 16:37

Kotlin Linear Algebra using LAPACKE C APIs

Code snippet to call the library method

    print_matrix_colmajor( "Entry Matrix A", m, n, a, lda )
    print_matrix_colmajor( "Right Hand Side b", n, nrhs, b, ldb )
    println( "\nLAPACKE_dgels (col-major, high-level) Example Program Results" );
    print_matrix_colmajor( "Solution", n, nrhs, b, ldb );

You need to use MSYS2 and install OpenBLAS to make this work, please refer other articles for MSYS2

Call Lua from Kotlin or embed Lua inside Kotlin

Submitted by Dickens A S on Sat, 11/23/2019 - 06:20

Embedded Lua inside Kotlin

Compile and Execute from MSYS2 or Cygwin with python development C header files

Demo output

Lua in Kotlin

Lua code which is running inside Kotlin

Kotlin OpenGL Render SVG using librsvg

Submitted by Dickens A S on Fri, 11/22/2019 - 07:55

Kickstart Kotlin OpenGL using GLEW, librsvg using below github code

Output window with GLFW

SVG Using librsvg

You Need MSYS2

This is required for windows to download pre-compiled libraries and its headers

Kotlin OpenGL libpangocairo Unicode Font Rendering

Submitted by Dickens A S on Fri, 11/22/2019 - 05:05

Kickstart Kotlin OpenGL using GLEW, libpangocairo using below github code

Output window with GLFW


libpangocairo offers combined ready made methods to render, save, texture, pattern generate in an image file or in a rendering window

cairo is one of the base libraries used in many open source tool kits