Parallel Colt 0.7.2

jcuda.jcublas
Class JCuComplex

java.lang.Object
  extended by jcuda.jcublas.JCuComplex

public class JCuComplex
extends Object

Java port of the CUBLAS complex number structure


Field Summary
 float x
          The real part of the complex number
 float y
          The imaginary part of the complex number
 
Method Summary
static float cuCabs(JCuComplex x)
          Returns the absolute value of the given complex number

Original comment:

This implementation guards against intermediate underflow and overflow by scaling.
static JCuComplex cuCadd(JCuComplex x, JCuComplex y)
          Returns a new complex number that is the sum of the given complex numbers
static JCuComplex cuCdiv(JCuComplex x, JCuComplex y)
          Returns the quotient of the given complex numbers.

Original comment:

This implementation guards against intermediate underflow and overflow by scaling.
static float cuCimag(JCuComplex x)
          Returns the imaginary part of the given complex number
static JCuComplex cuCmplx(float r, float i)
          Creates a new complex number consisting of the given real and imaginary part
static JCuComplex cuCmul(JCuComplex x, JCuComplex y)
          Returns the product of the given complex numbers.

Original comment:

This implementation could suffer from intermediate overflow even though the final result would be in range.
static JCuComplex cuConj(JCuComplex x)
          Returns the complex conjugate of the given complex number
static float cuCreal(JCuComplex x)
          Returns the real part of the given complex number
 String toString()
          Returns a String representation of this complex number
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
The real part of the complex number


y

public float y
The imaginary part of the complex number

Method Detail

cuCreal

public static float cuCreal(JCuComplex x)
Returns the real part of the given complex number

Parameters:
x - The complex number whose real part should be returned
Returns:
The real part of the given complex number

cuCimag

public static float cuCimag(JCuComplex x)
Returns the imaginary part of the given complex number

Parameters:
x - The complex number whose imaginary part should be returned
Returns:
The imaginary part of the given complex number

cuCmplx

public static JCuComplex cuCmplx(float r,
                                 float i)
Creates a new complex number consisting of the given real and imaginary part

Parameters:
r - The real part of the complex number
i - The imaginary part of the complex number
Returns:
A complex number with the given real and imaginary part

cuConj

public static JCuComplex cuConj(JCuComplex x)
Returns the complex conjugate of the given complex number

Parameters:
x - The complex number whose complex conjugate should be returned
Returns:
The complex conjugate of the given complex number

cuCadd

public static JCuComplex cuCadd(JCuComplex x,
                                JCuComplex y)
Returns a new complex number that is the sum of the given complex numbers

Parameters:
x - The first addend
y - The second addend
Returns:
The sum of the given addends

cuCmul

public static JCuComplex cuCmul(JCuComplex x,
                                JCuComplex y)
Returns the product of the given complex numbers.

Original comment:

This implementation could suffer from intermediate overflow even though the final result would be in range. However, various implementations do not guard against this (presumably to avoid losing performance), so we don't do it either to stay competitive.

Parameters:
x - The first factor
y - The second factor
Returns:
The product of the given factors

cuCdiv

public static JCuComplex cuCdiv(JCuComplex x,
                                JCuComplex y)
Returns the quotient of the given complex numbers.

Original comment:

This implementation guards against intermediate underflow and overflow by scaling. Such guarded implementations are usually the default for complex library implementations, with some also offering an unguarded, faster version.

Parameters:
x - The dividend
y - The divisor
Returns:
The quotient of the given complex numbers

cuCabs

public static float cuCabs(JCuComplex x)
Returns the absolute value of the given complex number

Original comment:

This implementation guards against intermediate underflow and overflow by scaling. Otherwise the we'd lose half the exponent range. There are various ways of doing guarded computation. For now chose the simplest and fastest solution, however this may suffer from inaccuracies if sqrt and division are not IEEE compliant.

Parameters:
x - The complex number whose absolute value should be returned
Returns:
The absolute value of the given complex number

toString

public String toString()
Returns a String representation of this complex number

Overrides:
toString in class Object
Returns:
A String representation of this complex number

Parallel Colt 0.7.2

Jump to the Parallel Colt Homepage