nmatrix 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/.gitignore +27 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +3 -5
  4. data/Guardfile +6 -0
  5. data/History.txt +33 -0
  6. data/Manifest.txt +41 -38
  7. data/README.rdoc +88 -11
  8. data/Rakefile +35 -53
  9. data/ext/nmatrix/data/complex.h +372 -0
  10. data/ext/nmatrix/data/data.cpp +275 -0
  11. data/ext/nmatrix/data/data.h +707 -0
  12. data/ext/nmatrix/data/rational.h +421 -0
  13. data/ext/nmatrix/data/ruby_object.h +446 -0
  14. data/ext/nmatrix/extconf.rb +101 -51
  15. data/ext/nmatrix/new_extconf.rb +56 -0
  16. data/ext/nmatrix/nmatrix.cpp +1609 -0
  17. data/ext/nmatrix/nmatrix.h +265 -849
  18. data/ext/nmatrix/ruby_constants.cpp +134 -0
  19. data/ext/nmatrix/ruby_constants.h +103 -0
  20. data/ext/nmatrix/storage/common.cpp +70 -0
  21. data/ext/nmatrix/storage/common.h +170 -0
  22. data/ext/nmatrix/storage/dense.cpp +665 -0
  23. data/ext/nmatrix/storage/dense.h +116 -0
  24. data/ext/nmatrix/storage/list.cpp +1088 -0
  25. data/ext/nmatrix/storage/list.h +129 -0
  26. data/ext/nmatrix/storage/storage.cpp +658 -0
  27. data/ext/nmatrix/storage/storage.h +99 -0
  28. data/ext/nmatrix/storage/yale.cpp +1601 -0
  29. data/ext/nmatrix/storage/yale.h +208 -0
  30. data/ext/nmatrix/ttable_helper.rb +126 -0
  31. data/ext/nmatrix/{yale/smmp1_header.template.c → types.h} +36 -9
  32. data/ext/nmatrix/util/io.cpp +295 -0
  33. data/ext/nmatrix/util/io.h +117 -0
  34. data/ext/nmatrix/util/lapack.h +1175 -0
  35. data/ext/nmatrix/util/math.cpp +557 -0
  36. data/ext/nmatrix/util/math.h +1363 -0
  37. data/ext/nmatrix/util/sl_list.cpp +475 -0
  38. data/ext/nmatrix/util/sl_list.h +255 -0
  39. data/ext/nmatrix/util/util.h +78 -0
  40. data/lib/nmatrix/blas.rb +70 -0
  41. data/lib/nmatrix/io/mat5_reader.rb +567 -0
  42. data/lib/nmatrix/io/mat_reader.rb +162 -0
  43. data/lib/{string.rb → nmatrix/monkeys.rb} +49 -2
  44. data/lib/nmatrix/nmatrix.rb +199 -0
  45. data/lib/nmatrix/nvector.rb +103 -0
  46. data/lib/nmatrix/version.rb +27 -0
  47. data/lib/nmatrix.rb +22 -230
  48. data/nmatrix.gemspec +59 -0
  49. data/scripts/mac-brew-gcc.sh +47 -0
  50. data/spec/4x4_sparse.mat +0 -0
  51. data/spec/4x5_dense.mat +0 -0
  52. data/spec/blas_spec.rb +47 -0
  53. data/spec/elementwise_spec.rb +164 -0
  54. data/spec/io_spec.rb +60 -0
  55. data/spec/lapack_spec.rb +52 -0
  56. data/spec/math_spec.rb +96 -0
  57. data/spec/nmatrix_spec.rb +93 -89
  58. data/spec/nmatrix_yale_spec.rb +52 -36
  59. data/spec/nvector_spec.rb +1 -1
  60. data/spec/slice_spec.rb +257 -0
  61. data/spec/spec_helper.rb +51 -0
  62. data/spec/utm5940.mtx +83844 -0
  63. metadata +113 -71
  64. data/.autotest +0 -23
  65. data/.gemtest +0 -0
  66. data/ext/nmatrix/cblas.c +0 -150
  67. data/ext/nmatrix/dense/blas_header.template.c +0 -52
  68. data/ext/nmatrix/dense/elementwise.template.c +0 -107
  69. data/ext/nmatrix/dense/gemm.template.c +0 -159
  70. data/ext/nmatrix/dense/gemv.template.c +0 -130
  71. data/ext/nmatrix/dense/rationalmath.template.c +0 -68
  72. data/ext/nmatrix/dense.c +0 -307
  73. data/ext/nmatrix/depend +0 -18
  74. data/ext/nmatrix/generator/syntax_tree.rb +0 -481
  75. data/ext/nmatrix/generator.rb +0 -594
  76. data/ext/nmatrix/list.c +0 -774
  77. data/ext/nmatrix/nmatrix.c +0 -1977
  78. data/ext/nmatrix/rational.c +0 -98
  79. data/ext/nmatrix/yale/complexmath.template.c +0 -71
  80. data/ext/nmatrix/yale/elementwise.template.c +0 -46
  81. data/ext/nmatrix/yale/elementwise_op.template.c +0 -73
  82. data/ext/nmatrix/yale/numbmm.template.c +0 -94
  83. data/ext/nmatrix/yale/smmp1.template.c +0 -21
  84. data/ext/nmatrix/yale/smmp2.template.c +0 -43
  85. data/ext/nmatrix/yale/smmp2_header.template.c +0 -46
  86. data/ext/nmatrix/yale/sort_columns.template.c +0 -56
  87. data/ext/nmatrix/yale/symbmm.template.c +0 -54
  88. data/ext/nmatrix/yale/transp.template.c +0 -68
  89. data/ext/nmatrix/yale.c +0 -726
  90. data/lib/array.rb +0 -67
  91. data/spec/syntax_tree_spec.rb +0 -46
