本文整理汇总了Golang中math/cmplx.Conj函数的典型用法代码示例。如果您正苦于以下问题:Golang Conj函数的具体用法?Golang Conj怎么用?Golang Conj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Conj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SparseDiagDagger
// Function to obtain complex conjugate (dagger operation) of
// sparse matrix stored in diagonal form
func SparseDiagDagger(s *SparseMat) *SparseMat {
// Initiaize variables for indexing purposes
matSize := len(s.Data)
numDiags := len(s.Data[0])
mainDiagIdx := (numDiags - 1) / 2
// Initialize output variable
t := SparseCopy(s)
for idx0 := 0; idx0 < matSize; idx0++ {
// Complex conjugate main diagonal
t.Data[idx0][mainDiagIdx] = cmplx.Conj(t.Data[idx0][mainDiagIdx])
// When there are more than one diagonal stored, and if we are not in the top left most entry,
// we will need to swap rows and columns, and complex conjugate those entries as well.
if (idx0 > 1) && (mainDiagIdx > 0) {
loopIdx := mainDiagIdx
if idx0 < loopIdx {
loopIdx = idx0
}
for idx1 := 1; idx1 < loopIdx; idx1++ {
// Swap row and columns, and conjugate those entries
t.Data[idx0][mainDiagIdx-idx1], t.Data[idx0-idx1][mainDiagIdx+idx1] = cmplx.Conj(t.Data[idx0-idx1][mainDiagIdx+idx1]), cmplx.Conj(t.Data[idx0][mainDiagIdx-idx1])
}
}
}
return t
}
示例2: choleskyDecomp
func (a *matrix) choleskyDecomp() *matrix {
l := like(a)
// Cholesky-Banachiewicz algorithm
for r, rxc0 := 0, 0; r < a.stride; r++ {
// calculate elements along row, up to diagonal
x := rxc0
for c, cxc0 := 0, 0; c < r; c++ {
sum := a.ele[x]
for k := 0; k < c; k++ {
sum -= l.ele[rxc0+k] * cmplx.Conj(l.ele[cxc0+k])
}
l.ele[x] = sum / l.ele[cxc0+c]
x++
cxc0 += a.stride
}
// calcualate diagonal element
sum := a.ele[x]
for k := 0; k < r; k++ {
sum -= l.ele[rxc0+k] * cmplx.Conj(l.ele[rxc0+k])
}
l.ele[x] = cmplx.Sqrt(sum)
rxc0 += a.stride
}
return l
}
示例3: BasisTransform
// 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
}
示例4: XCorrFFT
func XCorrFFT(x1, x2 []float64, circular bool) []float64 {
// zero padding.
ftlength := len(x1)
if !circular {
length := len(x1) * 2
var i uint32 = 1
for ftlength < length {
ftlength = 1 << i
i++
}
}
datax1 := make([]complex128, ftlength)
datax2 := make([]complex128, ftlength)
for i := 0; i < len(x1); i++ {
datax1[i] = complex(x2[i%len(x2)], 0)
datax2[i] = complex(x1[i%len(x1)], 0)
}
v1 := fft.FFT(datax1)
v2 := fft.FFT(datax2)
temp := []complex128{}
for i := 0; i < len(v1); i++ {
v := v1[i] * cmplx.Conj(v2[i])
temp = append(temp, v)
}
v3 := fft.IFFT(temp)
res := []float64{}
for i := 0; i < len(x1); i++ {
res = append(res, real(v3[i]))
}
return res
}
示例5: Set
func (a *triangleMat) Set(i, j int, x complex128) {
if otherTri(i, j, a.Tri) {
i, j = j, i
x = cmplx.Conj(x)
}
a.Set(i, j, x)
}
示例6: parallel_Traspose
func (this *Matrix) parallel_Traspose(i0, i1, j0, j1 int, res *Matrix, done chan<- bool, conjugate bool) {
di := i1 - i0
dj := j1 - j0
done2 := make(chan bool, THRESHOLD)
if di >= dj && di >= THRESHOLD && runtime.NumGoroutine() < maxGoRoutines {
mi := i0 + di/2
go this.parallel_Traspose(i0, mi, j0, j1, res, done2, conjugate)
this.parallel_Traspose(mi, i1, j0, j1, res, done2, conjugate)
<-done2
<-done2
} else if dj >= THRESHOLD && runtime.NumGoroutine() < maxGoRoutines {
mj := j0 + dj/2
go this.parallel_Traspose(i0, i1, j0, mj, res, done2, conjugate)
this.parallel_Traspose(i0, i1, mj, i1, res, done2, conjugate)
<-done2
<-done2
} else {
if !conjugate {
for i := i0; i <= i1; i++ {
for j := j0; j <= j1; j++ {
res.SetValue(j, i, this.GetValue(i, j))
}
}
} else {
for i := i0; i <= i1; i++ {
for j := j0; j <= j1; j++ {
res.SetValue(j, i, cmplx.Conj(this.GetValue(i, j)))
}
}
}
}
done <- true
}
示例7: VmulConj
func (self *ComplexV) VmulConj(b *ComplexV) *ComplexV {
r := Zeros(len(*self))
for k, a := range *self {
(*r)[k] = a * cmplx.Conj((*b)[k])
}
return r
}
示例8: Conj
func (self *ComplexV) Conj() *ComplexV {
r := Zeros(len(*self))
for k, a := range *self {
(*r)[k] = cmplx.Conj(a)
}
return r
}
示例9: ZdotcInc
func ZdotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) {
for i := 0; i < int(n); i++ {
sum += y[iy] * cmplx.Conj(x[ix])
ix += incX
iy += incY
}
return
}
示例10: scaleMul
// ci <- k conj(ai) bi
func scaleMul(c *fftw.Array2, k complex128, a, b *fftw.Array2) {
m, n := a.Dims()
for i := 0; i < m; i++ {
for j := 0; j < n; j++ {
ax := cmplx.Conj(a.At(i, j))
bx := b.At(i, j)
c.Set(i, j, k*ax*bx)
}
}
}
示例11: Conj
// Creates a conjugated copy of the matrix.
func Conj(a Const) *Mat {
m, n := a.Dims()
b := New(m, n)
for i := 0; i < m; i++ {
for j := 0; j < n; j++ {
b.Set(i, j, cmplx.Conj(a.At(i, j)))
}
}
return b
}
示例12: addMul
// ci <- ci + conj(ai) bi
func addMul(c *fftw.Array2, a, b *fftw.Array2) {
m, n := a.Dims()
for i := 0; i < m; i++ {
for j := 0; j < n; j++ {
ax := cmplx.Conj(a.At(i, j))
bx := b.At(i, j)
cx := c.At(i, j)
c.Set(i, j, cx+ax*bx)
}
}
}
示例13: Trans
// implementation of Trans method
func (v *vectorComplex) Trans() {
if v.Type() == ColVector {
v.vectorType = RowVector
} else {
v.vectorType = ColVector
}
for i := 0; i < v.Dim(); i++ {
v.elements[i] = cmplx.Conj(v.elements[i])
}
}
示例14: At
func (a *triangleMat) At(i, j int) complex128 {
swap := otherTri(i, j, a.Tri)
if swap {
i, j = j, i
}
x := a.Mat.At(i, j)
if swap {
x = cmplx.Conj(x)
}
return x
}
示例15: main
func main() {
a := 1 + 1i
b := 3.14159 + 1.25i
fmt.Println("a: ", a)
fmt.Println("b: ", b)
fmt.Println("a + b: ", a+b)
fmt.Println("a * b: ", a*b)
fmt.Println("-a: ", -a)
fmt.Println("1 / a: ", 1/a)
fmt.Println("a̅: ", cmplx.Conj(a))
}