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


Golang GslRng.Ptr方法代碼示例

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


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

示例1: Dir3d

func Dir3d(r *rng.GslRng) (float64, float64, float64) {
	var _outptr_1 C.double
	var _outptr_2 C.double
	var _outptr_3 C.double
	C.gsl_ran_dir_3d((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), &_outptr_1, &_outptr_2, &_outptr_3)
	return *(*float64)(unsafe.Pointer(&_outptr_1)), *(*float64)(unsafe.Pointer(&_outptr_2)), *(*float64)(unsafe.Pointer(&_outptr_3))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:7,代碼來源:randist.go

示例2: Shuffle

func Shuffle(rng *rng.GslRng, data interface{}, n int) {
	// data must be a slice
	dataType := reflect.TypeOf(data)
	if dataType.Kind() != reflect.Slice {
		gogsl.Error("rng.Shuffle() must have a slice as its second argument", gogsl.GSL_EINVAL)
		return
	}
	baseType := dataType.Elem()
	dataVal := reflect.ValueOf(data)
	sliceN := dataVal.Len()
	if sliceN < 0 {
		gogsl.Error("shuffle length may not be negative in rng.Shuffle()", gogsl.GSL_EINVAL)
		return
	}
	if sliceN < n {
		gogsl.Error("shuffle length too large for slice in rng.Shuffle()", gogsl.GSL_EINVAL)
		return
	}
	elementLen := baseType.Size()
	addr := dataVal.Index(0).UnsafeAddr()

	//hdr := (*reflect.SliceHeader)(unsafe.Pointer(addr))
	//void gsl_ran_shuffle (const gsl_rng * r, void * base, size_t n, size_t size)
	C.gsl_ran_shuffle((*C.gsl_rng)(unsafe.Pointer(rng.Ptr())),
		unsafe.Pointer(addr),
		C.size_t(n), C.size_t(elementLen))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:27,代碼來源:randist_support.go

示例3: Solve

func Solve(r *rng.GslRng, x0 interface{},
	ef GslSimanEnergyFunctionType,
	takeStep GslSimanStepFunctionType,
	distance GslSimanMetricFunctionType,
	printPosition GslSimanPrintFunctionType,
	copyfunc GslSimanCopyFunctionType,
	copyConstructor GslSimanCopyConstructFunctionType,
	destructor GslSimanDestroyFunctionType,
	params *GslSimanParams) {

	impl := &GslSimanImplementation{
		energyFn: ef,
		stepFn:   takeStep,
		metricFn: distance,
		printFn:  printPosition,
		copyFn:   copyfunc,
		ctorFn:   copyConstructor,
		freeFn:   destructor,
		holdRefs: make(map[uintptr]*GslSimanArgument),
	}

	initialArg := &GslSimanArgument{
		impl: impl,
		x:    x0,
	}
	InitializeGslSimanParams(params)
	var printFn *[0]byte
	if impl.printFn != nil {
		printFn = (*[0]byte)(C._gsl_siman_print_function_proxy)
	}
	C.gsl_siman_solve((*C.gsl_rng)(unsafe.Pointer(r.Ptr())),
		unsafe.Pointer(initialArg),
		(*[0]byte)(C._gsl_siman_energy_function_proxy),
		(*[0]byte)(C._gsl_siman_step_function_proxy),
		(*[0]byte)(C._gsl_siman_metric_function_proxy),
		printFn,
		(*[0]byte)(C._gsl_siman_copy_function_proxy),
		(*[0]byte)(C._gsl_siman_ctor_function_proxy),
		(*[0]byte)(C._gsl_siman_dtor_function_proxy),
		C.size_t(GSL_SIMAN_ARGUMENT_SIZE),
		*(*C.gsl_siman_params_t)(unsafe.Pointer(params.CPtr())))
}
開發者ID:dtromb,項目名稱:gogsl,代碼行數:42,代碼來源:siman_support.go

示例4: Choose

// void gsl_ran_sample (const gsl_rng * r, void * dest, size_t k, void * src, size_t n, size_t size)
func Choose(rng *rng.GslRng, dest interface{}, src interface{}, n int) int {
	// data must be a slice
	destDataType := reflect.TypeOf(dest)
	if destDataType.Kind() != reflect.Slice {
		gogsl.Error("rng.Choose() must have a slice as its second argument", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	srcDataType := reflect.TypeOf(src)
	if srcDataType.Kind() != reflect.Slice {
		gogsl.Error("rng.Choose() must have a slice as its third argument", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	if destDataType != srcDataType {
		gogsl.Error("rng.Choose() source and destination data types must match", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	if n < 0 {
		gogsl.Error("length may not be negative in rng.Choose()", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	baseType := destDataType.Elem()
	destVal := reflect.ValueOf(dest)
	srcVal := reflect.ValueOf(src)
	sliceN := destVal.Len()
	if sliceN < n {
		gogsl.Error("sample length too large for slice in rng.Choose()", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	if srcVal.Len() < n {
		gogsl.Error("sample length too large for source in rng.Choose()", gogsl.GSL_EINVAL)
		return int(gogsl.GSL_EINVAL)
	}
	elementLen := baseType.Size()
	srcAddr := srcVal.Index(0).UnsafeAddr()
	destAddr := destVal.Index(0).UnsafeAddr()
	return int(C.gsl_ran_choose((*C.gsl_rng)(unsafe.Pointer(rng.Ptr())),
		unsafe.Pointer(destAddr), C.size_t(sliceN),
		unsafe.Pointer(srcAddr), C.size_t(srcVal.Len()),
		C.size_t(elementLen)))
}
開發者ID:dtromb,項目名稱:gogsl,代碼行數:41,代碼來源:randist_support.go

示例5: Multinomial

func Multinomial(r *rng.GslRng, k int, n uint32, p []float64, x []uint32) {
	_slice_header_3 := (*reflect.SliceHeader)(unsafe.Pointer(&p))
	_slice_header_4 := (*reflect.SliceHeader)(unsafe.Pointer(&x))
	C.gsl_ran_multinomial((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.size_t(k), C.uint(n), (*C.double)(unsafe.Pointer(_slice_header_3.Data)), (*C.uint)(unsafe.Pointer(_slice_header_4.Data)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:5,代碼來源:randist.go

示例6: Fdist

func Fdist(r *rng.GslRng, nu1 float64, nu2 float64) float64 {
	return float64(C.gsl_ran_fdist((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(nu1), C.double(nu2)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例7: Bernoulli

func Bernoulli(r *rng.GslRng, p float64) uint32 {
	return uint32(C.gsl_ran_bernoulli((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(p)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例8: BivariateGaussian

func BivariateGaussian(r *rng.GslRng, sigmaX float64, sigmaY float64, rho float64) (float64, float64) {
	var _outptr_4 C.double
	var _outptr_5 C.double
	C.gsl_ran_bivariate_gaussian((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(sigmaX), C.double(sigmaY), C.double(rho), &_outptr_4, &_outptr_5)
	return *(*float64)(unsafe.Pointer(&_outptr_4)), *(*float64)(unsafe.Pointer(&_outptr_5))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:6,代碼來源:randist.go

示例9: GaussianZiggurat

func GaussianZiggurat(r *rng.GslRng, sigma float64) float64 {
	return float64(C.gsl_ran_gaussian_ziggurat((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(sigma)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例10: Geometric

func Geometric(r *rng.GslRng, p float64) uint32 {
	return uint32(C.gsl_ran_geometric((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(p)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例11: Logarithmic

func Logarithmic(r *rng.GslRng, p float64) uint32 {
	return uint32(C.gsl_ran_logarithmic((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(p)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例12: Lognormal

func Lognormal(r *rng.GslRng, zeta float64, sigma float64) float64 {
	return float64(C.gsl_ran_lognormal((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.double(zeta), C.double(sigma)))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例13: DirNd

func DirNd(r *rng.GslRng, n int) float64 {
	var _outptr_2 C.double
	C.gsl_ran_dir_nd((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), C.size_t(n), &_outptr_2)
	return *(*float64)(unsafe.Pointer(&_outptr_2))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:5,代碼來源:randist.go

示例14: UgaussianRatioMethod

func UgaussianRatioMethod(r *rng.GslRng) float64 {
	return float64(C.gsl_ran_ugaussian_ratio_method((*C.gsl_rng)(unsafe.Pointer(r.Ptr()))))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:3,代碼來源:randist.go

示例15: Dir2dTrigMethod

func Dir2dTrigMethod(r *rng.GslRng) (float64, float64) {
	var _outptr_1 C.double
	var _outptr_2 C.double
	C.gsl_ran_dir_2d_trig_method((*C.gsl_rng)(unsafe.Pointer(r.Ptr())), &_outptr_1, &_outptr_2)
	return *(*float64)(unsafe.Pointer(&_outptr_1)), *(*float64)(unsafe.Pointer(&_outptr_2))
}
開發者ID:postfix,項目名稱:gsl-1,代碼行數:6,代碼來源:randist.go


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