metadata CHANGED
@@ -1,112 +1,156 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nmatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Woods
9
+ - Chris Wailes
10
+ - Aleksey Timin
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000 Z
14
+ date: 2012-09-21 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
- name: rdoc
16
- requirement: &81217480 !ruby/object:Gem::Requirement
17
+ name: rake
18
+ requirement: &75615060 !ruby/object:Gem::Requirement
17
19
  none: false
18
20
  requirements:
19
21
  - - ~>
20
22
  - !ruby/object:Gem::Version
21
- version: '3.10'
23
+ version: '0.9'
22
24
  type: :development
23
25
  prerelease: false
24
- version_requirements: *81217480
26
+ version_requirements: *75615060
25
27
  - !ruby/object:Gem::Dependency
26
- name: rake-compiler
27
- requirement: &81217250 !ruby/object:Gem::Requirement
28
+ name: bundler
29
+ requirement: &75614870 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *75614870
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &75614590 !ruby/object:Gem::Requirement
28
41
  none: false
29
42
  requirements:
30
43
  - - ~>
31
44
  - !ruby/object:Gem::Version
32
- version: '0.7'
45
+ version: 2.9.0
33
46
  type: :development
34
47
  prerelease: false
35
- version_requirements: *81217250
48
+ version_requirements: *75614590
36
49
  - !ruby/object:Gem::Dependency
37
- name: hoe
38
- requirement: &81217030 !ruby/object:Gem::Requirement
50
+ name: pry
51
+ requirement: &75614320 !ruby/object:Gem::Requirement
39
52
  none: false
40
53
  requirements:
41
54
  - - ~>
42
55
  - !ruby/object:Gem::Version
43
- version: '3.0'
56
+ version: 0.9.9
44
57
  type: :development
45
58
  prerelease: false
