| 1 | /* Author: G. Jungman |
| 2 | */ |
| 3 | #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/ |
| 4 | #include <stdlib.h> |
| 5 | #include <string.h> |
| 6 | #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/ |
| 7 | #include "gsl_qrng.h"cxx . . $ `<file>/external/gsl/gsl_qrng.h`/ |
| 8 | |
| 9 | |
| 10 | gsl_qrngcxx . . $ gsl_qrng# * |
| 11 | gsl_qrng_alloccxx . . $ gsl_qrng_alloc(af9f78a9b5fe42de). (const gsl_qrng_typecxx . . $ gsl_qrng_type# * T, unsigned int dimension) |
| 12 | { |
| 13 | |
| 14 | gsl_qrngcxx . . $ gsl_qrng# * q = (gsl_qrngcxx . . $ gsl_qrng# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (gsl_qrngcxx . . $ gsl_qrng#)); |
| 15 | |
| 16 | if (q == 0) |
| 17 | { |
| 18 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("allocation failed for qrng struct", |
| 19 | GSL_ENOMEM, 0); |
| 20 | }; |
| 21 | |
| 22 | q->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension. = dimension; |
| 23 | q->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size. = T->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_0#state_size.(dimension); |
| 24 | q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (q->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.); |
| 25 | |
| 26 | if (q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state. == 0) |
| 27 | { |
| 28 | freecxx . . $ free(5d22bdacc48458e8). (q); |
| 29 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("allocation failed for qrng state", |
| 30 | GSL_ENOMEM, 0); |
| 31 | }; |
| 32 | |
| 33 | q->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type. = T; |
| 34 | |
| 35 | T->init_statecxx . . $ $anonymous_type_a6b11103b538dc27_0#init_state.(q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., q->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension.); |
| 36 | |
| 37 | return q; |
| 38 | } |
| 39 | |
| 40 | void |
| 41 | gsl_qrng_initcxx . . $ gsl_qrng_init(103b5603e39f15b4). (gsl_qrngcxx . . $ gsl_qrng# * q) |
| 42 | { |
| 43 | (q->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type.->init_statecxx . . $ $anonymous_type_a6b11103b538dc27_0#init_state.) (q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., q->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension.); |
| 44 | } |
| 45 | |
| 46 | int |
| 47 | gsl_qrng_memcpycxx . . $ gsl_qrng_memcpy(edb5fd098e9382d7). (gsl_qrngcxx . . $ gsl_qrng# * dest, const gsl_qrngcxx . . $ gsl_qrng# * src) |
| 48 | { |
| 49 | if (dest->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type. != src->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type.) |
| 50 | { |
| 51 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("generators must be of the same type", GSL_EINVAL); |
| 52 | } |
| 53 | |
| 54 | dest->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension. = src->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension.; |
| 55 | dest->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size. = src->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.; |
| 56 | memcpycxx . . $ memcpy(cc817cb175f282d). (dest->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., src->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., src->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.); |
| 57 | |
| 58 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | gsl_qrngcxx . . $ gsl_qrng# * |
| 63 | gsl_qrng_clonecxx . . $ gsl_qrng_clone(f87888c728be91d9). (const gsl_qrngcxx . . $ gsl_qrng# * q) |
| 64 | { |
| 65 | gsl_qrngcxx . . $ gsl_qrng# * r = (gsl_qrngcxx . . $ gsl_qrng# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (gsl_qrngcxx . . $ gsl_qrng#)); |
| 66 | |
| 67 | if (r == 0) |
| 68 | { |
| 69 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for rng struct", |
| 70 | GSL_ENOMEM, 0); |
| 71 | }; |
| 72 | |
| 73 | r->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension. = q->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension.; |
| 74 | r->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size. = q->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.; |
| 75 | r->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (r->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.); |
| 76 | |
| 77 | if (r->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state. == 0) |
| 78 | { |
| 79 | freecxx . . $ free(5d22bdacc48458e8). (r); |
| 80 | GSL_ERROR_VALcxx . . $ `external/gsl/gsl_errno.h:112:9`! ("failed to allocate space for rng state", |
| 81 | GSL_ENOMEM, 0); |
| 82 | }; |
| 83 | |
| 84 | r->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type. = q->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type.; |
| 85 | |
| 86 | memcpycxx . . $ memcpy(cc817cb175f282d). (r->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., q->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.); |
| 87 | |
| 88 | return r; |
| 89 | } |
| 90 | |
| 91 | #ifndef HIDE_INLINE_STATIC |
| 92 | int |
| 93 | gsl_qrng_getcxx . . $ gsl_qrng_get(6eca0c6bc9fa1511). (const gsl_qrngcxx . . $ gsl_qrng# * q, double x[]) |
| 94 | { |
| 95 | return (q->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type.->getcxx . . $ $anonymous_type_a6b11103b538dc27_0#get.) (q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state., q->dimensioncxx . . $ $anonymous_type_a6b11103b538dc27_1#dimension., x); |
| 96 | } |
| 97 | #endif |
| 98 | |
| 99 | const char * |
| 100 | gsl_qrng_namecxx . . $ gsl_qrng_name(b78cabcc4803f475). (const gsl_qrngcxx . . $ gsl_qrng# * q) |
| 101 | { |
| 102 | return q->typecxx . . $ $anonymous_type_a6b11103b538dc27_1#type.->namecxx . . $ $anonymous_type_a6b11103b538dc27_0#name.; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | size_t |
| 107 | gsl_qrng_sizecxx . . $ gsl_qrng_size(8c7c38b81ddb7ae3). (const gsl_qrngcxx . . $ gsl_qrng# * q) |
| 108 | { |
| 109 | return q->state_sizecxx . . $ $anonymous_type_a6b11103b538dc27_1#state_size.; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | void * |
| 114 | gsl_qrng_statecxx . . $ gsl_qrng_state(619b05e09edfe8c0). (const gsl_qrngcxx . . $ gsl_qrng# * q) |
| 115 | { |
| 116 | return q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state.; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | void |
| 121 | gsl_qrng_freecxx . . $ gsl_qrng_free(103b5603e39f15b4). (gsl_qrngcxx . . $ gsl_qrng# * q) |
| 122 | { |
| 123 | if(q != 0) { |
| 124 | if(q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state. != 0) freecxx . . $ free(5d22bdacc48458e8). (q->statecxx . . $ $anonymous_type_a6b11103b538dc27_1#state.); |
| 125 | freecxx . . $ free(5d22bdacc48458e8). (q); |
| 126 | } |
| 127 | } |