Exemple #1
0
// Acos calculates pixel values for arcus-cosinus fractal.
func Acos(r, i float64) (blue, red uint8) {
	z := complex(r, i)
	v := cmplx.Acos(z)
	blue = uint8(real(v)*128) + 127
	red = uint8(imag(v)*128) + 127
	return blue, red
}
Exemple #2
0
// Function for calculating the self-energy matrices
func SelfEnergyEntries(currEnergy, modeEnergy, delta0, delta1, potential float64, t0 complex128, BT_Mat *[2][2]complex128) *[2][2]complex128 {
	s := new([2][2]complex128)

	SumEnergy := complex(currEnergy-modeEnergy+0.5*potential-delta0, utils.Zplus)
	SumEnergy /= complex(-2.0, 0.0) * t0
	SumEnergy += complex(1.0, 0.0)

	sig_uu := complex(-1.0, 0.0) * t0 * cmplx.Exp(1.0i*cmplx.Acos(SumEnergy))

	SumEnergy = complex(currEnergy-modeEnergy+0.5*potential-delta1, utils.Zplus)
	SumEnergy /= complex(-2.0, 0.0) * t0
	SumEnergy += complex(1.0, 0.0)

	sig_dd := complex(-1.0, 0.0) * t0 * cmplx.Exp(1.0i*cmplx.Acos(SumEnergy))

	s[0][0] = cmplx.Conj(BT_Mat[0][0])*sig_uu*BT_Mat[0][0] + cmplx.Conj(BT_Mat[1][0])*sig_dd*BT_Mat[1][0]
	s[0][1] = cmplx.Conj(BT_Mat[0][0])*sig_uu*BT_Mat[0][1] + cmplx.Conj(BT_Mat[1][0])*sig_dd*BT_Mat[1][1]
	s[1][0] = cmplx.Conj(BT_Mat[0][1])*sig_uu*BT_Mat[0][0] + cmplx.Conj(BT_Mat[1][1])*sig_dd*BT_Mat[1][0]
	s[1][1] = cmplx.Conj(BT_Mat[0][1])*sig_uu*BT_Mat[0][1] + cmplx.Conj(BT_Mat[1][1])*sig_dd*BT_Mat[1][1]

	return s
}
// AngleThetaComplex returns the angle theta between VectorComplex A and VectorComplex B using the dot product
func AngleThetaComplex(vectorA ct.VectorComplex, vectorB ct.VectorComplex) (complex128, error) {
	normA := vectorA.Norm()
	normB := vectorB.Norm()

	if normA == 0 || normB == 0 {
		return nil, errors.New("Either Vector A or Vector B is the zero vector")
	}

	dotProduct, err := InnerProductComplex(vectorA, vectorB)

	if err != nil {
		return nil, err
	}

	theta := cmplx.Acos(dotProduct / (normA * normB))

	return theta
}
Exemple #4
0
func acos(z complex128) color.Color {
	v := cmplx.Acos(z)
	blue := uint8(real(v)*128) + 127
	red := uint8(imag(v)*128) + 127
	return color.YCbCr{192, blue, red}
}