46
- version_requirements: *81217030
47
- description: ! 'NMatrix is an experimental linear algebra library for Ruby, written
48
- mostly in C. It can be used with or without SciRuby, but is part of the SciRuby
49
- project.
50
-
51
-
52
- NMatrix was inspired by and based heavily upon {NArray}[http://narray.rubyforge.org],
53
- by Masahiro Tanaka.
54
-
55
-
56
- {<img src=https://www.pledgie.com/campaigns/15783.png?skin_name=chrome>}[http://www.pledgie.com/campaigns/15783]'
59
+ version_requirements: *75614320
60
+ - !ruby/object:Gem::Dependency
61
+ name: guard-rspec
62
+ requirement: &75614020 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.7.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *75614020
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake-compiler
73
+ requirement: &75613790 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.8.1
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *75613790
82
+ description: NMatrix is an experimental linear algebra library for Ruby, written mostly
83
+ in C.
57
84
  email:
58
85
  - john.o.woods@gmail.com
59
86
  executables: []
60
87
  extensions:
61
88
  - ext/nmatrix/extconf.rb
62
- extra_rdoc_files:
63
- - History.txt
64
- - Manifest.txt
65
- - README.rdoc
66
- - LICENSE.txt
89
+ extra_rdoc_files: []
67
90
  files:
68
- - .autotest
91
+ - .gitignore
92
+ - .rspec
93
+ - Gemfile
94
+ - Guardfile
69
95
  - History.txt
96
+ - LICENSE.txt
70
97
  - Manifest.txt
71
98
  - README.rdoc
72
- - LICENSE.txt
73
99
  - Rakefile
74
- - Gemfile
100
+ - ext/nmatrix/data/complex.h
101
+ - ext/nmatrix/data/data.cpp
102
+ - ext/nmatrix/data/data.h
103
+ - ext/nmatrix/data/rational.h
104
+ - ext/nmatrix/data/ruby_object.h
105
+ - ext/nmatrix/extconf.rb
106
+ - ext/nmatrix/new_extconf.rb
107
+ - ext/nmatrix/nmatrix.cpp
108
+ - ext/nmatrix/nmatrix.h
109
+ - ext/nmatrix/ruby_constants.cpp
110
+ - ext/nmatrix/ruby_constants.h
111
+ - ext/nmatrix/storage/common.cpp
112
+ - ext/nmatrix/storage/common.h
113
+ - ext/nmatrix/storage/dense.cpp
114
+ - ext/nmatrix/storage/dense.h
115
+ - ext/nmatrix/storage/list.cpp
116
+ - ext/nmatrix/storage/list.h
117
+ - ext/nmatrix/storage/storage.cpp
118
+ - ext/nmatrix/storage/storage.h
119
+ - ext/nmatrix/storage/yale.cpp
120
+ - ext/nmatrix/storage/yale.h
121
+ - ext/nmatrix/ttable_helper.rb
122
+ - ext/nmatrix/types.h
123
+ - ext/nmatrix/util/io.cpp
124
+ - ext/nmatrix/util/io.h
125
+ - ext/nmatrix/util/lapack.h
126
+ - ext/nmatrix/util/math.cpp
127
+ - ext/nmatrix/util/math.h
128
+ - ext/nmatrix/util/sl_list.cpp
129
+ - ext/nmatrix/util/sl_list.h
130
+ - ext/nmatrix/util/util.h
131
+ - lib/nmatrix.rb
132
+ - lib/nmatrix/blas.rb
133
+ - lib/nmatrix/io/mat5_reader.rb
134
+ - lib/nmatrix/io/mat_reader.rb
135
+ - lib/nmatrix/monkeys.rb
136
+ - lib/nmatrix/nmatrix.rb
137
+ - lib/nmatrix/nvector.rb
138
+ - lib/nmatrix/version.rb
139
+ - nmatrix.gemspec
140
+ - scripts/mac-brew-gcc.sh
141
+ - spec/4x4_sparse.mat
142
+ - spec/4x5_dense.mat
143
+ - spec/blas_spec.rb
144
+ - spec/elementwise_spec.rb
145
+ - spec/io_spec.rb
146
+ - spec/lapack_spec.rb
147
+ - spec/math_spec.rb
75
148
  - spec/nmatrix_spec.rb
76
149
  - spec/nmatrix_yale_spec.rb
77
150
  - spec/nvector_spec.rb
78
- - spec/syntax_tree_spec.rb
79
- - lib/array.rb
80
- - lib/nmatrix.rb
81
- - lib/string.rb
82
- - ext/nmatrix/cblas.c
83
- - ext/nmatrix/dense.c
84
- - ext/nmatrix/depend
85
- - ext/nmatrix/extconf.rb
86
- - ext/nmatrix/generator.rb
87
- - ext/nmatrix/list.c
88
- - ext/nmatrix/nmatrix.c
89
- - ext/nmatrix/nmatrix.h
90
- - ext/nmatrix/rational.c
91
- - ext/nmatrix/yale.c
92
- - ext/nmatrix/generator/syntax_tree.rb
93
- - ext/nmatrix/dense/blas_header.template.c
94
- - ext/nmatrix/dense/elementwise.template.c
95
- - ext/nmatrix/dense/gemm.template.c
96
- - ext/nmatrix/dense/gemv.template.c
97
- - ext/nmatrix/dense/rationalmath.template.c
98
- - ext/nmatrix/yale/smmp1.template.c
99
- - ext/nmatrix/yale/smmp2.template.c
100
- - ext/nmatrix/yale/smmp1_header.template.c
101
- - ext/nmatrix/yale/smmp2_header.template.c
102
- - ext/nmatrix/yale/sort_columns.template.c
103
- - ext/nmatrix/yale/symbmm.template.c
104
- - ext/nmatrix/yale/numbmm.template.c
105
- - ext/nmatrix/yale/transp.template.c
106
- - ext/nmatrix/yale/complexmath.template.c
107
- - ext/nmatrix/yale/elementwise.template.c
108
- - ext/nmatrix/yale/elementwise_op.template.c
109
- - .gemtest
151
+ - spec/slice_spec.rb
152
+ - spec/spec_helper.rb
153
+ - spec/utm5940.mtx
110
154
  homepage: http://sciruby.com
111
155
  licenses: []
112
156
  post_install_message: ! "***********************************************************\nWelcome
@@ -120,9 +164,7 @@ post_install_message: ! "*******************************************************
120
164
  explicit instructions for NMatrix and SciRuby should\nbe available on the SciRuby
121
165
  website, sciruby.com, or\nthrough our mailing list (which can be found on our web-\nsite).\n\nThanks
122
166
  for trying out NMatrix! Happy coding!\n\n***********************************************************\n"
123
- rdoc_options:
124
- - --main
125
- - README.rdoc
167
+ rdoc_options: []
126
168
  require_paths:
127
169
  - lib
128
170
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -130,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
172
  requirements:
131
173
  - - ! '>='
132
174
  - !ruby/object:Gem::Version
133
- version: '1.9'
175
+ version: 1.9.2
134
176
  required_rubygems_version: !ruby/object:Gem::Requirement
135
177
  none: false
136
178
  requirements:
@@ -139,12 +181,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
181
  version: '0'
140
182
  segments:
141
183
  - 0
142
- hash: -102996319
184
+ hash: -1003602253
143
185
  requirements: []
144
- rubyforge_project: nmatrix
186
+ rubyforge_project:
145
187
  rubygems_version: 1.8.10
146
188
  signing_key:
147
189
  specification_version: 3
148
190
  summary: NMatrix is an experimental linear algebra library for Ruby, written mostly
149
- in C
191
+ in C.
150
192
  test_files: []
data/.autotest DELETED
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'autotest/restart'
4
-
5
- # Autotest.add_hook :initialize do |at|
6
- # at.extra_files << "../some/external/dependency.rb"
7
- #
8
- # at.libs << ":../some/external"
9
- #
10
- # at.add_exception 'vendor'
11
- #
12
- # at.add_mapping(/dependency.rb/) do |f, _|
13
- # at.files_matching(/test_.*rb$/)
14
- # end
15
- #
16
- # %w(TestA TestB).each do |klass|
17
- # at.extra_class_map[klass] = "test/test_misc.rb"
18
- # end
19
- # end
20
-
21
- # Autotest.add_hook :run_command do |at|
22
- # system "rake build"
23
- # end
data/.gemtest DELETED
File without changes
data/ext/nmatrix/cblas.c DELETED
@@ -1,150 +0,0 @@
1
- /////////////////////////////////////////////////////////////////////
2
- // = NMatrix
3
- //
4
- // A linear algebra library for scientific computation in Ruby.
5
- // NMatrix is part of SciRuby.
6
- //
7
- // NMatrix was originally inspired by and derived from NArray, by
8
- // Masahiro Tanaka: http://narray.rubyforge.org
9
- //
10
- // == Copyright Information
11
- //
12
- // SciRuby is Copyright (c) 2010 - 2012, Ruby Science Foundation
13
- // NMatrix is Copyright (c) 2012, Ruby Science Foundation
14
- //
15
- // Please see LICENSE.txt for additional copyright notices.
16
- //
17
- // == Contributing
18
- //
19
- // By contributing source code to SciRuby, you agree to be bound by
20
- // our Contributor Agreement:
21
- //
22
- // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
- //
24
- // == cblas.c
25
- //
26
- // Functions in this file allow us to call CBLAS functions using
27
- // arrays of function pointers, by ensuring that each has the same
28
- // signature.
29
-
30
- #ifndef CBLAS_C
31
- # define CBLAS_C
32
-
33
- #include <cblas.h>
34
- #include "nmatrix.h"
35
-
36
- //extern const enum CBLAS_ORDER;
37
- //extern const enum CBLAS_TRANSPOSE;
38
-
39
-
40
- inline void cblas_r32gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
41
- if (Order == CblasColMajor) r32gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.r[0], p.A, p.lda, p.B, p.ldb, p.beta.r[0], p.C, p.ldc);
42
- else r32gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.r[0], p.B, p.ldb, p.A, p.lda, p.beta.r[0], p.C, p.ldc);
43
- }
44
-
45
- inline void cblas_r32gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
46
- r32gemv(TransA, p.M, p.N, p.alpha.r[0], p.A, p.lda, p.B, p.ldb, p.beta.r[0], p.C, p.ldc);
47
- }
48
-
49
- inline void cblas_r64gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
50
- if (Order == CblasColMajor) r64gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.ra[0], p.A, p.lda, p.B, p.ldb, p.beta.ra[0], p.C, p.ldc);
51
- else r64gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.ra[0], p.B, p.ldb, p.A, p.lda, p.beta.ra[0], p.C, p.ldc);
52
- }
53
-
54
- inline void cblas_r64gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
55
- r64gemv(TransA, p.M, p.N, p.alpha.ra[0], p.A, p.lda, p.B, p.ldb, p.beta.ra[0], p.C, p.ldc);
56
- }
57
-
58
- inline void cblas_r128gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
59
- if (Order == CblasColMajor) r128gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.rat, p.A, p.lda, p.B, p.ldb, p.beta.rat, p.C, p.ldc);
60
- else r128gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.rat, p.B, p.ldb, p.A, p.lda, p.beta.rat, p.C, p.ldc);
61
- }
62
-
63
- inline void cblas_r128gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
64
- r128gemv(TransA, p.M, p.N, p.alpha.rat, p.A, p.lda, p.B, p.ldb, p.beta.rat, p.C, p.ldc);
65
- }
66
-
67
- inline void cblas_bgemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
68
- bgemv(TransA, p.M, p.N, p.alpha.b[0], p.A, p.lda, p.B, p.ldb, p.beta.b[0], p.C, p.ldc);
69
- }
70
-
71
- inline void cblas_bgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
72
- if (Order == CblasColMajor) bgemm(TransA, TransB, p.M, p.N, p.K, p.alpha.b[0], p.A, p.lda, p.B, p.ldb, p.beta.b[0], p.C, p.ldc);
73
- else bgemm(TransB, TransA, p.N, p.M, p.K, p.alpha.b[0], p.B, p.ldb, p.A, p.lda, p.beta.b[0], p.C, p.ldc);
74
- }
75
-
76
- inline void cblas_i8gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
77
- i8gemv(TransA, p.M, p.N, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
78
- }
79
-
80
- inline void cblas_i8gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
81
- if (Order == CblasColMajor) i8gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
82
- else i8gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.i[0], p.B, p.ldb, p.A, p.lda, p.beta.i[0], p.C, p.ldc);
83
- }
84
-
85
- inline void cblas_i16gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
86
- i16gemv(TransA, p.M, p.N, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
87
- }
88
-
89
- inline void cblas_i16gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
90
- if (Order == CblasColMajor) i16gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
91
- else i16gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.i[0], p.B, p.ldb, p.A, p.lda, p.beta.i[0], p.C, p.ldc);
92
- }
93
-
94
- inline void cblas_i32gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
95
- i32gemv(TransA, p.M, p.N, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
96
- }
97
-
98
- inline void cblas_i32gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
99
- if (Order == CblasColMajor) i32gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
100
- else i32gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.i[0], p.B, p.ldb, p.A, p.lda, p.beta.i[0], p.C, p.ldc);
101
- }
102
-
103
- inline void cblas_i64gemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
104
- i64gemv(TransA, p.M, p.N, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
105
- }
106
-
107
- inline void cblas_i64gemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
108
- if (Order == CblasColMajor) i64gemm(TransA, TransB, p.M, p.N, p.K, p.alpha.i[0], p.A, p.lda, p.B, p.ldb, p.beta.i[0], p.C, p.ldc);
109
- else i64gemm(TransB, TransA, p.N, p.M, p.K, p.alpha.i[0], p.B, p.ldb, p.A, p.lda, p.beta.i[0], p.C, p.ldc);
110
- }
111
-
112
- inline void cblas_vgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
113
- if (Order == CblasColMajor) vgemm(TransA, TransB, p.M, p.N, p.K, p.alpha.v[0], p.A, p.lda, p.B, p.ldb, p.beta.v[0], p.C, p.ldc);
114
- else vgemm(TransB, TransA, p.N, p.M, p.K, p.alpha.v[0], p.B, p.ldb, p.A, p.lda, p.beta.v[0], p.C, p.ldc);
115
- }
116
-
117
- inline void cblas_sgemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
118
- cblas_sgemv(Order, TransA, p.M, p.N, p.alpha.d[0], p.A, p.lda, p.B, p.ldb, p.beta.d[0], p.C, p.ldc);
119
- }
120
-
121
- inline void cblas_sgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
122
- cblas_sgemm(Order, TransA, TransB, p.M, p.N, p.K, p.alpha.d[0], p.A, p.lda, p.B, p.ldb, p.beta.d[0], p.C, p.ldc);
123
- }
124
-
125
- inline void cblas_dgemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
126
- cblas_dgemv(Order, TransA, p.M, p.N, p.alpha.d[0], p.A, p.lda, p.B, p.ldb, p.beta.d[0], p.C, p.ldc);
127
- }
128
-
129
- inline void cblas_dgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
130
- cblas_dgemm(Order, TransA, TransB, p.M, p.N, p.K, p.alpha.d[0], p.A, p.lda, p.B, p.ldb, p.beta.d[0], p.C, p.ldc);
131
- }
132
-
133
- inline void cblas_cgemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
134
- cblas_cgemv(Order, TransA, p.M, p.N, &(p.alpha.c), p.A, p.lda, p.B, p.ldb, &(p.beta.c), p.C, p.ldc);
135
- }
136
-
137
- inline void cblas_cgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
138
- cblas_cgemm(Order, TransA, TransB, p.M, p.N, p.K, &(p.alpha.c), p.A, p.lda, p.B, p.ldb, &(p.beta.c), p.C, p.ldc);
139
- }
140
-
141
- inline void cblas_zgemv_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, DENSE_PARAM p) {
142
- cblas_zgemv(Order, TransA, p.M, p.N, &(p.alpha.z), p.A, p.lda, p.B, p.ldb, &(p.beta.z), p.C, p.ldc);
143
- }
144
-
145
- inline void cblas_zgemm_(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, DENSE_PARAM p) {
146
- cblas_zgemm(Order, TransA, TransB, p.M, p.N, p.K, &(p.alpha.z), p.A, p.lda, p.B, p.ldb, &(p.beta.z), p.C, p.ldc);
147
- }
148
-
149
-
150
- #endif
@@ -1,52 +0,0 @@
1
- /////////////////////////////////////////////////////////////////////
2
- // = NMatrix
3
- //
4
- // A linear algebra library for scientific computation in Ruby.
5
- // NMatrix is part of SciRuby.
6
- //
7
- // NMatrix was originally inspired by and derived from NArray, by
8
- // Masahiro Tanaka: http://narray.rubyforge.org
9
- //
10
- // == Copyright Information
11
- //
12
- // SciRuby is Copyright (c) 2010 - 2012, Ruby Science Foundation
13
- // NMatrix is Copyright (c) 2012, Ruby Science Foundation
14
- //
15
- // Please see LICENSE.txt for additional copyright notices.
16
- //
17
- // == Contributing
18
- //
19
- // By contributing source code to SciRuby, you agree to be bound by
20
- // our Contributor Agreement:
21
- //
22
- // * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
23
- //
24
- // == blas.c
25
- //
26
- // blas.c is automatically generated by generator.rb. Do not modify
27
- // it directly!
28
- //
29
- // This file contains C ports of BLAS functions that work on integer
30
- // types and eventually rationals. You can find the original template
31
- // in ext/nmatrix/blas/igemm.template.c.
32
- //
33
- // The port was accomplished using f2c (on dgemm.f) and a magnifying
34
- // glass.
35
- //
36
- // Note that this is in no way comparable to ATLAS. Why?
37
- // * We didn't test any options other than CblasNoTrans (for A and B)
38
- // * It doesn't use any of that cool cross-over crap (e.g.,
39
- // Strassen's algorithm)
40
- // * It really hasn't been tested exhaustively in any way, shape, or
41
- // form.
42
- //
43
- // This file also contains rational math helper functions so that the
44
- // aforementioned port will work with rationals too. These are in
45
- // ext/nmatrix/blas/rationalmath.template.c. They are derived from
46
- // rational.c in Ruby 1.9.3.
47
-
48
- #include "nmatrix.h"
49
-
50
-
51
-
52
-
@@ -1,107 +0,0 @@
1
-
2
- int nm_d_%%TYPE_ABBREV%%_elementwise(const %%TYPE%%* A, const %%TYPE%%* B, %%TYPE%%* C, size_t n, enum NMatrix_Ops op)
3
- {
4
- size_t i;
5
- //fprintf(stderr, "elementwise: n=%d, op=%c\n", n, op);
6
-
7
- switch (op) {
8
- case '+':
9
- for (i = 0; i < n; ++i) {
10
- %%TYPE C[i] = A[i] + B[i]%%
11
- }
12
- break;
13
- case '-':
14
- for (i = 0; i < n; ++i) {
15
- %%TYPE C[i] = A[i] - B[i]%%
16
- }
17
- break;
18
- case '*':
19
- for (i = 0; i < n; ++i) {
20
- %%TYPE C[i] = A[i] * B[i]%%
21
- }
22
- break;
23
- case '/':
24
- for (i = 0; i < n; ++i) {
25
- %%TYPE C[i] = A[i] / B[i]%%
26
- }
27
- break;
28
- case '%':
29
- for (i = 0; i < n; ++i) {
30
- %%TYPE C[i] = A[i] % B[i]%%
31
- }
32
- break;
33
- case '!':
34
- for (i = 0; i < n; ++i) {
35
- %%TYPE C[i] = !A[i]%%
36
- }
37
- break;
38
- case NM_OP_NEG:
39
- for (i = 0; i < n; ++i) {
40
- %%TYPE C[i] = -A[i]%%
41
- }
42
- break;
43
- case NM_OP_EQEQ:
44
- for (i = 0; i < n; ++i) {
45
- %%TYPE C[i] = A[i] == B[i]%%
46
- }
47
- break;
48
- case NM_OP_NEQ:
49
- for (i = 0; i < n; ++i) {
50
- %%TYPE C[i] = A[i] != B[i]%%
51
- }
52
- break;
53
- case '>':
54
- for (i = 0; i < n; ++i) {
55
- %%TYPE C[i] = A[i] > B[i]%%
56
- }
57
- break;
58
- case '<':
59
- for (i = 0; i < n; ++i) {
60
- %%TYPE C[i] = A[i] < B[i]%%
61
- }
62
- break;
63
- case NM_OP_GTE:
64
- for (i = 0; i < n; ++i) {
65
- %%TYPE C[i] = A[i] >= B[i]%%
66
- }
67
- break;
68
- case NM_OP_LTE:
69
- for (i = 0; i < n; ++i) {
70
- %%TYPE C[i] = A[i] <= B[i]%%
71
- }
72
- break;
73
- case '~':
74
- for (i = 0; i < n; ++i) {
75
- %%TYPE C[i] = ~A[i]%%
76
- }
77
- break;
78
- case '&':
79
- for (i = 0; i < n; ++i) {
80
- %%TYPE C[i] = A[i] & B[i]%%
81
- }
82
- break;
83
- case '|':
84
- for (i = 0; i < n; ++i) {
85
- %%TYPE C[i] = A[i] | B[i]%%
86
- }
87
- break;
88
- case '^':
89
- for (i = 0; i < n; ++i) {
90
- %%TYPE C[i] = A[i] ^ B[i]%%
91
- }
92
- break;
93
- case NM_OP_LSH:
94
- for (i = 0; i < n; ++i) {
95
- %%TYPE C[i] = A[i] << B[i]%%
96
- }
97
- break;
98
- case NM_OP_RSH:
99
- for (i = 0; i < n; ++i) {
100
- %%TYPE C[i] = A[i] >> B[i]%%
101
- }
102
- break;
103
- default:
104
- rb_raise(rb_eNotImpError, "Unrecognized element-wise operator");
105
- }
106
- return 0;
107
- }