Module: Colt::Matrix2DAlgebra
- Included in:
- DoubleMDMatrix2D, FloatMDMatrix2D, IntMDMatrix2D, LongMDMatrix2D
- Defined in:
- lib/colt/matrix/algebra.rb
Instance Method Summary collapse
-
#mult(other_val, alpha = 1, beta = 0, transA = false, transB = false, result = nil) ⇒ Object
(also: #*)
———————————————————————————— Linear algebraic matrix-matrix multiplication; C = alpha * A x B + beta*C.
-
#transpose ⇒ Object
———————————————————————————— Constructs and returns a new view which is the transposition of the given matrix A.
Instance Method Details
#mult(other_val, alpha = 1, beta = 0, transA = false, transB = false, result = nil) ⇒ Object Also known as: *
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/colt/matrix/algebra.rb', line 83 def mult(other_val, alpha = 1, beta = 0, transA = false, transB = false, result = nil) if (other_val.is_a? Numeric) MDMatrix.from_mdarray(@mdarray * other_val) elsif (other_val.is_a? MDMatrix) if (other_val.rank > 2) raise "Rank should be 1 or 2" elsif (other_val.rank == 2) result = MDMatrix .build(@mdarray.type, [@mdarray.shape[0], other_val.mdarray.shape[1]]) if result == nil @colt_matrix.zMult(other_val.colt_matrix, result.colt_matrix, alpha, beta, transA, transB) else # multiplying by a vector result = MDMatrix.build(@mdarray.type, [@mdarray.shape[1]]) if result == nil @colt_matrix.zMult(other_val.colt_matrix, result.colt_matrix, alpha, beta, transA) end # MDMatrix.from_colt_matrix(result) result else raise "Cannot multiply matrix by given value" end end |
#transpose ⇒ Object
Constructs and returns a new view which is the transposition of the given matrix A.
115 116 117 |
# File 'lib/colt/matrix/algebra.rb', line 115 def transpose MDMatrix.from_mdarray(@mdarray.transpose(0, 1)) end |