Skip to content

Commit 01fc3f3

Browse files
committed
With basic hint
1 parent cd1d3d0 commit 01fc3f3

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

sig/matrix.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type numeric = Integer | Float | Rational | Complex
2+
3+
class Matrix
4+
@rows : Array[Array[numeric]]
5+
end
6+
7+
class Vector
8+
@elements : Array[numeric]
9+
end

sig/matrix_gen.rbs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Matrix
66
include Enumerable
77
include ExceptionForMatrix
88
extend ConversionHelper
9-
attr_reader rows : (Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[(Integer | String)?] | Array[Integer] | Array[String?] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Integer | String)?] | Array[(Array[(Integer | String)?] | Array[Vector?] | Integer | String)?] | Array[(Array[(Integer | String)?] | Array[nil] | Integer | String)?] | Array[(Array[(Integer | String)?] | Integer | String)?] | Array[(Array[(Integer | String)?] | String)?] | Array[Array[Integer]] | Array[Array[untyped]] | String)?
9+
attr_reader rows : (Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[Integer] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Array[Vector?] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Array[nil] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Complex | Float | Integer | Rational | String)?] | Array[Array[Integer]] | Array[Array[untyped]] | String)?
1010
attr_reader column_count : (Complex | Float | Integer | Matrix | Range | Rational)?
1111
def self.[] : (*Vector) -> Matrix
1212
def self.rows : (Array[Array[Vector] | Vector], ?bool) -> Matrix
@@ -23,15 +23,15 @@ class Matrix
2323
def self.hstack : (Matrix, *untyped) -> Matrix
2424
def self.combine : (*Matrix) ?{ (Array[nil]) -> untyped } -> (Enumerator[untyped] | Matrix)
2525
def combine : (*untyped) ?{ (Array[nil]) -> untyped } -> (Enumerator[untyped] | Matrix)
26-
def initialize : ((Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[(Integer | String)?] | Array[Integer] | Array[String?] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Integer | String)?] | Array[(Array[(Integer | String)?] | Array[Vector?] | Integer | String)?] | Array[(Array[(Integer | String)?] | Array[nil] | Integer | String)?] | Array[(Array[(Integer | String)?] | Integer | String)?] | Array[(Array[(Integer | String)?] | String)?] | Array[Array[Integer]] | Array[Array[untyped]] | String)?, ?(Complex | Float | Integer | Matrix | Range | Rational)?) -> ((Complex | Float | Integer | Matrix | Range | Rational)?)
26+
def initialize : ((Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[Integer] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Array[Vector?] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Array[nil] | Complex | Float | Integer | Rational | String)?] | Array[(Array[(Complex | Float | Integer | Rational | String)?] | Complex | Float | Integer | Rational | String)?] | Array[Array[Integer]] | Array[Array[untyped]] | String)?, ?(Complex | Float | Integer | Matrix | Range | Rational)?) -> ((Complex | Float | Integer | Matrix | Range | Rational)?)
2727
def new_matrix : (Array[(Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[Complex | Float | Integer | Rational] | Array[Integer] | Enumerator[untyped] | Integer | Matrix | String | Vector)?] | Array[Array[untyped]], ?(Complex | Float | Integer | Matrix | Range | Rational)?) -> Matrix
2828
def [] : (Integer?, Integer?) -> nil
29-
def []= : (untyped, untyped, untyped) -> (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[(Integer | String)?] | Array[String?] | Array[untyped] | Enumerable[untyped, untyped] | Enumerator[untyped] | Matrix | Range | Vector)
29+
def []= : (untyped, untyped, untyped) -> (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[untyped] | Enumerable[untyped, untyped] | Enumerator[untyped] | Matrix | Range | Vector)
3030
def check_range : (untyped, :column | :row) -> Range?
3131
def check_int : (untyped, :column | :row) -> ((Complex | Float | Integer | Matrix | Range | Rational)?)
3232
def set_value : ((Complex | Float | Integer | Matrix | Range | Rational)?, (Complex | Float | Integer | Matrix | Range | Rational)?, untyped) -> untyped
3333
def set_row_and_col_range : (Range, Range, untyped) -> (Enumerable[untyped, untyped] | Range)
34-
def set_row_range : (Range, (Complex | Float | Integer | Matrix | Range | Rational)?, untyped) -> (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[(Integer | String)?] | Array[String?] | Enumerator[untyped] | Matrix | Vector)
34+
def set_row_range : (Range, (Complex | Float | Integer | Matrix | Range | Rational)?, untyped) -> (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Enumerator[untyped] | Matrix | Vector)
3535
def set_column_vector : (Range, (Complex | Float | Integer | Matrix | Range | Rational)?, untyped) -> untyped
3636
def set_col_range : ((Complex | Float | Integer | Matrix | Range | Rational)?, Range, untyped) -> Array[untyped]
3737
def row_count : -> Integer
@@ -66,7 +66,7 @@ class Matrix
6666
def zero? : -> bool
6767
def == : ((Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Range | Rational | String | Vector)?) -> bool
6868
def eql? : (untyped) -> bool
69-
def initialize_copy : (untyped) -> Array[String]?
69+
def initialize_copy : (untyped) -> (Array[Integer | String]?)
7070
def hash : -> Integer
7171
def * : ((Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> ((Matrix | Vector)?)
7272
def + : ((Array[Vector] | Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Range | Rational | String | Vector)?) -> Matrix
@@ -100,15 +100,15 @@ class Matrix
100100
def row_vectors : -> (Array[(Matrix | Vector)?])
101101
def column_vectors : -> (Array[(Matrix | Vector)?])
102102
def to_matrix : -> Matrix
103-
def to_a : -> Array[String?]
103+
def to_a : -> (Array[(Integer | String)?])
104104
def elements_to_f : -> Array[untyped]
105105
def elements_to_i : -> Array[untyped]
106106
def elements_to_r : -> Array[untyped]
107107
def to_s : -> String
108108
def inspect : -> String
109109

110110
module ConversionHelper
111-
def convert_to_array : ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[String?] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?, ?bool) -> ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[String?])?)
111+
def convert_to_array : ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?, ?bool) -> ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?])?)
112112
end
113113

