Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scientific Computing in Ruby at Ruby World Conf...

Scientific Computing in Ruby at Ruby World Conference 2016

Talk on tools for Scientific Computing in Ruby at Ruby World Conference 2016, Matsue City, Shimane, Japan.

Sameer Deshmukh

November 03, 2016
Tweet

More Decks by Sameer Deshmukh

Other Decks in Programming

Transcript

  1. Runs in your browser Input cell – accepts Ruby code

    Output cell – can render HTML/CSS/JS
  2. 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.
  3. Mapnya Nyaplot3D Bionya Map visualizations with inbuilt country charts. Three

    Dimensional interactive plots. Biology plots for visualizing relationships of genes.
  4. Daru::Vector Heterogenous Array that can be indexed on any Ruby

    object. Name Label(0) Label(1) Label(2) ... Label(n-1)
  5. 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) ....
  6. 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))); }
  7. 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.
  8. # 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
  9. Allows interfacing JRuby libraries with jBLAS for performance. Uses Apache

    Commons Math library for storage and operations on internal Java arrays.
  10. 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
  11. 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)