Class: Reem::LowerTriangularMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/reem/lower_triangular_matrix.rb

Instance Method Summary collapse

Constructor Details

#initialize(matrix) ⇒ LowerTriangularMatrix

Returns a new instance of LowerTriangularMatrix.



3
4
5
6
7
8
9
10
11
12
# File 'lib/reem/lower_triangular_matrix.rb', line 3

def initialize(matrix)
  columns, rows = matrix.sizes
  @ltm = NArray.float(columns, rows)

  (0...columns).each do |i|
    (0..i).each do |j|
      @ltm[j,i] = matrix[j,i]
    end
  end
end

Instance Method Details

#transposeObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/reem/lower_triangular_matrix.rb', line 14

def transpose
  @transpose ||= begin
    columns, rows = @ltm.sizes
    matrix = NArray.float(columns, rows)
    (0...columns).each do |i|
      (0...rows).each do |j|
        matrix[i,j] = @ltm[j,i]
      end
    end
    matrix
  end
end