Module | JBLAS::MatrixAccessMixin |
In: |
lib/jblas/mixin_access.rb
|
Mixin for all kinds of element access.
This mixin is collected into MatrixMixin.
You have the following options of accessing elements:
As indices, you can use one of the following:
For some access functions (in particular getting rows and columns), you can also specify where to copy the result to get better performance through suppressing object creations.
Get the entry at i, j. If j is omitted, linear addressing is used (that is, i just enumerates all entries going down rows first.)
As indices you can use numbers, int[] arrays, matrices (non-zero elements are taken as indices then), and ranges.
# File lib/jblas/mixin_access.rb, line 90 def [](i, j=nil) if j get(i.to_indices, j.to_indices) else get(i.to_indices) end end
Set the entry at i, j to v. If j is omitted, linear addressing is used (that is, i just enumerates all entries going down rows first.)
As indices you can use numbers, int[] arrays, matrices (non-zero elements are taken as indices then), and ranges.
# File lib/jblas/mixin_access.rb, line 104 def []=(i, j, v=nil) if v put(i.to_indices, j.to_indices, v) else put(i.to_indices, j) end end
Get a column of a matrix. Unlike column(i) method, this method returns a copy of the given column.
# File lib/jblas/mixin_access.rb, line 125 def get_column(i); JAVA_METHOD; end
Get a copy of columns j1 .. j2 - 1 from row i.
# File lib/jblas/mixin_access.rb, line 137 def get_column_range(i, j1, j2); JAVA_METHOD; end
Get a number of rows.
As indices you can use numbers, int[] arrays, matrices (non-zero elements are taken as indices then), and ranges.
# File lib/jblas/mixin_access.rb, line 131 def get_columns(i); JAVA_METHOD; end
Get a copy of the submatrix with rows i1 .. i2 - 1 and columns j1 .. j2 - 1.
# File lib/jblas/mixin_access.rb, line 141 def get_range(i1, i2, j1, j2); JAVA_METHOD; end
Get row of a matrix. Unlike the row(i) method, this method returns a copy of the given row. If result is given, the row is copied in that matrix.
# File lib/jblas/mixin_access.rb, line 115 def get_row(i, result=nil); JAVA_METHOD; end
Get a copy of rows i1 .. i2 - 1 from column j.
# File lib/jblas/mixin_access.rb, line 134 def get_row_range(i1, i2, j); JAVA_METHOD; end
Get a number of rows.
As indices you can use numbers, int[] arrays, matrices (non-zero elements are taken as indices then), and ranges.
# File lib/jblas/mixin_access.rb, line 121 def get_rows(i); JAVA_METHOD; end