PaStiX Handbook  6.2.1
core_zplrnt.c
Go to the documentation of this file.
1 /**
2  *
3  * @file core_zplrnt.c
4  *
5  * PaStiX kernel routines
6  *
7  * @copyright 2010-2015 Univ. of Tennessee, Univ. of California Berkeley and
8  * Univ. of Colorado Denver. All rights reserved.
9  * @copyright 2012-2021 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
10  * Univ. Bordeaux. All rights reserved.
11  *
12  * @version 6.1.0
13  * @author Piotr Luszczek
14  * @author Pierre Lemarinier
15  * @author Mathieu Faverge
16  * @author Gregoire Pichon
17  * @date 2019-11-12
18  * @generated from /builds/solverstack/pastix/kernels/core_zplrnt.c, normal z -> z, Tue Apr 12 09:38:35 2022
19  *
20  **/
21 #include "common.h"
22 
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 #define Rnd64_A 6364136223846793005ULL
25 #define Rnd64_C 1ULL
26 #define RndF_Mul 5.4210108624275222e-20f
27 #define RndD_Mul 5.4210108624275222e-20
28 
29 static inline unsigned long long int
30 Rnd64_jump(unsigned long long int n, unsigned long long int seed ) {
31  unsigned long long int a_k, c_k, ran;
32  int i;
33 
34  a_k = Rnd64_A;
35  c_k = Rnd64_C;
36 
37  ran = seed;
38  for (i = 0; n; n >>= 1, ++i) {
39  if (n & 1)
40  ran = a_k * ran + c_k;
41  c_k *= (a_k + 1);
42  a_k *= a_k;
43  }
44 
45  return ran;
46 }
47 
48 #if defined(PRECISION_z) || defined(PRECISION_c)
49 #define NBELEM 2
50 #else
51 #define NBELEM 1
52 #endif
53 
54 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
55 
56 /**
57  *******************************************************************************
58  *
59  * @brief Generate a random tile.
60  *
61  *******************************************************************************
62  *
63  * @param[in] m
64  * The number of rows of the tile A. m >= 0.
65  *
66  * @param[in] n
67  * The number of columns of the tile A. n >= 0.
68  *
69  * @param[inout] A
70  * On entry, the m-by-n tile to be initialized.
71  * On exit, the tile initialized in the mtxtype format.
72  *
73  * @param[in] lda
74  * The leading dimension of the tile A. lda >= max(1,m).
75  *
76  * @param[in] gM
77  * The global number of rows of the full matrix, A is belonging to. gM >= (m0+M).
78  *
79  * @param[in] m0
80  * The index of the first row of tile A in the full matrix. m0 >= 0.
81  *
82  * @param[in] n0
83  * The index of the first column of tile A in the full matrix. n0 >= 0.
84  *
85  * @param[in] seed
86  * The seed used for random generation. Must be the same for
87  * all tiles initialized with this routine.
88  *
89  ******************************************************************************/
90 void
91 core_zplrnt( int m, int n, pastix_complex64_t *A, int lda,
92  int gM, int m0, int n0, unsigned long long int seed )
93 {
94  pastix_complex64_t *tmp = A;
95  int64_t i, j;
96  unsigned long long int ran, jump;
97 
98  jump = (unsigned long long int)m0 + (unsigned long long int)n0 * (unsigned long long int)gM;
99 
100  for (j=0; j<n; ++j ) {
101  ran = Rnd64_jump( NBELEM*jump, seed );
102  for (i = 0; i < m; ++i) {
103  *tmp = 0.5f - ran * RndF_Mul;
104  ran = Rnd64_A * ran + Rnd64_C;
105 #if defined(PRECISION_z) || defined(PRECISION_c)
106  *tmp += I*(0.5f - ran * RndF_Mul);
107  ran = Rnd64_A * ran + Rnd64_C;
108 #endif
109  tmp++;
110  }
111  tmp += lda-i;
112  jump += gM;
113  }
114 }
core_zplrnt
void core_zplrnt(int m, int n, pastix_complex64_t *A, int lda, int gM, int m0, int n0, unsigned long long int seed)
Generate a random tile.
Definition: core_zplrnt.c:91