// Qrng_Alloc creates a new quasirandom number generator of the // requested type and dimension and returns it as a QrngState // object. // XXX: using SetFinalizer to release the generator doesn't work // properly since the go runtime destroys the object prematurely. func Qrng_alloc(qrngType QrngType, dim uint) QrngState { state := QrngState{C.gsl_qrng_alloc(qrngType.qrng, C.uint(dim)), dim} // make sure we get rid of any memory associated with the // rng within gsl //runtime.SetFinalizer(&state, // func(qrng *QrngState) {C.gsl_qrng_free(qrng.state)}) return state }
func QrngAlloc(t *GslQrngType, d uint32) *GslQrng { _ref := C.gsl_qrng_alloc((*C.gsl_qrng_type)(unsafe.Pointer(t.Ptr())), C.uint(d)) _result := &GslQrng{} gogsl.InitializeGslReference(_result, uintptr(unsafe.Pointer(_ref))) return _result }