uk.ac.ic.doc.jpair.pairing
Class Complex

java.lang.Object
  extended by uk.ac.ic.doc.jpair.pairing.Complex
All Implemented Interfaces:
java.io.Serializable, FieldElement

public class Complex
extends java.lang.Object
implements java.io.Serializable, FieldElement

This immutable class defines complex numbers over a finite field, i.e. the real and imaginary parts of the complex number are taken over the finite field.

Version:
1.0
Author:
Changyu Dong
See Also:
Serialized Form

Constructor Summary
Complex(Fp field, BigInt real)
           
Complex(Fp field, BigInt real, BigInt imag)
           
 
Method Summary
 Complex add(Complex p)
           
 Complex conjugate()
          Return the conjugate of this complex number.
 Complex divide(Complex p)
           
 boolean equals(java.lang.Object obj)
           
 Field getField()
           
 BigInt getImag()
           
 BigInt getReal()
           
 int hashCode()
           
 Complex inverse()
           
 boolean isOne()
           
 boolean isZero()
           
 Complex multiply(Complex p)
           
 Complex multiply(int val)
           
 Complex negate()
           
 Complex pow(BigInt k)
           
 Complex square()
           
 Complex substract(Complex p)
           
 byte[] toByteArray()
          Return a single byte array which is equivalent to this.real.toByteArray()||this.imag.toByteArray();
 java.lang.String toString()
          Return a string in the format of [a,b] where a and b are the real and imaginary parts of the complex number a+bi.
 java.lang.String toString(int radix)
          Return a string in the format of [a,b] where a and b are the real and imaginary parts of the complex number a+bi.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex(Fp field,
               BigInt real)

Complex

public Complex(Fp field,
               BigInt real,
               BigInt imag)
Method Detail

isZero

public boolean isZero()

isOne

public boolean isOne()

add

public Complex add(Complex p)

substract

public Complex substract(Complex p)

negate

public Complex negate()

multiply

public Complex multiply(Complex p)

square

public Complex square()

divide

public Complex divide(Complex p)

conjugate

public Complex conjugate()
Return the conjugate of this complex number. If this is a+bi, then the conjugate is a-bi.

Returns:
the conjugate.

pow

public Complex pow(BigInt k)

inverse

public Complex inverse()

multiply

public Complex multiply(int val)

getField

public Field getField()

toString

public java.lang.String toString()
Return a string in the format of [a,b] where a and b are the real and imaginary parts of the complex number a+bi. a and b are in the given radix.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int radix)
Return a string in the format of [a,b] where a and b are the real and imaginary parts of the complex number a+bi. a and b are in decimal format.

Specified by:
toString in interface FieldElement

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getReal

public BigInt getReal()

getImag

public BigInt getImag()

toByteArray

public byte[] toByteArray()
Return a single byte array which is equivalent to this.real.toByteArray()||this.imag.toByteArray();

Specified by:
toByteArray in interface FieldElement