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


Golang mvec_t.inc方法代碼示例

本文整理匯總了Golang中C.mvec_t.inc方法的典型用法代碼示例。如果您正苦於以下問題:Golang mvec_t.inc方法的具體用法?Golang mvec_t.inc怎麽用?Golang mvec_t.inc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在C.mvec_t的用法示例。


在下文中一共展示了mvec_t.inc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: updtrmv

func updtrmv(A, X, Y *cmat.FloatMatrix, alpha float64, bits, N, M int) error {
	var Am C.mdata_t
	var Xm, Ym C.mvec_t

	xr, _ := X.Size()
	yr, _ := Y.Size()
	Am.md = (*C.double)(unsafe.Pointer(&A.Data()[0]))
	Am.step = C.int(A.Stride())
	Xm.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	Ym.md = (*C.double)(unsafe.Pointer(&Y.Data()[0]))
	Ym.inc = C.int(1)
	Xm.inc = C.int(1)

	// if row vectors, change increment
	if xr == 1 {
		Xm.inc = C.int(X.Stride())
	}
	if yr == 1 {
		Ym.inc = C.int(Y.Stride())
	}

	C.__d_update_trmv_unb(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xm)),
		(*C.mvec_t)(unsafe.Pointer(&Ym)),
		C.double(alpha), C.int(bits), C.int(N), C.int(M))
	return nil
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:28,代碼來源:updtrmv.go

示例2: gemv

func gemv(Y, A, X *cmat.FloatMatrix, alpha, beta float64, bits, S, L, R, E int) {
	var Am C.mdata_t
	var Xm, Ym C.mvec_t

	xr, _ := X.Size()
	yr, _ := Y.Size()
	Am.md = (*C.double)(unsafe.Pointer(&A.Data()[0]))
	Am.step = C.int(A.Stride())
	Xm.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	Ym.md = (*C.double)(unsafe.Pointer(&Y.Data()[0]))
	Ym.inc = C.int(1)
	Xm.inc = C.int(1)

	// if row vectors, change increment
	if xr == 1 {
		Xm.inc = C.int(X.Stride())
	}
	if yr == 1 {
		Ym.inc = C.int(Y.Stride())
	}

	C.__d_gemv_unb(
		(*C.mvec_t)(unsafe.Pointer(&Ym)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xm)),
		C.double(alpha),
		/*C.double(beta),*/
		C.int(bits),
		C.int(S), C.int(L), C.int(R), C.int(E))
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:30,代碼來源:gemv.go

示例3: axpby

