Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.1
0.5.4
2 changes: 1 addition & 1 deletion ext/svd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VALUE decompose(VALUE module, VALUE matrix_ruby, VALUE m_ruby, VALUE n_ruby) {
/* precondition */
if((m*n) != RARRAY_LEN(matrix_ruby)) {
rb_raise(rb_eRangeError, "Size of the array is not equal to m * n");
return;
return NULL;
}

/* convert to u matrix */
Expand Down
4 changes: 2 additions & 2 deletions ext/svd.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void svdcmp(float **a, int m, int n, float w[], float **v)
++a[i][i];
}
for (k=n;k>=1;k--) {
for (its=1;its<=30;its++) {
for (its=1;its<=90;its++) {
flag=1;
for (l=k;l>=1;l--) {
nm=l-1;
Expand Down Expand Up @@ -139,7 +139,7 @@ void svdcmp(float **a, int m, int n, float w[], float **v)
}
break;
}
if (its == 30) nrerror("no convergence in 30 svdcmp iterations");
if (its == 90) nrerror("no convergence in 90 svdcmp iterations");
x=w[l];
nm=k-1;
y=w[nm];
Expand Down
7 changes: 5 additions & 2 deletions lib/lsa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ class LSA
attr_accessor :u, :s, :v

def initialize(matrix)
if matrix.send(:rows).count < matrix.send(:column_size)
raise "Matrix dimension 1 must be greater than or equal to dimension 2"
end
@u, @s, @v = matrix.decompose(2)
end

def inspect
"U:\n#{@u.inspect}\n\nS:\n#{@s.inspect}\n\nV:\n#{@v.inspect}"
end
Expand All @@ -15,7 +18,7 @@ def inspect
# and all the clusters (columns) used in the original matrix.
# Returns a sorted list of indexes and distances,
def classify_vector(values)
raise "Unsupported vector length" unless values.size == @u.row_size || values.size == @v.row_size
raise "Unsupported vector length: #{values.size} != #{@u.row_size} or #{@v.row_size}" unless values.size == @u.row_size || values.size == @v.row_size
vector = Matrix.row_vector(values)
mult_matrix = (values.size == @u.row_size ? @u : @v)
comp_matrix = (values.size == @u.row_size ? @v : @u)
Expand Down
Binary file removed pkg/ruby-svd-0.1.0.gem
Binary file not shown.
Binary file removed pkg/ruby-svd-0.2.0.gem
Binary file not shown.
Binary file removed pkg/ruby-svd-0.2.1.gem
Binary file not shown.
Binary file removed pkg/ruby-svd-0.3.0.gem
Binary file not shown.
Binary file removed pkg/ruby-svd-0.4.0.gem
Binary file not shown.
Binary file removed pkg/ruby-svd-0.4.5.gem
Binary file not shown.
16 changes: 8 additions & 8 deletions ruby-svd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{ruby-svd}
s.version = "0.5.1"
s.name = "ruby-svd"
s.version = "0.5.4"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Will Cannings"]
s.date = %q{2011-05-30}
s.description = %q{Singular Value Decomposition with no dependency on GSL or LAPACK}
s.email = %q{me@willcannings.com}
s.date = "2012-10-23"
s.description = "Singular Value Decomposition with no dependency on GSL or LAPACK"
s.email = "me@willcannings.com"
s.extensions = ["ext/extconf.rb"]
s.extra_rdoc_files = [
"LICENSE",
Expand All @@ -26,10 +26,10 @@ Gem::Specification.new do |s|
"lib/ruby-svd.rb",
"lib/svd_matrix.rb"
]
s.homepage = %q{http://github.com/willcannings/ruby-svd}
s.homepage = "http://github.com/willcannings/ruby-svd"
s.require_paths = ["lib", "ext"]
s.rubygems_version = %q{1.6.2}
s.summary = %q{SVD for Ruby}
s.rubygems_version = "1.8.24"
s.summary = "SVD for Ruby"

if s.respond_to? :specification_version then
s.specification_version = 3
Expand Down