Last active
December 4, 2015 22:54
-
-
Save yrps/111ad4fb65ec8f669130 to your computer and use it in GitHub Desktop.
extend Ruby's standard Matrix module to facilitate Rational matrices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'matrix' | |
| class Matrix | |
| # Attempt to recast each entry of the matrix to clazz | |
| def to(clazz) | |
| self.each_with_index do |entry, i, j| | |
| self[i, j] = send(clazz.name.to_sym, entry) | |
| end | |
| end | |
| end |
yrps
commented
Dec 4, 2015
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment