density

package
v1.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitFlip

func BitFlip(p float64) (matrix.Matrix, matrix.Matrix, error)
Example
Output:

[(0.7071067811865476+0i) (0+0i)]
[(0+0i) (0.7071067811865476+0i)]

[(0+0i) (0.7071067811865476+0i)]
[(0.7071067811865476+0i) (0+0i)]

func BitPhaseFlip

func BitPhaseFlip(p float64) (matrix.Matrix, matrix.Matrix, error)
Example
Output:

[(0.7071067811865476+0i) (0+0i)]
[(0+0i) (0.7071067811865476+0i)]

[(0+0i) (0-0.7071067811865476i)]
[(0+0.7071067811865476i) (0+0i)]

func Flip

func PhaseFlip

func PhaseFlip(p float64) (matrix.Matrix, matrix.Matrix, error)
Example
Output:

[(0.7071067811865476+0i) (0+0i)]
[(0+0i) (0.7071067811865476+0i)]

[(0.7071067811865476+0i) (0+0i)]
[(0+0i) (-0.7071067811865476+0i)]

Types

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

func New

func New(ensemble []State) (*Matrix, error)

func (*Matrix) Add

func (m *Matrix) Add(ensemble []State) error

func (*Matrix) Apply

func (m *Matrix) Apply(u matrix.Matrix) *Matrix

func (*Matrix) Depolarizing

func (m *Matrix) Depolarizing(p float64) (*Matrix, error)
Example
Output:

0: 1.00
1: 0.00

0: 0.50
1: 0.50

func (*Matrix) Dimension

func (m *Matrix) Dimension() (int, int)

func (*Matrix) ExpectedValue

func (m *Matrix) ExpectedValue(u matrix.Matrix) float64
Example
Output:

X: 0.9
Y: 0
Z: 0.1

func (*Matrix) Measure

func (m *Matrix) Measure(q *qubit.Qubit) float64
Example
Output:

0: 0.1
1: 0.9

func (*Matrix) NumberOfBit

func (m *Matrix) NumberOfBit() int

func (*Matrix) PartialTrace

func (m *Matrix) PartialTrace(index ...int) *Matrix
Example
Output:

[(0.2500+0.0000i) (0.0000+0.0000i) (0.1250+0.1250i) (0.1250-0.1250i)]
[(0.0000+0.0000i) (0.2500+0.0000i) (0.1250-0.1250i) (0.1250+0.1250i)]
[(0.1250-0.1250i) (0.1250+0.1250i) (0.2500+0.0000i) (0.0000+0.0000i)]
[(0.1250+0.1250i) (0.1250-0.1250i) (0.0000+0.0000i) (0.2500+0.0000i)]
trace: 1, square_trace: 0.5

[(0.5000+0.0000i) (0.0000+0.0000i)]
[(0.0000+0.0000i) (0.5000+0.0000i)]
trace: 1, square_trace: 0.5

[(0.5000+0.0000i) (0.2500+0.2500i)]
[(0.2500-0.2500i) (0.5000+0.0000i)]
trace: 1, square_trace: 0.75
Example (X16)
Output:

trace: 1.00
square_trace: 0.25
Example (X8)
Output:

[(0.1250+0.0000i) (0.0000+0.0000i) (0.0625+0.0625i) (0.0625-0.0625i) (0.1067+0.0442i) (0.0183-0.0442i) (0.0183+0.0442i) (0.1067-0.0442i)]
[(0.0000+0.0000i) (0.1250+0.0000i) (0.0625-0.0625i) (0.0625+0.0625i) (0.0183-0.0442i) (0.1067+0.0442i) (0.1067-0.0442i) (0.0183+0.0442i)]
[(0.0625-0.0625i) (0.0625+0.0625i) (0.1250+0.0000i) (0.0000+0.0000i) (0.1067-0.0442i) (0.0183+0.0442i) (0.1067+0.0442i) (0.0183-0.0442i)]
[(0.0625+0.0625i) (0.0625-0.0625i) (0.0000+0.0000i) (0.1250+0.0000i) (0.0183+0.0442i) (0.1067-0.0442i) (0.0183-0.0442i) (0.1067+0.0442i)]
[(0.1067-0.0442i) (0.0183+0.0442i) (0.1067+0.0442i) (0.0183-0.0442i) (0.1250+0.0000i) (0.0000+0.0000i) (0.0625+0.0625i) (0.0625-0.0625i)]
[(0.0183+0.0442i) (0.1067-0.0442i) (0.0183-0.0442i) (0.1067+0.0442i) (0.0000+0.0000i) (0.1250+0.0000i) (0.0625-0.0625i) (0.0625+0.0625i)]
[(0.0183-0.0442i) (0.1067+0.0442i) (0.1067-0.0442i) (0.0183+0.0442i) (0.0625-0.0625i) (0.0625+0.0625i) (0.1250+0.0000i) (0.0000+0.0000i)]
[(0.1067+0.0442i) (0.0183-0.0442i) (0.0183+0.0442i) (0.1067-0.0442i) (0.0625+0.0625i) (0.0625-0.0625i) (0.0000+0.0000i) (0.1250+0.0000i)]
trace: 1, square_trace: 0.5

[(0.2500+0.0000i) (0.0000+0.0000i) (0.1250+0.1250i) (0.1250-0.1250i)]
[(0.0000+0.0000i) (0.2500+0.0000i) (0.1250-0.1250i) (0.1250+0.1250i)]
[(0.1250-0.1250i) (0.1250+0.1250i) (0.2500+0.0000i) (0.0000+0.0000i)]
[(0.1250+0.1250i) (0.1250-0.1250i) (0.0000+0.0000i) (0.2500+0.0000i)]
trace: 1, square_trace: 0.5

[(0.2500+0.0000i) (0.0000+0.0000i) (0.2134+0.0884i) (0.0366-0.0884i)]
[(0.0000+0.0000i) (0.2500+0.0000i) (0.0366-0.0884i) (0.2134+0.0884i)]
[(0.2134-0.0884i) (0.0366+0.0884i) (0.2500+0.0000i) (0.0000+0.0000i)]
[(0.0366+0.0884i) (0.2134-0.0884i) (0.0000+0.0000i) (0.2500+0.0000i)]
trace: 1, square_trace: 0.5

[(0.2500+0.0000i) (0.1250+0.1250i) (0.2134+0.0884i) (0.0366+0.0884i)]
[(0.1250-0.1250i) (0.2500+0.0000i) (0.2134-0.0884i) (0.2134+0.0884i)]
[(0.2134-0.0884i) (0.2134+0.0884i) (0.2500+0.0000i) (0.1250+0.1250i)]
[(0.0366-0.0884i) (0.2134-0.0884i) (0.1250-0.1250i) (0.2500+0.0000i)]
trace: 1, square_trace: 0.71

func (*Matrix) Raw

func (m *Matrix) Raw() matrix.Matrix

func (*Matrix) SquareTrace

func (m *Matrix) SquareTrace() float64
Example
Output:

pure:  1.00
mixed: 0.82

func (*Matrix) Trace

func (m *Matrix) Trace() float64
Example
Output:

pure:  1.00
mixed: 1.00

type State

type State struct {
	Probability float64
	Qubit       *qubit.Qubit
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL