1 package JSci.physics.quantum; 2 3 import JSci.maths.matrices.AbstractComplexMatrix; 4 import JSci.maths.matrices.AbstractComplexSquareMatrix; 5 6 11 public final class DensityMatrix extends Operator { 12 private static AbstractComplexSquareMatrix constructor(KetVector kets[],double probs[]) { 13 AbstractComplexMatrix rep=(new Projector(kets[0])).getRepresentation().scalarMultiply(probs[0]); 14 for(int i=1;i<kets.length;i++) 15 rep=rep.add((new Projector(kets[i])).getRepresentation().scalarMultiply(probs[i])); 16 return (AbstractComplexSquareMatrix)rep; 17 } 18 private static AbstractComplexSquareMatrix constructor(Projector projs[],double probs[]) { 19 AbstractComplexMatrix rep=projs[0].getRepresentation().scalarMultiply(probs[0]); 20 for(int i=1;i<projs.length;i++) 21 rep=rep.add(projs[i].getRepresentation().scalarMultiply(probs[i])); 22 return (AbstractComplexSquareMatrix)rep; 23 } 24 25 30 public DensityMatrix(KetVector kets[],double probs[]) { 31 super(constructor(kets,probs)); 32 } 33 38 public DensityMatrix(Projector projs[],double probs[]) { 39 super(constructor(projs,probs)); 40 } 41 44 public boolean isPureState() { 45 return representation.equals(representation.multiply(representation)); 46 } 47 } 48 49 | Popular Tags |