func axpby(Y, X *cmat.FloatMatrix, alpha, beta float64, N int) {
	var x, y C.mvec_t

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	yr, _ := Y.Size()
	y.md = (*C.double)(unsafe.Pointer(&Y.Data()[0]))
	y.inc = C.int(1)
	if yr == 1 {
		y.inc = C.int(Y.Stride())
	}
	if beta == 1.0 {
		C.__d_vec_axpy(
			(*C.mvec_t)(unsafe.Pointer(&y)),
			(*C.mvec_t)(unsafe.Pointer(&x)),
			C.double(alpha), C.int(N))
	} else {
		C.__d_vec_axpby(
			(*C.mvec_t)(unsafe.Pointer(&y)),
			(*C.mvec_t)(unsafe.Pointer(&x)),
			C.double(alpha), C.double(beta), C.int(N))
	}
	return
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:28,代碼來源:axpy.go

示例4: vinvscal

func vinvscal(X *cmat.FloatMatrix, alpha float64, N int) {
	var x C.mvec_t

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	C.__d_vec_invscal(
		(*C.mvec_t)(unsafe.Pointer(&x)), C.double(alpha), C.int(N))
	return
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:13,代碼來源:scal.go

示例5: iamax

func iamax(X *cmat.FloatMatrix, N int) int {
	var x C.mvec_t
	var ix C.int

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	ix = C.__d_vec_iamax(
		(*C.mvec_t)(unsafe.Pointer(&x)), C.int(N))
	return int(ix)
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:14,代碼來源:iamax.go

示例6: sum

func sum(X *cmat.FloatMatrix, N int) float64 {
	var x C.mvec_t
	var dc C.double

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	dc = C.__d_vec_sum_recursive(
		(*C.mvec_t)(unsafe.Pointer(&x)), C.int(N))
	return float64(dc)
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:14,代碼來源:asum.go

示例7: DCopy

// copying: X := Y
func DCopy(X, Y []float64, incX, incY, N int) {

	var Xv C.mvec_t
	var Yv C.mvec_t

	if X == nil || Y == nil || N <= 0 {
		return
	}
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)

	C.dvec_copy(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.int(N))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:19,代碼來源:cmops.go

示例8: trmv

func trmv(X, A *cmat.FloatMatrix, alpha float64, bits, N int) error {
	var Am C.mdata_t
	var Xm C.mvec_t

	xr, _ := X.Size()
	Am.md = (*C.double)(unsafe.Pointer(&A.Data()[0]))
	Am.step = C.int(A.Stride())
	Xm.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	Xm.inc = C.int(1)
	// if row vectors, change increment
	if xr == 1 {
		Xm.inc = C.int(X.Stride())
	}
	C.__d_trmv_unb(
		(*C.mvec_t)(unsafe.Pointer(&Xm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.int(bits), C.int(N))
	return nil
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:19,代碼來源:trmv.go

示例9: vswap

func vswap(X, Y *cmat.FloatMatrix, N int) {
	var x, y C.mvec_t

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	yr, _ := Y.Size()
	y.md = (*C.double)(unsafe.Pointer(&Y.Data()[0]))
	y.inc = C.int(1)
	if yr == 1 {
		y.inc = C.int(Y.Stride())
	}
	C.__d_vec_swap(
		(*C.mvec_t)(unsafe.Pointer(&x)),
		(*C.mvec_t)(unsafe.Pointer(&y)), C.int(N))
	return
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:20,代碼來源:swap.go

示例10: DiffNorm2

// return: sum (abs(X[i]-Y[i]))^2
func DiffNorm2(X, Y []float64, incX, incY, N int) float64 {

	var nrm C.double
	var Xv C.mvec_t
	var Yv C.mvec_t

	if X == nil || Y == nil || N <= 0 {
		return 0.0
	}
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)

	nrm = C.dvec_diff_nrm2(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.int(N))
	return float64(nrm)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:21,代碼來源:cmops.go

示例11: dot

func dot(X, Y *cmat.FloatMatrix, N int) float64 {
	var x, y C.mvec_t
	var dc C.double

	xr, _ := X.Size()
	x.md = (*C.double)(unsafe.Pointer(&X.Data()[0]))
	x.inc = C.int(1)
	if xr == 1 {
		x.inc = C.int(X.Stride())
	}
	yr, _ := Y.Size()
	y.md = (*C.double)(unsafe.Pointer(&Y.Data()[0]))
	y.inc = C.int(1)
	if yr == 1 {
		y.inc = C.int(Y.Stride())
	}
	dc = C.__d_vec_dot_recursive(
		(*C.mvec_t)(unsafe.Pointer(&x)),
		(*C.mvec_t)(unsafe.Pointer(&y)), C.int(N))
	return float64(dc)
}
開發者ID:hrautila,項目名稱:gomas,代碼行數:21,代碼來源:dot.go

示例12: DDot

// return: alpha * X * Y
func DDot(X, Y []float64, alpha float64, incX, incY, N int) float64 {

	var dot C.double
	var Xv C.mvec_t
	var Yv C.mvec_t

	if X == nil || Y == nil || N <= 0 {
		return 0.0
	}
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)

	dot = C.dvec_dot(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.double(alpha),
		C.int(N))
	return float64(dot)
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:22,代碼來源:cmops.go

示例13: DTrmUpdMV

// generic triangular matrix rank update; A = A + alpha*X*Y.T
func DTrmUpdMV(A, X, Y []float64, alpha float64, flags Flags, ldA, incX, incY, S, L, NB int) {
	var Xv C.mvec_t
	var Yv C.mvec_t
	var Am C.mdata_t

	if A == nil || X == nil || Y == nil {
		return
	}
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)

	C.dmvec_trmv_upd(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.double(alpha), C.int(flags),
		C.int(S), C.int(L), C.int(NB))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:23,代碼來源:cmops.go

示例14: DMultMV

// blas GEMV; blocked version
// Y = alpha*A*X + beta*Y; Y is M*1, X is N*1 and A is M*N
func DMultMV(Y, A, X []float64, alpha, beta float64, flags Flags, incY, ldA, incX, S, L, R, E, H, MB int) {
	var Yv C.mvec_t
	var Xv C.mvec_t
	var Am C.mdata_t

	if Y == nil || A == nil || X == nil {
		return
	}
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)

	C.dmult_gemv_blocked(
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		C.double(alpha), C.double(beta), C.int(flags),
		C.int(S), C.int(L), C.int(R), C.int(E),
		C.int(H), C.int(MB))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:25,代碼來源:cmops.go

示例15: DDotSum

// Z[0] = beta*Z[0] + alpha * X * Y
func DDotSum(Z, X, Y []float64, alpha, beta float64, incZ, incX, incY, N int) {

	var Zv C.mvec_t
	var Xv C.mvec_t
	var Yv C.mvec_t

	if Z == nil || X == nil || Y == nil || N <= 0 {
		return
	}
	Xv.md = (*C.double)(unsafe.Pointer(&X[0]))
	Xv.inc = C.int(incX)
	Zv.md = (*C.double)(unsafe.Pointer(&Z[0]))
	Zv.inc = C.int(incZ)
	Yv.md = (*C.double)(unsafe.Pointer(&Y[0]))
	Yv.inc = C.int(incY)

	C.dvec_dots(
		(*C.mvec_t)(unsafe.Pointer(&Zv)),
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.double(alpha), C.double(beta),
		C.int(N))
}
開發者ID:sguzwf,項目名稱:algorithm,代碼行數:24,代碼來源:cmops.go


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