Slide 1

Slide 1 text

namaste

Slide 2

Slide 2 text

Incredible India

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

India must master Western science and yet preserve its Culture and Heritage. What India Dreams

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

City of Pune. Population: 6 million. Oxford of the East.

Slide 9

Slide 9 text

Sameer Deshmukh github.com/v0dro @v0dro

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Dr. Gopal Deshmukh Sameer Desmukh Dr. Hemchandra Deshmukh Dr. Satish Deshmukh

Slide 12

Slide 12 text

www.soundcloud.com/catkamikazee Sameer

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Pune Ruby Users Group www.punerb.org @punerb @punerb @deccanrubyconf www.deccanrubyconf.org

Slide 16

Slide 16 text

Ruby Science Foundation www.sciruby.com @sciruby @sciruby

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Scientific Computing In Ruby

Slide 19

Slide 19 text

iruby notebook

Slide 20

Slide 20 text

Browser based Ruby REPL for interactive computing.

Slide 21

Slide 21 text

Runs in your browser Input cell – accepts Ruby code Output cell – can render HTML/CSS/JS

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

nmatrix

Slide 24

Slide 24 text

n­dimensional array object. Interface Ruby with high speed C libraries.

Slide 25

Slide 25 text

require 'nmatrix' n = NMatrix.new( [2,2], [1,2,3,4], dtype: :float32, stype: :dense ) n[0,1] # => 2.0

Slide 26

Slide 26 text

Data Types :int8 :float32 :int16 :float64 :int32 :complex64 :int64 :complex128

Slide 27

Slide 27 text

Storage types Dense Dense matrix. List Sparse matrix type storing data as a linked list. Yale Sparse type storing data in the 'New Yale' format.

Slide 28

Slide 28 text

NMatrix C API

Slide 29

Slide 29 text

nmatrix nmatrix­ atlas nmatrix­ lapacke nmatrix­ fftw gsl

Slide 30

Slide 30 text

nyaplot

Slide 31

Slide 31 text

Interactive plotting tool for Rubyists.

Slide 32

Slide 32 text

interactive HTML and JavaScript plots that can be displayed in your browser.

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Mapnya Nyaplot3D Bionya Map visualizations with inbuilt country charts. Three Dimensional interactive plots. Biology plots for visualizing relationships of genes.

Slide 35

Slide 35 text

daru (Data Analysis in RUby)

Slide 36

Slide 36 text

daru == (Hindi) ददार sake alcohol

Slide 37

Slide 37 text

library for analysis, cleaning, manipulation and visualization of data.

Slide 38

Slide 38 text

Read/write many data sources Ephemeral statistics functions Works well with 'wild' data Data indexing

Slide 39

Slide 39 text

Acts as glue between other SciRuby libraries.

Slide 40

Slide 40 text

Daru::Vector Heterogenous Array that can be indexed on any Ruby object. Name Label(0) Label(1) Label(2) ... Label(n-1)

Slide 41

Slide 41 text

Daru::DataFrame 2D spreadsheet like data structure indexed by rows or columns. Col0 Label(0) Label(1) Label(2) ... Label(n-1) Col1 Col2 Col(n-1) ....

Slide 42

Slide 42 text

New Ideas for better Ruby

Slide 43

Slide 43 text

“Any sufficiently advanced technology is indistinguishable from magic.” ­ Arthur C. Clarke

Slide 44

Slide 44 text

Writing C extensions ● FFI gem. ● Rice. ● SWIG. ● Writing C bindings manually.

Slide 45

Slide 45 text

Rubyist! Write me a C extension!

Slide 46

Slide 46 text

def factorial n n > 1 ? n*factorial(n-1) : 1 end

Slide 47

Slide 47 text

unsigned long long int calc_factorial(unsigned long long int n) { return (n > 1 ? n*calc_factorial(n-1) : 1); } static VALUE cfactorial(VALUE self, VALUE n) { return ULL2FIX( calc_factorial(NUM2ULL(n))); }

Slide 48

Slide 48 text

void Init_factorial() { VALUE cFact = rb_define_class("Fact", rb_cObject); rb_define_method(cFact, "factorial", cfactorial, 1); }

Slide 49

Slide 49 text

a = Fact.new a.factorial(8000)

Slide 50

Slide 50 text

Big Problems ● Difficult and irritating to write. ● Time consuming to debug. ● Tough to trace memory leaks. ● Change mindset from high level to low level language. ● Need to care about small things.™* *Matz – Keynote at Red Dot Ruby Conf 2016, Singapore.

Slide 51

Slide 51 text

Rubex

Slide 52

Slide 52 text

Rubex is a Crystal­inspired superset of Ruby that compiles to C.

Slide 53

Slide 53 text

class Fact def factorial(unsigned long long int n) n > 1 ? n*factorial(n-1) : 1 end end

Slide 54

Slide 54 text

# Create a C static array and return a Ruby Array def adder(n) a = StaticArray(i32, n) i32 i = 0 i32 sum = 0 a.each(n) { a[i] = i*5 } for 0 <= i < n do sum += a[i] end sum end

Slide 55

Slide 55 text

Received the Ruby Association Grant 2016 for development of Rubex

Slide 56

Slide 56 text

https://github.com/v0dro/rubex

Slide 57

Slide 57 text

Scientific Computing on JRuby

Slide 58

Slide 58 text

NMatrix and NArray are a linear algebra libraries for Ruby similar to numpy.

Slide 59

Slide 59 text

NMatrix C/C++ core CRuby interpreter Numo::NArray C core CRuby interpreter

Slide 60

Slide 60 text

JRuby backend for the NMatrix Ruby API – Sci. Computing on JVM.

Slide 61

Slide 61 text

Allows interfacing JRuby libraries with jBLAS for performance. Uses Apache Commons Math library for storage and operations on internal Java arrays.

Slide 62

Slide 62 text

https://github.com/prasunanand/ nmatrix/tree/jruby_port

Slide 63

Slide 63 text

Symbolic Computation in Ruby with symengine.rb

Slide 64

Slide 64 text

(x – y) * (x ** y / z)

Slide 65

Slide 65 text

require 'symengine' x = SymEngine::Symbol.new("x") y = SymEngine::Symbol.new("y") z = SymEngine::Symbol.new("z") f = (x – y) * (x ** y / z) f.expand.to_s # x**(1 + y)/z – x**y*y/z f == - (x**y*y/z) + (x**y*x/z) # true

Slide 66

Slide 66 text

https://github.com/symengine/ symengine.rb

Slide 67

Slide 67 text

Ruby in Space

Slide 68

Slide 68 text

NASA SPICE Ruby wrapper spice_rub

Slide 69

Slide 69 text

require 'spice_rub' k_pool = SpiceRub::KernelPool.instance k_pool.load_folder("spec/data/kernels") epoch = SpiceRub::Time.now moon = SpiceRub::Body.new(:moon) earth = SpiceRub::Body.now(:earth) earth.position_at(epoch) moon.distance_from(:earth, epoch) # 395791.1464913574 (Km)

Slide 70

Slide 70 text

https://github.com/gau27/spice_rub

Slide 71

Slide 71 text

Cool SciRuby Stickers

Slide 72

Slide 72 text

Thank You Ruby World Conf!

Slide 73

Slide 73 text

Any questions?