rmatrix 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66edec4fe60372252f4542b6c2adf5e7ff88349e
4
- data.tar.gz: 363d633958bce93fb9ae62de0aa8d12ba1c441bc
3
+ metadata.gz: b03156a99a7338c06f4bde90d9c21af4323e3a75
4
+ data.tar.gz: 9c3229920bcb608b8cec92320e2f5c4119d93966
5
5
  SHA512:
6
- metadata.gz: cadab96ed60b3bc2912abe69502ef76ed8739a15834fe32938188b1a011e1906b2e10334f7d79853761263f494e842390bf4a28af7e47cafa35392fc330d8c36
7
- data.tar.gz: 7d6ba92b3df5794e9a315d788b994b454825d54745dd93c62c987a2547d1288976be17ab63ebb3a73b871da0ca4b5a1d22e2e52f04152c802a2728b11bb008c5
6
+ metadata.gz: 2f3d4b98cdb9cb7fde56f80fa4988c9bbf88387c136dd0487ee0192e533d61c0a06a5ed070f6dbdbcc48fa932cf73ab9b216219123e7802ad82a0bce8c6343db
7
+ data.tar.gz: 8e19dfaf471c07dbaf8463ab646bb5c9c1f440f2d20ad2f71e8ab4b519f3488d0c2fea61031f7c5f296fff713fb433d82b8d492aafed85d1c453869b881c3bd9
@@ -0,0 +1,17 @@
1
+ require 'rmatrix'
2
+
3
+ m1 = M[
4
+ [1,2,3],
5
+ [4,5,6]
6
+ ]
7
+
8
+ m2 = M[
9
+ [5,2],
10
+ [9,4],
11
+ [3,4]
12
+ ]
13
+
14
+ RMatrix::GPU.exec do
15
+ buffer_two = m1.buffer * m2.buffer
16
+ buffer_two * M[[1,2],[3,4]]
17
+ end
data/lib/rmatrix/core.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require_relative "matrix"
2
2
  require_relative "vector"
3
- require_relative "print_table"
3
+ require_relative "printing/matrix_table"
@@ -58,6 +58,21 @@ module RMatrix
58
58
  narray.to_s << ':' << columns.to_s << ':' << rows.to_s << ':' << narray.typecode.to_s
59
59
  end
60
60
 
61
+ def to_f
62
+ if length === 1
63
+ self[0].to_f
64
+ else
65
+ raise "Can only call to_f on vectors of length 1"
66
+ end
67
+ end
68
+
69
+ def to_i
70
+ if length === 1
71
+ self[0].to_i
72
+ else
73
+ raise "Can only call to_i on vectors of length 1"
74
+ end
75
+ end
61
76
  def self._load arg
62
77
  split_index, buffer, index = 0, '', arg.length - 1
63
78
  split = Array.new(3)
@@ -1,3 +1,5 @@
1
+ require 'rmatrix/printing/print_table'
2
+
1
3
  module RMatrix
2
4
  class MatrixTable < PrintTable
3
5
  def initialize(matrix, max_columns: 10, max_rows: 10)
@@ -80,7 +80,7 @@ TEX
80
80
  end
81
81
 
82
82
  def numeric_to_truncated_string(numeric)
83
- ("%-.4e" % numeric).gsub(/(?<!\.)0+e/,'e').gsub('.e+00','').gsub('e+00','')
83
+ numeric.to_s
84
84
  end
85
85
 
86
86
  def [](column, row)
@@ -101,7 +101,4 @@ TEX
101
101
  self.row_count = [self.row_count || 0 , idx.succ].max
102
102
  end
103
103
  end
104
-
105
-
106
104
  end
107
- require_relative 'matrix_table'
@@ -1,14 +1,14 @@
1
1
  module RMatrix
2
2
  class Matrix
3
3
  module Typecode
4
- BYTE = 1
5
- SINT = 2
6
- INT = 3
7
- SFLOAT = 4
8
- FLOAT = 5
4
+ BYTE = 1
5
+ SINT = 2
6
+ INT = 3
7
+ SFLOAT = 4
8
+ FLOAT = 5
9
9
  SCOMPLEX = 6
10
- COMPLEX = 7
11
- OBJECT = 8
10
+ COMPLEX = 7
11
+ OBJECT = 8
12
12
  end
13
13
  end
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module RMatrix
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2018-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,12 +154,13 @@ files:
154
154
  - Rakefile
155
155
  - bin/console
156
156
  - bin/setup
157
+ - examples/gpu_example.rb
157
158
  - lib/rmatrix.rb
158
159
  - lib/rmatrix/core.rb
159
160
  - lib/rmatrix/indices.rb
160
161
  - lib/rmatrix/matrix.rb
161
- - lib/rmatrix/matrix_table.rb
162
- - lib/rmatrix/print_table.rb
162
+ - lib/rmatrix/printing/matrix_table.rb
163
+ - lib/rmatrix/printing/print_table.rb
163
164
  - lib/rmatrix/shortcuts.rb
164
165
  - lib/rmatrix/typecode.rb
165
166
  - lib/rmatrix/vector.rb