Module: StairCar

Defined in:
lib/stair_car/pmatrix/types.rb,
lib/stair_car.rb,
lib/stair_car/shared/errors.rb,
lib/stair_car/umatrix/types.rb,
lib/stair_car/shared/inspect.rb,
lib/stair_car/shared/methods.rb,
lib/stair_car/pmatrix/compare.rb,
lib/stair_car/pmatrix/pmatrix.rb,
lib/stair_car/shared/indicies.rb,
lib/stair_car/umatrix/compare.rb,
lib/stair_car/umatrix/umatrix.rb,
lib/stair_car/shared/iteration.rb,
lib/stair_car/pmatrix/transforms.rb,
lib/stair_car/umatrix/transforms.rb,
lib/stair_car/pmatrix/matrix_math.rb,
lib/stair_car/shared/init_methods.rb,
lib/stair_car/umatrix/matrix_math.rb

Overview

Handles converting indicies into arrays of row or column offsets

Defined Under Namespace

Modules: Indicies, InitMethods, Inspect, Iteration, Methods, PMatrixCompare, PMatrixMatrixMath, PMatrixTransforms, PMatrixTypes, UMatrixCompare, UMatrixMatrixMath, UMatrixTransforms, UMatrixTypes Classes: IncorrectMatrixDimensions, InverseMatrixIsSignular, MatrixDimensionsError, PMatrix, UMatrix

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/stair_car.rb', line 8

def self.included(klass)
  # Add easy access methods
  PMatrix.init_method_names do |method_name, sparse, type, initialize_values|
    klass.send(:define_method, method_name) do |cols, rows|
      PMatrix.new(cols, rows, type, sparse, initialize_values)
    end
  end
end

Instance Method Details

#to_java_nested_array(array, type = :double) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stair_car.rb', line 17

def to_java_nested_array(array, type=:double)
  if type == :double
    type = java.lang.Double::TYPE
  else
    type = java.lang.Float::TYPE
  end

  rows = array.size
  cols = array[0].size

  java_array = java.lang.reflect.Array.newInstance(type, [rows,cols].to_java(:int))

  rows.times do |row|
    cols.times do |col|
      java_array[row][col] = array[row][col]
    end
  end

  return java_array
end