ruby-lapack 1.5 → 1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,21 +1,28 @@
1
1
  require "rubygems"
2
+ require "rubygems/package_task"
2
3
  require "rake/clean"
3
- require "rake/gempackagetask"
4
4
  require "rake/testtask"
5
5
 
6
- version = 1.5
6
+ version = "1.6"
7
7
  target_prefix = "numru"
8
8
 
9
9
  # get options
10
- destdir = ENV["DESTDIR"]
11
- libdir = ENV["SITELIBDIR"] || Config::CONFIG["sitelibdir"]
12
- archdir = ENV["SITEARCHDIR"] || Config::CONFIG["sitearchdir"]
10
+ destdir = ENV["DESTDIR"] || ""
11
+ libdir = ENV["SITELIBDIR"] || RbConfig::CONFIG["sitelibdir"]
12
+ archdir = ENV["SITEARCHDIR"] || RbConfig::CONFIG["sitearchdir"]
13
13
  config_opts = ENV["CONFIG_OPTIONS"]
14
14
 
15
15
  NAME = "lapack"
16
16
  LIBS = FileList["lib/#{target_prefix}/*rb"]
17
- DLLIB = "ext/#{NAME}.so"
18
- so_file = File.join("lib", target_prefix, "#{NAME}.so")
17
+
18
+ case RbConfig::CONFIG["host_os"]
19
+ when /darwin/
20
+ extension = "bundle"
21
+ else
22
+ extension = "so"
23
+ end
24
+ DLLIB = "ext/#{NAME}.#{extension}"
25
+ so_file = File.join("lib", target_prefix, "#{NAME}.#{extension}")
19
26
 
20
27
 
21
28
  task :default => so_file
@@ -56,7 +63,7 @@ task :install_rb => LIBS do
56
63
  dst = File.join(destdir, libdir, target_prefix)
57
64
  mkdir_p dst
58
65
  LIBS.each do |lib|
59
- install lib, dst, :mode => 644
66
+ install lib, dst, :mode => 0644
60
67
  end
61
68
  end
62
69
 
@@ -99,23 +106,18 @@ EOL
99
106
  end
100
107
 
101
108
 
102
- Rake::GemPackageTask.new(spec) do |pkg|
109
+ Gem::PackageTask.new(spec) do |pkg|
103
110
  pkg.need_tar_gz = true
104
111
  pkg.need_tar_bz2 = true
105
112
  end
106
113
 
107
114
 
108
115
 
109
- binary_pkg = "pkg/#{spec.name}-#{spec.version}-#{Config::CONFIG["arch"]}.gem"
116
+ binary_pkg = "pkg/#{spec.name}-#{spec.version}-#{RbConfig::CONFIG["arch"]}.gem"
117
+ gem_pkg = "pkg/#{spec.name}-#{spec.version}.gem"
110
118
  desc "Build binary package"
111
119
  task :binary_package => binary_pkg
112
120
 
113
- file binary_pkg => so_file do
114
- files = PKG_FILES.dup
115
- files.include so_file
116
- spec.platform = Gem::Platform::CURRENT
117
- spec.files = files
118
- spec.extensions = []
119
- Gem::Builder.new(spec).build
120
- mv File.basename(binary_pkg), binary_pkg
121
+ file binary_pkg => gem_pkg do
122
+ system "gem compile --fat 1.8:ruby1.8,1.9:ruby1.9 #{gem_pkg}"
121
123
  end
@@ -61,7 +61,7 @@ unless find_library("lapack", nil)
61
61
  end
62
62
  end
63
63
 
64
- sitearchdir = Config::CONFIG["sitearchdir"]
64
+ sitearchdir = RbConfig::CONFIG["sitearchdir"]
65
65
  dir_config("narray", sitearchdir, sitearchdir)
66
66
  gem_path = nil
67
67
  begin
@@ -1,3 +1,7 @@
1
+ begin
2
+ require "rubygems"
3
+ rescue LoadError
4
+ end
1
5
  require "narray"
2
6
  require "numru/lapack.so"
3
7
 
