Anthony Lee

Matrix with Ruby

Introduction

user

Anthony Lee

I love to code and better the world. Graduate student at Georgia Tech specializing in Machine Learning.


Featured

Machine Learning, Linear Algebra, Ruby

Matrix with Ruby

Posted by Anthony Lee on .

While doing math in Ruby is little more challenging than Python or R, it is still my favorite language! Here is how we create simple matrix with Ruby with matrix class and do a simple multiplication.

require 'matrix'

matrix_a = Matrix[[1, 2], [3, 4]]
matrix_b = Matrix[[-3, -8, 3], [-2, 1, 4]]

result = matrix_a * matrix_b
# => Matrix[[-7, -6, 11], [-17, -20, 25]]
user

Anthony Lee

http://anthonylee.io

I love to code and better the world. Graduate student at Georgia Tech specializing in Machine Learning.