Module | JBLAS::MatrixArithMixin |
In: |
lib/jblas/mixin_arith.rb
|
Mixin for syntactic sugar for arithmetic operations.
Collected in MatrixMixin.
Roughly defines the following types of operators:
Multiply this matrix with o. If o is a matrix, this matrix-matrix multiplication. If you want element-wise multiplication, you must use emul
# File lib/jblas/mixin_arith.rb, line 54 def *(o); mmul(o); end
Compute self to the power of o.
# File lib/jblas/mixin_arith.rb, line 131 def **(o); MatrixFunctions.pow(self, o); end
Add o to this matrix. Works with matrices and scalars.
# File lib/jblas/mixin_arith.rb, line 48 def +(o); add(o); end
Subtract o from this matrix. Works with matrices and scalars.
# File lib/jblas/mixin_arith.rb, line 50 def -(o); sub(o); end
Element-wise test on less-than with o.
# File lib/jblas/mixin_arith.rb, line 61 def <(o); lt(o); end
Element-wise test on less-than-or-equal with o.
# File lib/jblas/mixin_arith.rb, line 63 def <=(o); le(o); end
Test on equality.
# File lib/jblas/mixin_arith.rb, line 118 def ==(o) #puts "== called with self = #{self.inspect}, o = #{o.inspect}" equals(o) end
Element-wise test on equality with o.
# File lib/jblas/mixin_arith.rb, line 69 def ===(o); eq(o); end
Element-wise test on greater-than with o.
# File lib/jblas/mixin_arith.rb, line 65 def >(o); gt(o); end
Element-wise test on greater-than-or-equal with o.
# File lib/jblas/mixin_arith.rb, line 67 def >=(o); ge(o); end
Element-wise logical exclusive-or.
# File lib/jblas/mixin_arith.rb, line 128 def ^(o); self.xor(o); end
Add column vector to matrix in-place.
# File lib/jblas/mixin_arith.rb, line 101 def add_column_vector!(s); addi_column_vector(s); end
Add row vector to matrix in-place.
# File lib/jblas/mixin_arith.rb, line 103 def add_row_vector!(s); addi_row_vector(s); end
Element-wise logical "and" in-place.
# File lib/jblas/mixin_arith.rb, line 94 def and!(s); andi(s); end
Divide matrices element-wise (see also /)
# File lib/jblas/mixin_arith.rb, line 163 def div(o); JAVA_METHOD; end
Divide matrices element-wise in-place.
# File lib/jblas/mixin_arith.rb, line 80 def div!(s); divi(s); end
Multiply row vector element-wise with matrix in-place.
# File lib/jblas/mixin_arith.rb, line 113 def div_column_vector!(s); divi_column_vector(s); end
Divide matrix element-wise by row vector in-place.
# File lib/jblas/mixin_arith.rb, line 115 def div_row_vector!(s); divi_row_vector(s); end
Element-wise test for equality in-place.
# File lib/jblas/mixin_arith.rb, line 82 def eq!(s); eqi(s); end
Element-wise test for greater-than-or-equal in-place.
# File lib/jblas/mixin_arith.rb, line 92 def ge!(s); gei(s); end
Element-wise test for greater-than in-place.
# File lib/jblas/mixin_arith.rb, line 90 def gt!(s); gti(s); end
Element-wise test for less-than-or-equal in-place.
# File lib/jblas/mixin_arith.rb, line 88 def le!(s); lei(s); end
Element-wise test for less-than in-place.
# File lib/jblas/mixin_arith.rb, line 86 def lt!(s); lti(s); end
Matrix multiply matrices in-place.
# File lib/jblas/mixin_arith.rb, line 78 def mmul!(s); mmuli(s); end
Multiply matrices element-wise. (see also *)
# File lib/jblas/mixin_arith.rb, line 158 def mul(o); JAVA_METHOD; end
Multiply matrices element-wise in-place.
# File lib/jblas/mixin_arith.rb, line 76 def mul!(s); muli(s); end
Multiply row vector element-wise with matrix in-place.
# File lib/jblas/mixin_arith.rb, line 109 def mul_column_vector!(s); muli_column_vector(s); end
Divide matrix element-wise by column vector in-place.
# File lib/jblas/mixin_arith.rb, line 111 def mul_row_vector!(s); muli_row_vector(s); end
Element-wise test for inequality in-place.
# File lib/jblas/mixin_arith.rb, line 84 def ne!(s); nei(s); end
Element-wise logical "or" in-place.
# File lib/jblas/mixin_arith.rb, line 96 def or!(s); ori(s); end
Subtract matrices (see also -).
# File lib/jblas/mixin_arith.rb, line 153 def sub(o); JAVA_METHOD; end
Subtract column vector from matrix in-place.
# File lib/jblas/mixin_arith.rb, line 105 def sub_column_vector!(s); subi_column_vector(s); end
Subtract column vector from matrix in-place.
# File lib/jblas/mixin_arith.rb, line 107 def sub_row_vector!(s); subi_row_vector(s); end