コード例 #1
0
ファイル: cgo_dtrtrs.go プロジェクト: jvlmdr/lin-go
// DTRTRS: (Double-precision) TRiangular Solve
//
// http://www.netlib.org/lapack/double/dtrtrs.f
func dtrtrs(tri Triangle, t bool, diag diagType, n, nrhs int, a []float64, lda int, b []float64, ldb int) error {
	var (
		uplo_  = uploChar(tri)
		trans_ = transChar(t)
		diag_  = diagChar(diag)
		n_     = C.integer(n)
		nrhs_  = C.integer(nrhs)
		a_     = ptrFloat64(a)
		lda_   = C.integer(lda)
		b_     = ptrFloat64(b)
		ldb_   = C.integer(ldb)
	)
	var info_ C.integer

	C.dtrtrs_(&uplo_, &trans_, &diag_, &n_, &nrhs_, a_, &lda_, b_, &ldb_, &info_)

	info := int(info_)
	switch {
	case info < 0:
		return errInvalidArg(-info)
	case info > 0:
		return errSingular(info)
	default:
		return nil
	}
}
コード例 #2
0
ファイル: cgo_double.go プロジェクト: jvlmdr/linalg
// void dtrtrs_(char *uplo, char *trans, char *diag, int *n, int *nrhs,
//		double  *A, int *lda, double *B, int *ldb, int *info);
func dtrtrs(uplo, trans, diag string, N, Nrhs int, A []float64, lda int, B []float64, ldb int) int {

	var info int = 0
	cuplo := C.CString(uplo)
	defer C.free(unsafe.Pointer(cuplo))
	ctrans := C.CString(trans)
	defer C.free(unsafe.Pointer(ctrans))
	cdiag := C.CString(diag)
	defer C.free(unsafe.Pointer(cdiag))

	C.dtrtrs_(cuplo, ctrans, cdiag,
		(*C.int)(unsafe.Pointer(&N)),
		(*C.int)(unsafe.Pointer(&Nrhs)),
		(*C.double)(unsafe.Pointer(&A[0])),
		(*C.int)(unsafe.Pointer(&lda)),
		(*C.double)(unsafe.Pointer(&B[0])),
		(*C.int)(unsafe.Pointer(&ldb)),
		(*C.int)(unsafe.Pointer(&info)))
	return info
}