We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58cac7a commit 9765b0bCopy full SHA for 9765b0b
quantum/density/matrix.go
@@ -19,11 +19,10 @@ type Matrix struct {
19
20
// New returns a new density matrix.
21
func New(ensemble []State) *Matrix {
22
- normalized := Normalize(ensemble)
23
- n := normalized[0].Qubit.Dim()
+ n := ensemble[0].Qubit.Dim()
24
25
rho := matrix.Zero(n, n)
26
- for _, s := range normalized {
+ for _, s := range Normalize(ensemble) {
27
op := s.Qubit.OuterProduct(s.Qubit)
28
rho = rho.Add(op.Mul(complex(s.Probability, 0)))
29
}
0 commit comments