diff --git a/VERSION b/VERSION index 5d4294b..167b000 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.1 \ No newline at end of file +0.5.4 \ No newline at end of file diff --git a/ext/svd.c b/ext/svd.c index 8145e60..f2c640b 100644 --- a/ext/svd.c +++ b/ext/svd.c @@ -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 */ diff --git a/ext/svd.h b/ext/svd.h index 2f7ae4a..958c75e 100644 --- a/ext/svd.h +++ b/ext/svd.h @@ -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; @@ -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]; diff --git a/lib/lsa.rb b/lib/lsa.rb index aa62ea3..63f1981 100644 --- a/lib/lsa.rb +++ b/lib/lsa.rb @@ -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 @@ -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) diff --git a/pkg/ruby-svd-0.1.0.gem b/pkg/ruby-svd-0.1.0.gem deleted file mode 100644 index 4393bf3..0000000 Binary files a/pkg/ruby-svd-0.1.0.gem and /dev/null differ diff --git a/pkg/ruby-svd-0.2.0.gem b/pkg/ruby-svd-0.2.0.gem deleted file mode 100644 index eeb31a0..0000000 Binary files a/pkg/ruby-svd-0.2.0.gem and /dev/null differ diff --git a/pkg/ruby-svd-0.2.1.gem b/pkg/ruby-svd-0.2.1.gem deleted file mode 100644 index f0ed534..0000000 Binary files a/pkg/ruby-svd-0.2.1.gem and /dev/null differ diff --git a/pkg/ruby-svd-0.3.0.gem b/pkg/ruby-svd-0.3.0.gem deleted file mode 100644 index 421b42c..0000000 Binary files a/pkg/ruby-svd-0.3.0.gem and /dev/null differ diff --git a/pkg/ruby-svd-0.4.0.gem b/pkg/ruby-svd-0.4.0.gem deleted file mode 100644 index 4f841fd..0000000 Binary files a/pkg/ruby-svd-0.4.0.gem and /dev/null differ diff --git a/pkg/ruby-svd-0.4.5.gem b/pkg/ruby-svd-0.4.5.gem deleted file mode 100644 index 47f6ef8..0000000 Binary files a/pkg/ruby-svd-0.4.5.gem and /dev/null differ diff --git a/ruby-svd.gemspec b/ruby-svd.gemspec index 3f483a6..cdf646a 100644 --- a/ruby-svd.gemspec +++ b/ruby-svd.gemspec @@ -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", @@ -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