lib/eigen.rb in ruby-eigen-0.0.10.pre1 vs lib/eigen.rb in ruby-eigen-0.0.10
- old
+ new
@@ -91,10 +91,11 @@
j0 = r.begin >= 0 ? r.begin : r.begin + cols()
col_size = r.end >= 0 ? r.size : r.end + cols() + 1
end
return [j0, col_size]
end
+ private "row_range", "col_range"
def [](i,j)
return __get_item__(i,j) if i.is_a?(Numeric) and j.is_a?(Numeric)
if i == true
@@ -107,9 +108,24 @@
else
j0, col_size = col_range(j)
end
return __get_block__(i0, j0, row_size, col_size)
+ end
+
+ def ref(range0, range1)
+ if range0 == true
+ i0, row_size = 0, rows()
+ else
+ i0, row_size = row_range(range0)
+ end
+ if range1 == true
+ j0, col_size = 0, cols()
+ else
+ j0, col_size = col_range(range1)
+ end
+
+ return __ref__(i0, j0, row_size, col_size)
end
def to_a
ret = Array.new(rows())
(0..(rows()-1)).each{|i|