Class: NMatrix
- Inherits:
-
Object
- Object
- NMatrix
- Defined in:
- lib/nmatrix/rowcol.rb
Instance Method Summary collapse
- #column(col_number, get_by = :copy) ⇒ Object (also: #col)
- #internal_column ⇒ Object
- #internal_row ⇒ Object
- #row(row_number, get_by = :copy) ⇒ Object
Instance Method Details
#column(col_number, get_by = :copy) ⇒ Object Also known as: col
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nmatrix/rowcol.rb', line 27 def column(col_number, get_by = :copy) if dim > 1 && col_numbers = get_row_or_col_index_array(col_number) out = NMatrix.new [rows, col_numbers.length], default_value, dtype: dtype, stype: stype col_numbers.each_with_index do |colnum, i| out[0..-1, i] = self[0..-1, colnum] end out else internal_column(col_number, get_by) end end |
#internal_column ⇒ Object
25 |
# File 'lib/nmatrix/rowcol.rb', line 25 alias_method :internal_column, :column |
#internal_row ⇒ Object
5 |
# File 'lib/nmatrix/rowcol.rb', line 5 alias_method :internal_row, :row |
#row(row_number, get_by = :copy) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nmatrix/rowcol.rb', line 7 def row(row_number, get_by = :copy) if row_numbers = get_row_or_col_index_array(row_number) out = NMatrix.new [row_numbers.length, cols].compact, default_value, dtype: dtype, stype: stype row_numbers.each_with_index do |rownum, i| if dim > 1 out[i, 0..-1] = self[rownum, 0..-1] else out[i] = self[rownum] end end out else internal_row(row_number, get_by) end end |