示例#1
0
文件: axpy.go 项目: hrautila/gomas
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
}
示例#2
0
文件: scal.go 项目: hrautila/gomas
func minvscale(A *cmat.FloatMatrix, alpha float64, M, N int) {
	var a C.mdata_t

	a.md = (*C.double)(unsafe.Pointer(&A.Data()[0]))
	a.step = C.int(A.Stride())
	C.__d_blk_invscale(
		(*C.mdata_t)(unsafe.Pointer(&a)), C.double(alpha), C.int(M), C.int(N))
	return
}
示例#3
0
文件: scal.go 项目: hrautila/gomas
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
}
示例#4
0
文件: iamax.go 项目: hrautila/gomas
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)
}
示例#5
0
文件: plus.go 项目: hrautila/gomas
func plus(Ac, Bc *cmat.FloatMatrix, alpha, beta float64, bits, S, L, R, E int) {
	var Am, Bm C.mdata_t

	Am.md = (*C.double)(unsafe.Pointer(&Ac.Data()[0]))
	Am.step = C.int(Ac.Stride())
	Bm.md = (*C.double)(unsafe.Pointer(&Bc.Data()[0]))
	Bm.step = C.int(Bc.Stride())

	C.__d_scale_plus(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		C.double(alpha), C.double(beta), C.int(bits),
		C.int(S), C.int(L), C.int(R), C.int(E))
}
示例#6
0
文件: asum.go 项目: hrautila/gomas
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)
}
示例#7
0
文件: copy.go 项目: hrautila/gomas
func mtranspose(A, B *cmat.FloatMatrix, M, N int) {
	var a, b C.mdata_t
	if M == 0 || N == 0 {
		return
	}

	a.md = (*C.double)(unsafe.Pointer(&A.Data()[0]))
	a.step = C.int(A.Stride())
	b.md = (*C.double)(unsafe.Pointer(&B.Data()[0]))
	b.step = C.int(B.Stride())
	C.__d_blk_transpose(
		(*C.mdata_t)(unsafe.Pointer(&a)),
		(*C.mdata_t)(unsafe.Pointer(&b)), C.int(M), C.int(N))
	return
}
示例#8
0
文件: syrk.go 项目: hrautila/gomas
func syrk(Cc, Ac *cmat.FloatMatrix, alpha, beta float64, bits, P, S, E int, conf *gomas.Config) error {
	var Am, Cm C.mdata_t

	Am.md = (*C.double)(unsafe.Pointer(&Ac.Data()[0]))
	Am.step = C.int(Ac.Stride())
	Cm.md = (*C.double)(unsafe.Pointer(&Cc.Data()[0]))
	Cm.step = C.int(Cc.Stride())

	C.__d_rank_blk(
		(*C.mdata_t)(unsafe.Pointer(&Cm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.double(beta), C.int(bits),
		C.int(P), C.int(S), C.int(E),
		C.int(conf.KB), C.int(conf.NB), C.int(conf.MB))
	return nil
}
示例#9
0
文件: trsm.go 项目: hrautila/gomas
func trsm(Bc, Ac *cmat.FloatMatrix, alpha float64, bits, N, S, E int, conf *gomas.Config) error {
	var Am, Bm C.mdata_t

	Am.md = (*C.double)(unsafe.Pointer(&Ac.Data()[0]))
	Am.step = C.int(Ac.Stride())
	Bm.md = (*C.double)(unsafe.Pointer(&Bc.Data()[0]))
	Bm.step = C.int(Bc.Stride())

	C.__d_solve_blocked(
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.int(bits),
		C.int(N), C.int(S), C.int(E),
		C.int(conf.KB), C.int(conf.NB), C.int(conf.MB))

	return nil
}
示例#10
0
文件: trmv.go 项目: hrautila/gomas
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
}
示例#11
0
文件: swap.go 项目: hrautila/gomas
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
}
示例#12
0
文件: dot.go 项目: hrautila/gomas
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)
}
示例#13
0
文件: gemv.go 项目: hrautila/gomas
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))
}
示例#14
0
文件: updtrmv.go 项目: hrautila/gomas
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
}
示例#15
0
文件: mult.go 项目: hrautila/gomas
func gemm(Cc, Ac, Bc *cmat.FloatMatrix, alpha, beta float64, bits, P, S, L, R, E int, conf *gomas.Config) {
	var Am, Cm, Bm C.mdata_t

	Am.md = (*C.double)(unsafe.Pointer(&Ac.Data()[0]))
	Am.step = C.int(Ac.Stride())
	Bm.md = (*C.double)(unsafe.Pointer(&Bc.Data()[0]))
	Bm.step = C.int(Bc.Stride())
	Cm.md = (*C.double)(unsafe.Pointer(&Cc.Data()[0]))
	Cm.step = C.int(Cc.Stride())

	C.__d_gemm_inner(
		(*C.mdata_t)(unsafe.Pointer(&Cm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		C.double(alpha), C.double(beta), C.int(bits),
		C.int(P), C.int(S), C.int(L), C.int(R), C.int(E),
		C.int(conf.KB), C.int(conf.NB), C.int(conf.MB))
}