Lines Matching +full:- +full:r

19 static PetscErrorCode PetscRandomSeed_Random123(PetscRandom r)  in PetscRandomSeed_Random123()  argument
22 PetscRandom123 *r123 = (PetscRandom123 *)r->data; in PetscRandomSeed_Random123()
25 ukey.v[0] = (R123_ULONG_LONG)r->seed; in PetscRandomSeed_Random123()
31 r123->key = threefry4x64keyinit(ukey); in PetscRandomSeed_Random123()
32 r123->counter.v[0] = 0; in PetscRandomSeed_Random123()
33 r123->counter.v[1] = 1; in PetscRandomSeed_Random123()
34 r123->counter.v[2] = 2; in PetscRandomSeed_Random123()
35 r123->counter.v[3] = 3; in PetscRandomSeed_Random123()
36 r123->result = threefry4x64(r123->counter, r123->key); in PetscRandomSeed_Random123()
37 r123->count = 0; in PetscRandomSeed_Random123()
45 PetscInt mod = (r123->count++) % 4; in PetscRandom123Step()
48 ret = r123->result.v[mod] * scale + shift; in PetscRandom123Step()
51 r123->counter.v[0] += 4; in PetscRandom123Step()
52 r123->counter.v[1] += 4; in PetscRandom123Step()
53 r123->counter.v[2] += 4; in PetscRandom123Step()
54 r123->counter.v[3] += 4; in PetscRandom123Step()
55 r123->result = threefry4x64(r123->counter, r123->key); in PetscRandom123Step()
61 static PetscErrorCode PetscRandomGetValue_Random123(PetscRandom r, PetscScalar *val) in PetscRandomGetValue_Random123() argument
63 PetscRandom123 *r123 = (PetscRandom123 *)r->data; in PetscRandomGetValue_Random123()
72 if (r->iset) { in PetscRandomGetValue_Random123()
73 re = re * PetscRealPart(r->width) + PetscRealPart(r->low); in PetscRandomGetValue_Random123()
74 im = im * PetscImaginaryPart(r->width) + PetscImaginaryPart(r->low); in PetscRandomGetValue_Random123()
81 if (r->iset) rscal = rscal * r->width + r->low; in PetscRandomGetValue_Random123()
87 static PetscErrorCode PetscRandomGetValueReal_Random123(PetscRandom r, PetscReal *val) in PetscRandomGetValueReal_Random123() argument
89 PetscRandom123 *r123 = (PetscRandom123 *)r->data; in PetscRandomGetValueReal_Random123()
94 if (r->iset) rreal = rreal * PetscRealPart(r->width) + PetscRealPart(r->low); in PetscRandomGetValueReal_Random123()
99 static PetscErrorCode PetscRandomGetValuesReal_Random123(PetscRandom r, PetscInt n, PetscReal vals[… in PetscRandomGetValuesReal_Random123() argument
101 PetscRandom123 *r123 = (PetscRandom123 *)r->data; in PetscRandomGetValuesReal_Random123()
109 peel_start = (4 - (r123->count % 4)) % 4; in PetscRandomGetValuesReal_Random123()
111 for (PetscInt i = 0; i < peel_start; i++) PetscCall(PetscRandomGetValueReal(r, &vals[i])); in PetscRandomGetValuesReal_Random123()
112 PetscAssert((r123->count % 4) == 0, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Bad modular arithmetic"); in PetscRandomGetValuesReal_Random123()
113 n -= peel_start; in PetscRandomGetValuesReal_Random123()
116 lim = n - rem; in PetscRandomGetValuesReal_Random123()
117 if (r->iset) { in PetscRandomGetValuesReal_Random123()
118 scale *= PetscRealPart(r->width); in PetscRandomGetValuesReal_Random123()
119 shift *= PetscRealPart(r->width); in PetscRandomGetValuesReal_Random123()
120 shift += PetscRealPart(r->low); in PetscRandomGetValuesReal_Random123()
132 r123_copy.result = threefry4x64(r123->counter, r123->key); in PetscRandomGetValuesReal_Random123()
136 for (PetscInt i = 0; i < rem; i++) PetscCall(PetscRandomGetValueReal(r, &vals[i])); in PetscRandomGetValuesReal_Random123()
140 static PetscErrorCode PetscRandomGetValues_Random123(PetscRandom r, PetscInt n, PetscScalar vals[]) in PetscRandomGetValues_Random123() argument
144 for (PetscInt i = 0; i < n; i++) PetscCall(PetscRandomGetValue_Random123(r, n, &vals[i])); in PetscRandomGetValues_Random123()
146 PetscCall(PetscRandomGetValuesReal_Random123(r, n, vals)); in PetscRandomGetValues_Random123()
151 static PetscErrorCode PetscRandomDestroy_Random123(PetscRandom r) in PetscRandomDestroy_Random123() argument
154 PetscCall(PetscFree(r->data)); in PetscRandomDestroy_Random123()
159 // clang-format off
166 // clang-format on
170 …PETSCRANDOM123 - access to Random123 counter based pseudorandom number generators (currently three…
173 . -random_type <rand,rand48,sprng,random123> - select the random number generator at runtim
178 …PETSc must be ./configure with the option --download-random123 to use this random number generator.
183 PETSC_EXTERN PetscErrorCode PetscRandomCreate_Random123(PetscRandom r) in PetscRandomCreate_Random123() argument
189 r->data = r123; in PetscRandomCreate_Random123()
190 r->ops[0] = PetscRandomOps_Values; in PetscRandomCreate_Random123()
191 PetscCall(PetscObjectChangeTypeName((PetscObject)r, PETSCRANDOM123)); in PetscRandomCreate_Random123()
192 PetscCall(PetscRandomSeed(r)); in PetscRandomCreate_Random123()