Class: MVector
- Inherits:
-
Vector
- Object
- Vector
- MVector
- Defined in:
- lib/cicada/mutable_matrix.rb
Overview
Extension to the standard library Vector class making them mutable and adding some additional functionality.
Class Method Summary collapse
-
.unit(size) ⇒ MVector
Generates a unit vector of specified size.
-
.zero(size) ⇒ MVector
Generates a zero vector of specified size.
Instance Method Summary collapse
-
#replace(other) ⇒ void
Replaces the contents of this vector with the contents of another vector.
Class Method Details
.unit(size) ⇒ MVector
Generates a unit vector of specified size.
102 103 104 105 106 |
# File 'lib/cicada/mutable_matrix.rb', line 102 def MVector.unit(size) MVector.elements(Array.new(size, 1.0), false) end |
.zero(size) ⇒ MVector
Generates a zero vector of specified size.
89 90 91 92 93 |
# File 'lib/cicada/mutable_matrix.rb', line 89 def MVector.zero(size) elements(Array.new(size, 0.0), false) end |
Instance Method Details
#replace(other) ⇒ void
This method returns an undefined value.
Replaces the contents of this vector with the contents of another vector. This will not change the size of the current vector and will replace entries only up to the current size.
118 119 120 121 122 123 124 125 126 |
# File 'lib/cicada/mutable_matrix.rb', line 118 def replace(other) self.each_with_index do |e,i| self[i] = other[i] end end |