@@ -0,0 +1,26 @@
1
+ require "numru/lapack"
2
+
3
+ uplo = "L"
4
+ p a = NArray[[ 4.16, -3.12, 0.56, -0.10],
5
+ [-3.12, 5.03, -0.83, 1.18],
6
+ [ 0.56, -0.83, 0.76, 0.34],
7
+ [-0.10, 1.18, 0.34, 1.18]]
8
+ a_org = a.dup
9
+ info, a = NumRu::Lapack.dpotrf(uplo, a)
10
+
11
+ p info
12
+ p a
13
+
14
+ for i in 0...a.shape[0]
15
+ for j in 0...i
16
+ a[j,i] = 0.0
17
+ end
18
+ end
19
+
20
+ a = NMatrix.ref(a)
21
+
22
+ if (NArray.ref(a.transpose * a) - a_org).abs.gt(1.0e-10).count_true == 0
23
+ p "OK"
24
+ else
25
+ p "NG"
26
+ end
@@ -0,0 +1,63 @@
1
+ $:.push File.dirname(__FILE__) + "/../.."
2
+ require "lapack_test"
3
+
4
+ class SysvTest < Test::Unit::TestCase
5
+ include LapackTest
6
+
7
+ def setup
8
+ @a = Hash.new
9
+ @b = Hash.new
10
+ @b_exp = Hash.new
11
+ @ipiv_exp = Hash.new
12
+
13
+ @a[:r] = NMatrix[[-1.81, 2.06, 0.63, -1.15],
14
+ [ 2.06, 1.15, 1.87, 4.20],
15
+ [ 0.63, 1.87, -0.21, 3.87],
16
+ [-1.15, 4.20, 3.87, 2.07]].to_lm
17
+ @b[:r] = NVector[[0.96, 6.07, 8.38, 9.50]]
18
+ @b_exp[:r] = NArray[[-5.0, -2.0, 1.0, 4.0]]
19
+ @ipiv_exp[:r] = NArray[1, 2, -2, -2]
20
+
21
+ @a[:c] = NMatrix[[-0.56+0.12*I, -1.54-2.86*I, 5.32-1.59*I, 3.80+0.92*I],
22
+ [-1.54-2.86*I, -2.83-0.03*I, -3.52+0.58*I, -7.86-2.96*I],
23
+ [ 5.32-1.59*I, -3.52+0.58*I, 8.86+1.81*I, 5.14-0.64*I],
24
+ [ 3.80+0.92*I, -7.86-2.96*I, 5.14-0.64*I, -0.39-0.71*I]].to_lm
25
+ @b[:c] = NVector[[-6.43+19.24*I, -0.49-1.47*I, -48.18+66.0*I, -55.64+41.22*I]]
26
+ @b_exp[:c] = NArray[[-4.0+3.0*I, 3.0-2.0*I, -2.0+5.0*I, 1.0-1.0*I]]
27
+ @ipiv_exp[:c] = NArray[1, 2, -2, -2]
28
+ end
29
+
30
+ %w(s d c z).each do |x|
31
+ method = "#{x}sysv"
32
+ rc = LapackTest.get_rc(x)
33
+
34
+ define_method("test_#{method}") do
35
+ ipiv, work, info, a, b = NumRu::Lapack.send(method, "U", @a[rc], @b[rc])
36
+ assert_equal 0, info
37
+ assert_narray @b_exp[rc], b
38
+ assert_narray @ipiv_exp[rc], ipiv
39
+ end
40
+
41
+ define_method("test_#{method}_inquiring_lwork") do
42
+ rank, work, info, = NumRu::Lapack.send(method, "U", @a[rc], @b[rc], :lwork => -1)
43
+ assert_equal 0, info
44
+ lwork = get_int(work[0])
45
+ ipiv, work, info, a, b = NumRu::Lapack.send(method, "U", @a[rc], @b[rc], :lwork => lwork)
46
+ assert_equal 0, info
47
+ assert_equal lwork, get_int(work[0])
48
+ assert_narray @b_exp[rc], b
49
+ assert_narray @ipiv_exp[rc], ipiv
50
+ end
51
+
52
+ define_method("test_#{method}_inquiring_lwork_oldargstyle") do
53
+ rank, work, info, = NumRu::Lapack.send(method, "U", @a[rc], @b[rc], :lwork => -1)
54
+ assert_equal 0, info
55
+ lwork = get_int(work[0])
56
+ rank, work, info, = NumRu::Lapack.send(method, "U", @a[rc], @b[rc], -1)
57
+ assert_equal 0, info
58
+ assert_equal lwork, get_int(work[0])
59
+ end
60
+
61
+ end
62
+
63
+ end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lapack
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: "1.5"
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 6
9
+ version: "1.6"
6
10
  platform: ruby
7
11
  authors:
8
12
  - Seiya Nishizawa
@@ -10,7 +14,8 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-05-02 00:00:00 Z
17
+ date: 2014-03-12 00:00:00 +09:00
18
+ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: narray
@@ -20,6 +25,9 @@ dependencies:
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
23
31
  version: "0"
24
32
  type: :runtime
25
33
  version_requirements: *id001
@@ -1673,6 +1681,7 @@ files:
1673
1681
  - GPL
1674
1682
  - README.rdoc
1675
1683
  - samples/dsyevr.rb
1684
+ - samples/dpotrf.rb
1676
1685
  - dev/common.rb
1677
1686
  - dev/mkdoc.rb
1678
1687
  - dev/parse.rb
@@ -3321,8 +3330,10 @@ files:
3321
3330
  - tests/lin/ge/test_gelsy.rb
3322
3331
  - tests/lin/ge/test_gesv.rb
3323
3332
  - tests/lin/gt/test_gtsv.rb
3333
+ - tests/lin/sy/test_sysv.rb
3324
3334
  - tests/lapack_test.rb
3325
3335
  - ext/extconf.rb
3336
+ has_rdoc: true
3326
3337
  homepage: http://ruby.gfd-dennou.org/products/ruby-lapack/
3327
3338
  licenses: []
3328
3339
 
@@ -3336,17 +3347,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
3336
3347
  requirements:
3337
3348
  - - ">="
3338
3349
  - !ruby/object:Gem::Version
3350
+ hash: 3
3351
+ segments:
3352
+ - 0
3339
3353
  version: "0"
3340
3354
  required_rubygems_version: !ruby/object:Gem::Requirement
3341
3355
  none: false
3342
3356
  requirements:
3343
3357
  - - ">="
3344
3358
  - !ruby/object:Gem::Version
3359
+ hash: 3
3360
+ segments:
3361
+ - 0
3345
3362
  version: "0"
3346
3363
  requirements: []
3347
3364
 
3348
3365
  rubyforge_project:
3349
- rubygems_version: 1.7.2
3366
+ rubygems_version: 1.3.7
3350
3367
  signing_key:
3351
3368
  specification_version: 3
3352
3369
  summary: A Ruby wrapper of Lapack
@@ -3365,4 +3382,5 @@ test_files:
3365
3382
  - tests/lin/ge/test_gelsy.rb
3366
3383
  - tests/lin/ge/test_gesv.rb
3367
3384
  - tests/lin/gt/test_gtsv.rb
3385
+ - tests/lin/sy/test_sysv.rb
3368
3386
  - tests/lapack_test.rb