拷贝随机数流函数
拷贝随机数流stream。
接口定义
int vslCopyStream(VSLStreamStatePtr *newStream, VSLStreamStatePtr stream);
参数
参数名  | 
类型  | 
描述  | 
输入/输出  | 
|---|---|---|---|
newStream  | 
VSLStreamStatePtr类型  | 
新随机数流。  | 
输出  | 
stream  | 
VSLStreamStatePtr类型指针  | 
指向被拷贝随机数流结构体的指针。  | 
输入  | 
依赖
#include "krng.h"
示例
#include <stdio.h>
#include <stdlib.h>
#include "krng.h"
int main()
{
   /* initialize stream with given BRNG type and seed */
    VSLStreamStatePtr stream;
    unsigned seed = 42;
    int errcode = vslNewStream(&stream, VSL_BRNG_MCG59, seed);
    if (errcode != VSL_STATUS_OK) {
        fprintf(stderr, "Failure in newstream\n");
        return 0;
    }
    VSLStreamStatePtr stream2;
    if (vslCopyStream(&stream2, stream)) {
        fprintf(stderr, "Failure in vslCopyStream\n");
        return 0;
    }
    /* deinitialize the stream */
    errcode = vslDeleteStream(&stream);
    if (errcode != VSL_STATUS_OK) {
        fprintf(stderr, "Failure in deleting stream\n");
        return 0;
    }
    return 0;
}
父主题: 高性能函数