Class: RType::Matrix

Inherits:
Matrix
  • Object
show all
Includes:
Helper::MatrixMultiply, Helper::RObjDelegatable
Defined in:
lib/r_type/type/matrix.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper::MatrixMultiply

#*, #is_robj_matrix_multiply?

Methods included from Helper::RObjDelegatable

#==, #__getobj__, #as_r, included, #inspect, #robj, #robj=, #ruby_obj, #ruby_obj=, #to_ruby

Methods included from Helper::RObjDelegatable::ClassMethods

#delegate_constructor, #delegate_to_R

Methods included from CoreExt::NumericDelegateR

#*

Constructor Details

#initialize(obj, *args) ⇒ Matrix

Returns a new instance of Matrix.



14
15
16
17
18
19
20
21
22
23
# File 'lib/r_type/type/matrix.rb', line 14

def initialize obj, *args
  case obj
  when ::RObj
    @robj = obj
  when ::Matrix
    @ruby_obj = obj
  else
    raise "Not supported: #{obj} in RType::Matrix"
  end
end

Class Method Details

.match?(robj, type) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/r_type/type/matrix.rb', line 10

def self.match? robj, type
  type == 'matrix'
end

Instance Method Details

#[](*args) ⇒ Object



25
26
27
28
# File 'lib/r_type/type/matrix.rb', line 25

def [] *args
  args = convert_nil_args_to_vector(args)
  R['['].call self, *args
end

#[]=(*args) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/r_type/type/matrix.rb', line 30

def []= *args
  if args[0].is_a?(RType::Matrix)
    self.robj = R['[<-'].call(self, args[0], args[1]).robj
  else
    args = convert_nil_args_to_vector(args)
    self.robj = R['[<-'].call(self, *args).robj
  end
end

#column_sizeObject



43
44
45
# File 'lib/r_type/type/matrix.rb', line 43

def column_size
  R.ncol(self)
end

#row_sizeObject



39
40
41
# File 'lib/r_type/type/matrix.rb', line 39

def row_size
  R.nrow(self)
end