public override Transformation GetTransformation(QuantumState state) { double random = new Random().NextDouble(); double probability = state.ProabailityInBasis(GateTransformation.Column(0)); if (random < probability) { return(new Transformation(GateTransformation.Column(0).OuterProduct(GateTransformation.Column(0)))); } else { return(new Transformation(GateTransformation.Column(1).OuterProduct(GateTransformation.Column(1)))); } }
public override Transformation GetTransformation(StateOperator state) { double random = new Random().NextDouble(); Transformation zeroProjection = new Transformation(GateTransformation.Column(0).OuterProduct(GateTransformation.Column(0))); double probability = zeroProjection.Multiply(state).Trace().Real; if (random < probability) { return(zeroProjection); } else { return(new Transformation(GateTransformation.Column(1).OuterProduct(GateTransformation.Column(1)))); } }