Table of contents

Here is a simple example of how to construct a density and a subspace, and compute probabilities

import java.util.List;

import bpiwowar.maths.matrix.DoubleMatrix1D;

public final class QuantumProbabilityExample {
	 * @param densityVectors A list of density vectors
	 * @param subspaceVectors
	public void example(List<DoubleMatrix1D> densityVectors, List<DoubleMatrix1D> subspaceVectors) {
		// --- Creates the density and subspace trackers
		// Creates a new density tracker
		DensityTracker tracker = new DensityTracker();
		// Add the vectors one by one
		for(DoubleMatrix1D v: densityVectors)

		// Creates a density (do not copy the matrices, so be careful)
		Density density = new Density(tracker, false);
		// Creates a subspace from the tracker
		Subspace subspace = new Subspace(tracker);
		// --- Compute probabilities
		double probability;
		// Computes a probability
		probability = density.computeProbability(subspace, false);
		System.err.format("The probability P(S|rho) is %.4f", probability);

		// Computes a fuzzy probability
		probability = density.computeProbability(subspace, true);
		System.err.format("The probability P_fuzzy(S|rho) is %.4f", probability);