Method: EpiMath::Matrix.mult_array
- Defined in:
- lib/epimath100/matrix.class.rb
.mult_array(t1, t2) ⇒ Object
Parameters:
- t1,t2
-
Multiply each elements of t1 and t2 2b2 and sum all
Returns:
Float
208 209 210 211 212 213 214 215 216 217 |
# File 'lib/epimath100/matrix.class.rb', line 208 def self.mult_array(t1, t2) Error.call "Can't multiply this. One of the arguments is not an array.", Error::ERR_HIGH if (!t1.is_a?Array or !t2.is_a?Array) Error.call "Can't multiply this. Arrays do not have the same size.", Error::ERR_HIGH if t1.size != t2.size result = 0.0 t1.size.times do |i| result = (result + t1[i].to_f * t2[i].to_f).to_f end return result end |