114114
module CoercionHelper
@@ -156,21 +156,21 @@ class Vector
156156
include ExceptionForMatrix
157157
include Matrix::CoercionHelper
158158
extend Matrix::ConversionHelper
159-
attr_reader elements : (Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[String?])?
159+
attr_reader elements : (Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?])?
160160
def self.[] : (*(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> Vector
161-
def self.elements : (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[String?] | Enumerator[untyped], ?bool) -> Vector
161+
def self.elements : (Array[(Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Enumerator[untyped], ?bool) -> Vector
162162
def self.basis : (size: Integer, index: Integer) -> Vector
163163
def self.zero : (untyped) -> Vector
164-
def initialize : ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[String?])?) -> ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[String?])?)
164+
def initialize : ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?])?) -> ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?])?)
165165
def [] : (Integer) -> ((Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?)
166166
def []= : ((Complex | Float | Integer | Matrix | Range | Rational)?, (Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> ((Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[untyped] | Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[untyped] | Complex | Float | Integer | Numeric | Rational | String)?] | Array[Array[untyped] | Complex | Float | Integer | Numeric | Rational | String] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?)
167167
def set_value : ((Complex | Float | Integer | Matrix | Range | Rational)?, (Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> ((Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?)
168-
def set_range : (Range, (Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> ((Array[(Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Integer | String)?] | Array[Array[untyped] | Complex | Float | Integer | Numeric | Rational | String] | Array[untyped])?)
168+
def set_range : (Range, (Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> ((Array[(Array[Vector] | Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Array[untyped] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Matrix | Rational | String | Vector)?] | Array[(Complex | Float | Integer | Rational | String)?] | Array[Array[untyped] | Complex | Float | Integer | Numeric | Rational | String] | Array[untyped])?)
169169
def round : (?Integer) -> Array[untyped]
170170
def size : -> Integer
171171
def each : ?{ ((Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> untyped } -> (Enumerator[untyped] | Vector)
172172
def each2 : (untyped) ?{ ((Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?, untyped) -> (Complex | Float | Integer | Rational) } -> (Enumerator[untyped] | Vector)
173-
def collect2 : (Vector) ?{ ((Complex | Float | Integer | Matrix | Rational | String | Vector)?, (Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> (Complex | Float | Integer | Matrix | Rational | String | Vector) } -> (Array[Complex | Float | Integer | Matrix | Rational | String | Vector] | Array[untyped] | Enumerator[untyped])
173+
def collect2 : (Vector) ?{ ((Complex | Float | Integer | Matrix | Numeric | Rational | String | Vector)?, (Array[Vector] | Complex | Enumerator[untyped] | Float | Integer | Matrix | Numeric | Rational | String | Vector)?) -> (Complex | Float | Integer | Matrix | Rational | String | Vector) } -> (Array[Complex | Float | Integer | Matrix | Rational | String | Vector] | Array[untyped] | Enumerator[untyped])
174174
def self.independent? : (*Vector) -> bool
175175
def independent? : (*untyped) -> bool
176176
def zero? : -> bool

0 commit comments

Comments
 (0)