Project

randsvd

0.0
Low commit activity in last 3 years
No release in over a year
RandSVD is a class that performs truncated singular value decomposition using a randomized algorithm.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

RandSVD

Build Status Gem Version

RandSVD is a class that performs truncated singular value decomposition using a randomized algorithm. To implement, I referred to the following papers:

  • P.-G. Martinsson, A. Szlam, M. Tygert, "Normalized power iterations for the computation of SVD," Proc. of NIPS Workshop on Low-Rank Methods for Large-Scale Machine Learning, 2011.
  • P.-G. Martinsson, V. Rokhlin, M. Tygert, "A randomized algorithm for the approximation of matrices," Tech. Rep., 1361, Yale University Department of Computer Science, 2006.

Note: Since NMatrix does not support Ruby 3, the author recommends using numo-linalg-randsvd instead.

Installation

Add this line to your application's Gemfile:

gem 'randsvd'

And then execute:

$ bundle

Or install it yourself as:

$ gem install randsvd

Usage

require 'randsvd'

# Initialize some variables.
input_matrix = NMatrix.rand([1000, 100])
nb_singular_values = 10

# Perform the randomized singular value decomposition.
u, s, vt = RandSVD.gesvd(input_matrix, nb_singular_values)

# Reconstruct the matrix with the singular values and vectors.
reconstructed_matrix = u.dot(NMatrix.diag(s).dot(vt))

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/randsvd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.