All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.maths.fields.ComplexField Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.maths.fields;

import JSci.maths.Complex;
import JSci.maths.groups.AbelianGroup;

/**
* The ComplexField class encapsulates the field of complex numbers.
* @version 1.0
* @author Mark Hale
*/
public final class ComplexField extends Object implements Field {
        public static final Complex ZERO=new Complex(0.0,0.0);
        public static final Complex I=new Complex(0.0,1.0);
        public static final Complex ONE=new Complex(1.0,0.0);
        public static final Complex MINUS_ONE=new Complex(-1.0,0.0);
        public static final Complex MINUS_I=new Complex(0.0,-1.0);
        public static final Complex HALF=new Complex(0.5,0.0);
        public static final Complex MINUS_HALF=new Complex(-0.5,0.0);
        public static final Complex HALF_I=new Complex(0.0,0.5);
        public static final Complex MINUS_HALF_I=new Complex(0.0,-0.5);
        public static final Complex TWO=new Complex(2.0,0.0);
        public static final Complex MINUS_TWO=new Complex(-2.0,0.0);
        public static final Complex SQRT_HALF=new Complex(Math.sqrt(0.5),0.0);
        public static final Complex SQRT_HALF_I=new Complex(0.0,Math.sqrt(0.5));
        public static final Complex MINUS_SQRT_HALF_I=new Complex(0.0,-Math.sqrt(0.5));
        public static final Complex PI=new Complex(Math.PI,0.0);
        public static final Complex PI_I=new Complex(0.0,Math.PI);
        public static final Complex PI_2=new Complex(Math.PI/2.0,0.0);
        public static final Complex MINUS_PI_2=new Complex(-Math.PI/2.0,0.0);
        public static final Complex PI_2_I=new Complex(0.0,Math.PI/2.0);
        public static final Complex MINUS_PI_2_I=new Complex(0.0,-Math.PI/2.0);

        private final static ComplexField _instance = new ComplexField();
        /**
        * Constructs a field of complex numbers.
        */
        private ComplexField() {}
        /**
        * Constructs a field of complex numbers.
        * Singleton.
        */
        public static final ComplexField getInstance() {
                return _instance;
        }
        /**
        * Returns the complex number zero.
        */
        public AbelianGroup.Member zero() {
                return ZERO;
        }
        /**
        * Returns true if the complex number is equal to zero.
        */
        public boolean isZero(AbelianGroup.Member g) {
                return ZERO.equals(g);
        }
        /**
        * Returns true if one complex number is the negative of the other.
        */
        public boolean isNegative(AbelianGroup.Member a,AbelianGroup.Member b) {
                return ZERO.equals(a.add(b));
        }
        /**
        * Returns the complex number one.
        */
        public Ring.Member one() {
                return ONE;
        }
        /**
        * Returns true if the complex number is equal to one.
        */
        public boolean isOne(Ring.Member r) {
                return ONE.equals(r);
        }
        /**
        * Returns true if one complex number is the inverse of the other.
        */
        public boolean isInverse(Field.Member a, Field.Member b) {
                return ONE.equals(a.multiply(b));
        }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy