Parallel Colt 0.7.2

jcuda.jcublas
Class JCuDoubleComplex

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

public class JCuDoubleComplex
extends Object

Java port of the CUBLAS complex number structure for double precision numbers


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

Original comment:

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

Original comment:

This implementation guards against intermediate underflow and overflow by scaling.
static double cuCimag(JCuDoubleComplex x)
          Returns the imaginary part of the given complex number
static JCuDoubleComplex cuCmplx(double r, double i)
          Creates a new complex number consisting of the given real and imaginary part
static JCuDoubleComplex cuCmul(JCuDoubleComplex x, JCuDoubleComplex 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 JCuDoubleComplex cuConj(JCuDoubleComplex x)
          Returns the complex conjugate of the given complex number
static double cuCreal(JCuDoubleComplex 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 double x
The real part of the complex number


y

public double y
The imaginary part of the complex number

Method Detail

cuCreal

public static double cuCreal(JCuDoubleComplex 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 double cuCimag(JCuDoubleComplex 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 JCuDoubleComplex cuCmplx(double r,
                                       double 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 JCuDoubleComplex cuConj(JCuDoubleComplex 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 JCuDoubleComplex cuCadd(JCuDoubleComplex x,
                                      JCuDoubleComplex 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 JCuDoubleComplex cuCmul(JCuDoubleComplex x,
                                      JCuDoubleComplex 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 JCuDoubleComplex cuCdiv(JCuDoubleComplex x,
                                      JCuDoubleComplex 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 double cuCabs(JCuDoubleComplex 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