Skip to content

Commit 9765b0b

Browse files
committed
Update New
1 parent 58cac7a commit 9765b0b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

quantum/density/matrix.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ type Matrix struct {
1919

2020
// New returns a new density matrix.
2121
func New(ensemble []State) *Matrix {
22-
normalized := Normalize(ensemble)
23-
n := normalized[0].Qubit.Dim()
22+
n := ensemble[0].Qubit.Dim()
2423

2524
rho := matrix.Zero(n, n)
26-
for _, s := range normalized {
25+
for _, s := range Normalize(ensemble) {
2726
op := s.Qubit.OuterProduct(s.Qubit)
2827
rho = rho.Add(op.Mul(complex(s.Probability, 0)))
2928
}

0 commit comments

Comments
 (0)