Class: Digiproc::Strategies::GramSchmidtOrthonormalize

Inherits:
Object
  • Object
show all
Defined in:
lib/strategies/orthogonalize/gram_schmidt.rb

Overview

Class to orthonormalize a set of numbers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matrix) ⇒ GramSchmidtOrthonormalize

Input Args

matrix

2D array, each row is a set of numbers that should be orthogonalized



10
11
12
13
14
15
16
17
# File 'lib/strategies/orthogonalize/gram_schmidt.rb', line 10

def initialize(matrix)
    @original_vectors = matrix
    # if matrix.is_a? Array
    #     matrix = Vector.elements(matrix)
    # end
    vector_matrix = matrix.map { |vector| vector.is_a?(Array) ? Vector.elements(vector) : vector }
    @orthonormalized_matrix = gram_schmidt(vector_matrix)
end

Instance Attribute Details

#original_matrixObject (readonly)

Returns the value of attribute original_matrix.



5
6
7
# File 'lib/strategies/orthogonalize/gram_schmidt.rb', line 5

def original_matrix
  @original_matrix
end

#orthonormalized_matrixObject (readonly)

Returns the value of attribute orthonormalized_matrix.



5
6
7
# File 'lib/strategies/orthogonalize/gram_schmidt.rb', line 5

def orthonormalized_matrix
  @orthonormalized_matrix
end

Instance Method Details

#outputObject

No input arguments Output is a 2D array of Orthonormalized sets of numbers corresponding to the input set of numbers



22
23
24
# File 'lib/strategies/orthogonalize/gram_schmidt.rb', line 22

def output
    @orthonormalized_matrix.map{|vector| vector.to_a } 
end