Skip to content

Instantly share code, notes, and snippets.

View asengupta's full-sized avatar

Avishek Sen Gupta asengupta

View GitHub Profile
@asengupta
asengupta / MapReduceColumnwiseMatrixProduct.rb
Created November 11, 2011 20:04
MapReduce version of matrix multiplication using linear multiplications
require 'rubygems'
require 'matrix'
require './matrix_block_mixin'
require './map_reduce'
def pair_up(key, value)
inputs = []
a = value[:a]
b = value[:b]
@asengupta
asengupta / MapReduceBlockMatrixProduct.rb
Created November 11, 2011 01:28
MapReduce version of matrix multiplication using recursive block matrix decomposition
require 'rubygems'
require 'matrix'
require './matrix_block_mixin'
require './map_reduce'
require 'benchmark'
def map(key, value)
inputs = []
a = value[:a]
b = value[:b]
@asengupta
asengupta / matrix_block_mixin.rb
Created November 10, 2011 20:13
Block matrix decomposition operation addition to Matrix
class Matrix
def block(block_row, block_column)
raise "Non 2^n matrix" if (row_size & (row_size - 1)) != 0 || (column_size & (column_size - 1)) != 0
lower_order = row_size/2
start_row = block_row * lower_order
start_column = block_column * lower_order
b = []
lower_order.times do |r|
row = []
lower_order.times do |c|
@asengupta
asengupta / LinearRecursiveBlockMatrixProduct.rb
Created November 10, 2011 20:12
Linear, recursive matrix multiplication using block matrix decomposition
def join(left_block, right_block)
rows = []
lower_order = left_block.row_size
lower_order.times do |t|
rows << left_block.row(t).to_a + right_block.row(t).to_a
end
rows
end
def product(a,b)
@asengupta
asengupta / demo-boxplot.rb
Created October 9, 2011 18:49
Demo of Box Plot with Basis
require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
ENV['GEM_PATH'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
require 'basis_processing'
class BoxPlotSketch < Processing::App
def setup
@screen_height = 900
@asengupta
asengupta / demo-rotated.rb
Created October 9, 2011 14:57
Basis Rotated Coordinates Demo
require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
ENV['GEM_PATH'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
require 'basis_processing'
class Demo < Processing::App
app = self
@asengupta
asengupta / basis-demo.rb
Created October 6, 2011 05:49
Demonstration code for Basis
require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
ENV['GEM_PATH'] = '/home/avishek/jruby/jruby-1.6.4/lib/ruby/gems/1.8'
require 'basis_processing'
class Demo < Processing::App
app = self