Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Scientific Computing in Ruby at Ruby World Conf...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Sameer Deshmukh
November 03, 2016
Programming
240
1
Share
Scientific Computing in Ruby at Ruby World Conference 2016.
Talk on Scientific Computing in Ruby at Ruby World Conference, Matsue City, Shimane, Japan.
Sameer Deshmukh
November 03, 2016
More Decks by Sameer Deshmukh
See All by Sameer Deshmukh
XND and rubyplot - typed arrays and visualization in Ruby
v0dro
0
230
Ferrari Driven Development: superfast Ruby with Rubex
v0dro
0
2.2k
Ruby Kaigi 2017 - C how to supercharge your Ruby with Rubex
v0dro
1
460
Deccan Ruby Conf 2017 Rubex intro
v0dro
0
110
Rubex: A new way of writing C extensions for CRuby
v0dro
1
580
Scientific Computing in Ruby at Ruby World Conference 2016
v0dro
0
150
Data Analysis in RUby with daru
v0dro
3
3.7k
Introduction benchmark-plot at PRUG
v0dro
0
130
Webinar - Scientific Computing and Data Visualization
v0dro
0
110
Other Decks in Programming
See All in Programming
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
110
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
2
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
190
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
290
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
2
1.5k
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
3
540
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
180
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
230
AI時代になぜ書くのか
mutsumix
0
450
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
440
~ 秘伝のタレ化した『神スプシ』と戦う ~ 関数型パラダイムで壊れない仕組みへ
h0r15h0
1
120
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
430
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
190
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Making Projects Easy
brettharned
120
6.6k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
340
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
510
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Producing Creativity
orderedlist
PRO
348
40k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
Transcript
namaste
Incredible India
None
None
None
India must master Western science and yet preserve its Culture
and Heritage. What India Dreams
None
City of Pune. Population: 6 million. Oxford of the East.
Sameer Deshmukh github.com/v0dro @v0dro
None
Dr. Gopal Deshmukh Sameer Desmukh Dr. Hemchandra Deshmukh Dr. Satish
Deshmukh
www.soundcloud.com/catkamikazee Sameer
None
None
Pune Ruby Users Group www.punerb.org @punerb @punerb @deccanrubyconf www.deccanrubyconf.org
Ruby Science Foundation www.sciruby.com @sciruby @sciruby
None
Scientific Computing In Ruby
iruby notebook
Browser based Ruby REPL for interactive computing.
Runs in your browser Input cell – accepts Ruby code
Output cell – can render HTML/CSS/JS
None
nmatrix
ndimensional array object. Interface Ruby with high speed C libraries.
require 'nmatrix' n = NMatrix.new( [2,2], [1,2,3,4], dtype: :float32, stype:
:dense ) n[0,1] # => 2.0
Data Types :int8 :float32 :int16 :float64 :int32 :complex64 :int64 :complex128
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.
NMatrix C API
nmatrix nmatrix atlas nmatrix lapacke nmatrix fftw gsl
nyaplot
Interactive plotting tool for Rubyists.
interactive HTML and JavaScript plots that can be displayed in
your browser.
None
Mapnya Nyaplot3D Bionya Map visualizations with inbuilt country charts. Three
Dimensional interactive plots. Biology plots for visualizing relationships of genes.
daru (Data Analysis in RUby)
daru == (Hindi) ददार sake alcohol
library for analysis, cleaning, manipulation and visualization of data.
Read/write many data sources Ephemeral statistics functions Works well with
'wild' data Data indexing
Acts as glue between other SciRuby libraries.
Daru::Vector Heterogenous Array that can be indexed on any Ruby
object. Name Label(0) Label(1) Label(2) ... Label(n-1)
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) ....
New Ideas for better Ruby
“Any sufficiently advanced technology is indistinguishable from magic.” Arthur
C. Clarke
Writing C extensions • FFI gem. • Rice. • SWIG.
• Writing C bindings manually.
Rubyist! Write me a C extension!
def factorial n n > 1 ? n*factorial(n-1) : 1
end
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))); }
void Init_factorial() { VALUE cFact = rb_define_class("Fact", rb_cObject); rb_define_method(cFact, "factorial",
cfactorial, 1); }
a = Fact.new a.factorial(8000)
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.
Rubex
Rubex is a Crystalinspired superset of Ruby that compiles to
C.
class Fact def factorial(unsigned long long int n) n >
1 ? n*factorial(n-1) : 1 end end
# 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
Received the Ruby Association Grant 2016 for development of Rubex
https://github.com/v0dro/rubex
Scientific Computing on JRuby
NMatrix and NArray are a linear algebra libraries for Ruby
similar to numpy.
NMatrix C/C++ core CRuby interpreter Numo::NArray C core CRuby interpreter
JRuby backend for the NMatrix Ruby API – Sci. Computing
on JVM.
Allows interfacing JRuby libraries with jBLAS for performance. Uses Apache
Commons Math library for storage and operations on internal Java arrays.
https://github.com/prasunanand/ nmatrix/tree/jruby_port
Symbolic Computation in Ruby with symengine.rb
(x – y) * (x ** y / z)
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
https://github.com/symengine/ symengine.rb
Ruby in Space
NASA SPICE Ruby wrapper spice_rub
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)
https://github.com/gau27/spice_rub
Cool SciRuby Stickers
Thank You Ruby World Conf!
Any questions?