github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgRand/LcgCalculateConstants/LcgCalcuateConstants.go (about)

     1  package LcgCalculateConstants
     2  
     3  /*
     4  //cgo not work in cygwin...,and main in c not work in cgo too..
     5  #cgo LDFLAGS: -lm
     6  #include "c/rand-lcg.h"
     7  #include "c/rand-lcg.c"
     8  #include "c/rand-primegen.h"
     9  #include "c/rand-primegen.c"
    10  */
    11  import "C"
    12  
    13  //计算lcg常数,效果往往不好,需要使用m的质因数去乘(a-1)
    14  func LcgCalculateConstants(m uint64, inC uint64) (a uint64, c uint64) {
    15  	C.lcg_calculate_constants(C.uint64_t(m), (*C.uint64_t)(&a), (*C.uint64_t)(&inC), 0)
    16  	c = inC
    17  	return
    18  }
    19  
    20  func LcgCalculateConstantsDebug(m uint64, inC uint64) (a uint64, c uint64) {
    21  	C.lcg_calculate_constants(C.uint64_t(m), (*C.uint64_t)(&a), (*C.uint64_t)(&inC), 1)
    22  	c = inC
    23  	return
    24  }