Class: Digiproc::Strategies::GramSchmidtOrthonormalize
- Inherits:
-
Object
- Object
- Digiproc::Strategies::GramSchmidtOrthonormalize
- Defined in:
- lib/strategies/orthogonalize/gram_schmidt.rb
Overview
Class to orthonormalize a set of numbers
Instance Attribute Summary collapse
-
#original_matrix ⇒ Object
readonly
Returns the value of attribute original_matrix.
-
#orthonormalized_matrix ⇒ Object
readonly
Returns the value of attribute orthonormalized_matrix.
Instance Method Summary collapse
-
#initialize(matrix) ⇒ GramSchmidtOrthonormalize
constructor
Input Args matrix:: 2D array, each row is a set of numbers that should be orthogonalized.
-
#output ⇒ Object
No input arguments Output is a 2D array of Orthonormalized sets of numbers corresponding to the input set of numbers.
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_matrix ⇒ Object (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_matrix ⇒ Object (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
#output ⇒ Object
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 |