Coder Social home page Coder Social logo

clbustos / extendmatrix Goto Github PK

View Code? Open in Web Editor NEW
33.0 2.0 5.0 283 KB

Cosmin Bonchis's enhancements to the Ruby "Vector" and "Matrix" module and includes: LU and QR (Householder, Givens, Gram Schmidt, Hessenberg) decompositions, bidiagonalization, eigenvalue and eigenvector calculations. Work on Ruby 1.8.7, 1.9.1 and 1.9.2 (SVN version)

Home Page: http://rubyforge.org/projects/matrix/

License: Apache License 2.0

Ruby 100.00%

extendmatrix's Introduction

= extendmatrix

* http://github.com/clbustos/extendmatrix

== DESCRIPTION:

The project consists of some enhancements to the Ruby "Matrix" module and includes: LU and QR (Householder, Givens, Gram Schmidt, Hessenberg) decompositions, bidiagonalization, eigenvalue and eigenvector calculations.
Include some aditional code to obtains marginal for rows and columns.

Original code from http://rubyforge.org/projects/matrix/ , done by Cosmin Bonchis as a Google Summer of Code 2007 project for Ruby Central Inc.

Gem, github repository and current version manteined by Claudio Bustos.

== SYNOPSIS:

  require 'extendmatrix'
  v = Vector[1, 2, 3, 4]
  
  v.magnitude # => 5.47722557505166
  
  v.normalize # => Vector[0.182574185835055, 0.365148371670111, 0.547722557505166, 0.730296743340221]
  
  # Backport from Ruby 1.9.2+
  m = Matrix.build(4, 3){|i, j| i * 3 + j}
  # => Matrix[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
  
  # You could modify the matrix
  m = Matrix.I(3)
  m[0,1]=m[1,0]=0.5
  m[0,2]=m[2,0]=0.7
  m[1,2]=m[2,1]=0.9
  m           # => Matrix[[1, 0.5, 0.7], [0.5, 1, 0.9], [0.7, 0.9, 1]]
  
  # Eigenvalues and EigenVectors. PCA at sight :)
  
  m.eigenvaluesJacobi => Vector[0.523942339006665, 0.0632833995384682, 2.41277426145487]
  m.cJacobiV
  # => Matrix[[0.818814082563014, 0.249617871497675, 0.516947208547894], [-0.550168858227442, 0.598307531004925, 0.58253096551128], [-0.163883268313767, -0.761392813580323, 0.62723461144538]]
== REQUIREMENTS:

* Only Ruby

== INSTALL:

* sudo gem install matrix-extensions

== LICENSE:



Copyright [2007] Cosmin Bonchis
Copyright [2010] Claudio Bustos

Licensed under the Apache License, Version 2.0 (the "License"); you may not use 
this file except in compliance with the License. You may obtain a copy of the 
License at 

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed 
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the License for the 
specific language governing permissions and limitations under the License. 


See LICENSE.txt for more details

extendmatrix's People

Contributors

clbustos avatar maxhawkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

extendmatrix's Issues

Doesn't work on Ruby 1.9.2

The new methods on Matrix conflict with extension. Now, three test doesn't pass.

TypeError in 'Matrix class extension: row2matrix'
can't convert Range into Integer
spec/extendmatrix_spec.rb:213:in `block (2 levels) in <top (required)>'

NoMethodError in 'Matrix class extension: houseQR '
undefined method size' for nil:NilClass spec/extendmatrix_spec.rb:282:inblock (2 levels) in <top (required)>'

NoMethodError in 'Matrix class extension: houseR '
undefined method size' for nil:NilClass spec/extendmatrix_spec.rb:296:inblock (2 levels) in <top (required)>'

NoMethodError in 'Matrix class extension: bidiagonalization'
undefined method size' for nil:NilClass spec/extendmatrix_spec.rb:306:inblock (2 levels) in <top (required)>'

NoMethodError in 'Matrix class extension: hessenbergQR '
undefined method size' for nil:NilClass spec/extendmatrix_spec.rb:331:inblock (2 levels) in <top (required)>'

NoMethodError in 'Matrix class extension: realSchur'
undefined method size' for nil:NilClass spec/extendmatrix_spec.rb:351:inblock (2 levels) in <top (required)>'

Finished in 0.08513933899999999 seconds

`initialize_copy': undefined method `init_rows'

extendmatrix-0.4/lib/extendmatrix.rb:309:in initialize_copy': undefined method init_rows' for #Matrix:0x00005580c849f680 (NoMethodError)

def initialize_copy(orig)
    init_rows(orig.rows, true)
    self.wrap=(orig.wrap)
  end

Besides, unnecessary require 'rational'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.