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

JSci.physics.quantum.QuantumMath 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.physics.quantum;

import JSci.maths.AbstractMath;
import JSci.maths.Complex;

/**
* The Quantum math library.
* This class cannot be subclassed or instantiated because all methods are static.
* @version 1.5
* @author Mark Hale
*/
public final class QuantumMath extends AbstractMath {
        private QuantumMath() {}

// COMMUTATOR

        /**
        * Returns the commutator [A,B].
        * @param A an operator
        * @param B an operator
        */
        public static Operator commutator(final Operator A, final Operator B) {
                return (A.multiply(B)).subtract(B.multiply(A));
        }

// ANTICOMMUTATOR

        /**
        * Returns the anticommutator {A,B}.
        * @param A an operator
        * @param B an operator
        */
        public static Operator anticommutator(final Operator A, final Operator B) {
                return (A.multiply(B)).add(B.multiply(A));
        }

// EXPECTATION VALUES

        /**
        * Returns the expectation value.
        * @param op an operator
        * @param ket a ket vector
        * @exception DimensionException If the operator and vector have different dimensions.
        */
        public static Complex expectation(final Operator op, final KetVector ket) {
                return ket.toBraVector().multiply(op).multiply(ket);
        }
        /**
        * Returns the expectation value.
        * @param dm a density matrix
        * @param op an operator
        * @exception MatrixDimensionException If the operator and matrix have different dimensions.
        */
        public static Complex expectation(final DensityMatrix dm, final Operator op) {
                return dm.multiply(op).trace();
        }

// PROBABILITIES

        /**
        * Returns the probability.
        * @param p a projector
        * @param ket a ket vector
        * @exception DimensionException If the projector and vector have different dimensions.
        */
        public static Complex probability(final Projector p, final KetVector ket) {
                return ket.toBraVector().multiply(p).multiply(ket);
        }
        /**
        * Returns the probability.
        * @param dm a density matrix
        * @param p a projector
        * @exception MatrixDimensionException If the projector and matrix have different dimensions.
        */
        public static Complex probability(final DensityMatrix dm, final Projector p) {
                return dm.multiply(p).trace();
        }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy