コード例 #1
0
ファイル: fractalgen.go プロジェクト: wturyn/go-web-fractal
func juliaSinIter(c, seed complex128) float64 {
	i := 0
	for z := c; cmplx.Abs(z) < 50 && i < maxIter; i++ {
		z = cmplx.Sin(z) * seed
	}

	return float64(maxIter-i) / maxIter
}
コード例 #2
0
ファイル: qreg.go プロジェクト: hsavit1/quantum-computation
// Convenience constructor for a qubit, specified by its spherical coordinates
// on the Bloch sphere.
func NewQubitWithBlochCoords(theta, phi float64) *QReg {
	// |psi> = cos(theta/2) + e^{i phi}sin(theta/2)
	t := complex(theta/2, 0)
	p := complex(phi, 0)
	qreg := &QReg{1, []complex128{cmplx.Cos(t),
		cmplx.Exp(complex(0, 1)*p) * cmplx.Sin(t)}}
	return qreg
}
コード例 #3
0
ファイル: cmplxSparse.go プロジェクト: ominux/negf_mtj
// Function to compute basis transformation matrix
func BasisTransform(th, phi float64) *[2][2]complex128 {

	BTMatrix := new([2][2]complex128)
	th_2, phi_2 := 0.5*th, 0.5*phi
	csn := cmplx.Cos(complex(th_2, 0.0)) * cmplx.Exp(complex(0.0, -1.0*phi_2))
	sn := cmplx.Sin(complex(th_2, 0.0)) * cmplx.Exp(complex(0.0, phi_2))

	BTMatrix[0][0] = cmplx.Conj(csn)
	BTMatrix[0][1] = cmplx.Conj(sn)
	BTMatrix[1][0] = complex(-1.0, 0.0) * sn
	BTMatrix[1][1] = csn

	return BTMatrix
}