Skip to content

Commit 4bccad9

Browse files
committed
Update test
1 parent a9007c9 commit 4bccad9

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

quantum/density/matrix_test.go

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ func ExampleMatrix_Project() {
3636
gate.CNOT(2, 0, 1),
3737
))
3838

39-
basis := qubit.Zero(2)
40-
p, sigma := rho.Project(basis)
39+
computationalBasis := []*qubit.Qubit{
40+
qubit.From("00"),
41+
qubit.From("01"),
42+
qubit.From("10"),
43+
qubit.From("11"),
44+
}
4145

42-
fmt.Printf("%v: %.2f\n", basis.State(), p)
43-
for _, r := range sigma.Seq2() {
44-
fmt.Println(r)
46+
for _, basis := range computationalBasis {
47+
p, sigma := rho.Project(basis)
48+
49+
fmt.Printf("%v: %.2f\n", basis.State(), p)
50+
for _, r := range sigma.Seq2() {
51+
fmt.Println(r)
52+
}
4553
}
4654

4755
// Output:
@@ -50,6 +58,21 @@ func ExampleMatrix_Project() {
5058
// [(0+0i) (0+0i) (0+0i) (0+0i)]
5159
// [(0+0i) (0+0i) (0+0i) (0+0i)]
5260
// [(0+0i) (0+0i) (0+0i) (0+0i)]
61+
// [[01][ 1]( 1.0000 0.0000i): 1.0000]: 0.00
62+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
63+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
64+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
65+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
66+
// [[10][ 2]( 1.0000 0.0000i): 1.0000]: 0.00
67+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
68+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
69+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
70+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
71+
// [[11][ 3]( 1.0000 0.0000i): 1.0000]: 0.50
72+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
73+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
74+
// [(0+0i) (0+0i) (0+0i) (0+0i)]
75+
// [(0+0i) (0+0i) (0+0i) (1+0i)]
5376
}
5477

5578
func ExampleMatrix_ExpectedValue() {

0 commit comments

Comments
 (0)