Module JBLAS::ComplexMixin
In: lib/jblas/complex.rb

Syntactic sugar for complex numbers.

Defines the arithmetic operators *, +, -, /, and coercion such that the complex numbers interact well with the builtin numerics.

Methods

*   +   -   -@   /   abs   arg   conj   inspect   rdiv   rsub   sqrt   to_s  

Public Instance methods

Multiply complex values.

[Source]

# File lib/jblas/complex.rb, line 53
    def *(o); mul(o); end

Add complex values.

[Source]

# File lib/jblas/complex.rb, line 55
    def +(o); add(o); end

Subtract complex values.

[Source]

# File lib/jblas/complex.rb, line 57
    def -(o); sub(o); end

Negative complex values.

[Source]

# File lib/jblas/complex.rb, line 61
    def -@; neg; end

Divide complex values.

[Source]

# File lib/jblas/complex.rb, line 59
    def /(o); div(o); end

Get the length of the complex number

[Source]

# File lib/jblas/complex.rb, line 84
    def abs; JAVA_METHOD; end

Get the angle of the complex number

[Source]

# File lib/jblas/complex.rb, line 87
    def arg; JAVA_METHOD; end

Get the conjugate of the complex number

[Source]

# File lib/jblas/complex.rb, line 90
    def conj; JAVA_METHOD; end

Same as to_s.

[Source]

# File lib/jblas/complex.rb, line 48
    def inspect
      to_s
    end

Divide with swapped operands.

This means that a.rdiv(b) = b / a. This method is necessary to make coercion work.

[Source]

# File lib/jblas/complex.rb, line 72
    def rdiv(o); inv * o; end

Subtract with swapped operands.

This means that a.rsub(b) = b - a. This method is necessary to make coercion work.

[Source]

# File lib/jblas/complex.rb, line 67
    def rsub(o); -self + o; end

Compute the square root

[Source]

# File lib/jblas/complex.rb, line 81
    def sqrt; JAVA_METHOD; end

Convert to a string.

[Source]

# File lib/jblas/complex.rb, line 43
    def to_s
      "#{real} + #{imag}i"
    end

[Validate]