Example #1
0
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
}
Example #2
0
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))
}
Example #3
0
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
}
Example #4
0
// Generic triangular matrix update; blocked
// S is the start column and row in C; E is the end column and row in C
func DTrmUpdBlk(C, A, B []float64, alpha, beta float64, flags Flags, ldC, ldA, ldB, N, S, E, H, NB int) {
	var Cm C.mdata_t
	var Am C.mdata_t
	var Bm C.mdata_t

	if C == nil || A == nil || B == nil {
		return
	}
	if N == 0 || E-S <= 0 {
		return
	}
	Cm.md = (*C.double)(unsafe.Pointer(&C[0]))
	Cm.step = C.int(ldC)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)

	C.dmmat_trmupd_blk(
		(*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(flags), C.int(N), C.int(S), C.int(E), C.int(H), C.int(NB))

}
Example #5
0
// blas TRMV; unblocked
func DTrimvUnblkMV(X, A []float64, flags Flags, incX, ldA, N int) {
	var Xv C.mvec_t
	var Am C.mdata_t

	if A == nil || X == nil {
		return
	}
	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.dmvec_trid_unb(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.int(flags), C.int(N))

}
Example #6
0
// blas SYR; blocked version
func DSymmRankMV(A, X []float64, alpha float64, flags Flags, ldA, incX, S, L, NB int) {
	var Xv C.mvec_t
	var Am C.mdata_t

	if A == nil || X == nil {
		return
	}
	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.dmvec_symv_rank(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		C.double(alpha), C.int(flags),
		C.int(S), C.int(L), C.int(NB))
}
Example #7
0
func DSolveLowerBlocked(X, A []float64, unit bool, incX, ldA, N, NB int) {
	var Xv C.mvec_t
	var Am C.mdata_t
	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)

	var flags Flags = LOWER
	if unit {
		flags |= UNIT
	}
	C.dmvec_solve_blocked(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.int(flags), C.int(N), C.int(NB))

}
Example #8
0
// blas TSMV; blocked version
func DSolveBlkMV(X, A []float64, flags Flags, incX, ldA, N, NB int) {
	var Xv C.mvec_t
	var Am C.mdata_t

	if A == nil || X == nil {
		return
	}
	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.dmvec_solve_blocked(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.int(flags), C.int(N), C.int(NB))

}
Example #9
0
func DTrimvLowerTransA(X, A []float64, unit bool, incX, ldA, N, NB int) {
	var Xv C.mvec_t
	var Am C.mdata_t
	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)

	var flags Flags = LOWER | TRANSA
	if unit {
		flags |= UNIT
	}
	C.dmvec_trid_unb(
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.int(flags), C.int(N))

}
Example #10
0
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
}
Example #11
0
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))
}
Example #12
0
// 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))
}
Example #13
0
// 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))
}
Example #14
0
// blas GER; blocked version
// A = A + alpha * x * y.T; A is M*N, x is M*1, Y is N*1, 0 < R < E <= M, 0 < S < L <= N
func DRankMV(A, X, Y []float64, alpha float64, ldA, incX, incY, S, L, R, E, NB, MB int) {
	var Yv C.mvec_t
	var Xv C.mvec_t
	var Am C.mdata_t

	if A == nil || X == nil || Y == 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.dmvec_rank(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mvec_t)(unsafe.Pointer(&Xv)),
		(*C.mvec_t)(unsafe.Pointer(&Yv)),
		C.double(alpha),
		C.int(S), C.int(L), C.int(R), C.int(E),
		C.int(NB), C.int(MB))
}
Example #15
0
func DMultSymmOld(C, A, B []float64, alpha, beta float64, flags Flags, ldC, ldA, ldB, P, S, L, R, E, H, NB, MB int) {

	var Cm C.mdata_t
	var Am C.mdata_t
	var Bm C.mdata_t

	Cm.md = (*C.double)(unsafe.Pointer(&C[0]))
	Cm.step = C.int(ldC)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)

	C.dmult_symm_blocked(
		(*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(flags),
		C.int(P), C.int(S), C.int(L), C.int(R), C.int(E),
		C.int(H), C.int(NB), C.int(MB))
}
Example #16
0
func DMult0(C, A, B []float64, alpha, beta float64, trans Flags, ldC, ldA, ldB, P, S, L, R, E, H, NB, MB int) {

	var Cm C.mdata_t
	var Am C.mdata_t
	var Bm C.mdata_t

	if C == nil || B == nil || A == nil {
		return
	}
	Cm.md = (*C.double)(unsafe.Pointer(&C[0]))
	Cm.step = C.int(ldC)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)

	C.dmult_mm_blocked2(
		(*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(trans),
		C.int(P), C.int(S), C.int(L), C.int(R), C.int(E),
		C.int(H), C.int(NB), C.int(MB))
}
Example #17
0
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))
}
Example #18
0
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
}
Example #19
0
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
}
Example #20
0
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
}
Example #21
0
func DTrmmLowerTransA(B, A []float64, alpha float64, unit bool, ldB, ldA, N, S, L int) {
	var Bm C.mdata_t
	var Am C.mdata_t
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)

	var flags Flags = LOWER | TRANSA
	if unit {
		flags |= UNIT
	}
	C.dmmat_trid_unb(
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.int(flags), C.int(N), C.int(S), C.int(L))

}
Example #22
0
// matrix-matrix: A = alpha*A + beta*B
func DScalePlus(A, B []float64, alpha, beta float64, flags Flags, ldA, ldB, S, L, R, E int) {
	var Am C.mdata_t
	var Bm C.mdata_t

	if B == nil || A == nil {
		return
	}
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)

	C.dmmat_scale_plus(
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		C.double(alpha), C.double(beta), C.int(flags),
		C.int(S), C.int(L),
		C.int(R), C.int(E))
}
Example #23
0
// blas TRSM; blocked
// S is the start column (LEFT), row (RIGHT); E is the end column (LEFT), row (RIGHT)
func DSolveBlk(B, A []float64, alpha float64, flags Flags, ldB, ldA, N, S, E, NB int) {
	var Bm C.mdata_t
	var Am C.mdata_t

	if B == nil || A == nil {
		return
	}
	if N == 0 || E-S <= 0 {
		return
	}
	Bm.md = (*C.double)(unsafe.Pointer(&B[0]))
	Bm.step = C.int(ldB)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)

	C.dmmat_solve_blk(
		(*C.mdata_t)(unsafe.Pointer(&Bm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.int(flags), C.int(N), C.int(S), C.int(E), C.int(NB))

}
Example #24
0
// blas SYRK; blocked
// S is the start column and row in C; E is the end column and row in C
func DSymmRankBlk(C, A []float64, alpha, beta float64, flags Flags, ldC, ldA, N, S, E, H, NB int) {
	var Cm C.mdata_t
	var Am C.mdata_t

	if C == nil || A == nil {
		return
	}
	if N == 0 || E-S <= 0 {
		return
	}
	Cm.md = (*C.double)(unsafe.Pointer(&C[0]))
	Cm.step = C.int(ldC)
	Am.md = (*C.double)(unsafe.Pointer(&A[0]))
	Am.step = C.int(ldA)

	C.dmmat_rank_blk(
		(*C.mdata_t)(unsafe.Pointer(&Cm)),
		(*C.mdata_t)(unsafe.Pointer(&Am)),
		C.double(alpha), C.double(beta),
		C.int(flags), C.int(N), C.int(S), C.int(E), C.int(H), C.int(NB))

}