當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cmplx.Conj函數代碼示例

本文整理匯總了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
}
開發者ID:ominux,項目名稱:negf_mtj,代碼行數:33,代碼來源:cmplxSparse.go

示例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
}
開發者ID:jefferyyuan,項目名稱:RosettaCodeData,代碼行數:25,代碼來源:cholesky-decomposition-2.go

示例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
}
開發者ID:ominux,項目名稱:negf_mtj,代碼行數:15,代碼來源:cmplxSparse.go

示例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
}
開發者ID:mingzhi,項目名稱:gomath,代碼行數:34,代碼來源:fft.go

示例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)
}
開發者ID:jvlmdr,項目名稱:lin-go,代碼行數:7,代碼來源:triangle.go

示例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
}
開發者ID:eddytrex,項目名稱:AIgo,代碼行數:35,代碼來源:Arithmetic.go

示例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
}
開發者ID:a4a881d4,項目名稱:gosse,代碼行數:7,代碼來源:cmplxv.go

示例8: Conj

func (self *ComplexV) Conj() *ComplexV {
	r := Zeros(len(*self))
	for k, a := range *self {
		(*r)[k] = cmplx.Conj(a)
	}
	return r
}
開發者ID:a4a881d4,項目名稱:gosse,代碼行數:7,代碼來源:cmplxv.go

示例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
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:8,代碼來源:zdotc.go

示例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)
		}
	}
}
開發者ID:jvlmdr,項目名稱:go-cv,代碼行數:11,代碼來源:util.go

示例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
}
開發者ID:jvlmdr,項目名稱:lin-go,代碼行數:11,代碼來源:cmplx.go

示例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)
		}
	}
}
開發者ID:jvlmdr,項目名稱:go-cv,代碼行數:12,代碼來源:util.go

示例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])
	}
}
開發者ID:pwplus,項目名稱:GoCalculate,代碼行數:12,代碼來源:vectorComplex.go

示例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
}
開發者ID:jvlmdr,項目名稱:lin-go,代碼行數:11,代碼來源:triangle.go

示例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))
}
開發者ID:travis1230,項目名稱:RosettaCodeData,代碼行數:11,代碼來源:arithmetic-complex.go


注:本文中的math/cmplx.Conj函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。