Module: Colt::Matrix1DAlgebra

Included in:
DoubleMDMatrix1D, FloatMDMatrix1D, IntMDMatrix1D, LongMDMatrix1D
Defined in:
lib/colt/matrix/algebra.rb

Instance Method Summary collapse

Instance Method Details

#mult(other_val, from = 0, length = other_val.size) ⇒ Object Also known as: *


Returns the dot product of two vectors x and y, which is Sum(x*y).




43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/colt/matrix/algebra.rb', line 43

def mult(other_val, from = 0, length = other_val.size)

  p "mult"
  @mdarray.print
  other_val.mdarray.print
  printf("\n\n")

  if (other_val.is_a? Numeric)
    MDMatrix.from_mdarray(@mdarray * other_val)
  elsif (other_val.is_a? MDMatrix)
    if (other_val.rank == 2)
      MDMatrix
        .from_colt_matrix(other_val.transpose.colt_matrix.zMult(@colt_matrix, nil))
    else
      p "other_val.rank = #{other_val.rank}"
      @colt_matrix.zDotProduct(other_val.colt_matrix, from, length)
    end
  else
    raise "Cannot multiply matrix by given value"
  end
  
end