PaStiX Handbook  6.4.0
core_splrnt.c
Go to the documentation of this file.
1 /**
2  *
3  * @file core_splrnt.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-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
10  * Univ. Bordeaux. All rights reserved.
11  *
12  * @version 6.4.0
13  * @author Piotr Luszczek
14  * @author Pierre Lemarinier
15  * @author Mathieu Faverge
16  * @author Gregoire Pichon
17  * @date 2024-07-05
18  * @generated from /builds/solverstack/pastix/kernels/core_zplrnt.c, normal z -> s, Tue Oct 8 14:17:22 2024
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_splrnt( int m,
92  int n,
93  float *A,
94  int lda,
95  int gM,
96  int m0,
97  int n0,
98  unsigned long long int seed )
99 {
100  float *tmp = A;
101  int64_t i, j;
102  unsigned long long int ran, jump;
103 
104  jump = (unsigned long long int)m0 + (unsigned long long int)n0 * (unsigned long long int)gM;
105 
106  for (j=0; j<n; ++j ) {
107  ran = Rnd64_jump( NBELEM*jump, seed );
108  for (i = 0; i < m; ++i) {
109  *tmp = 0.5f - ran * RndF_Mul;
110  ran = Rnd64_A * ran + Rnd64_C;
111 #if defined(PRECISION_z) || defined(PRECISION_c)
112  *tmp += I*(0.5f - ran * RndF_Mul);
113  ran = Rnd64_A * ran + Rnd64_C;
114 #endif
115  tmp++;
116  }
117  tmp += lda-i;
118  jump += gM;
119  }
120 }
void core_splrnt(int m, int n, float *A, int lda, int gM, int m0, int n0, unsigned long long int seed)
Generate a random tile.
Definition: core_splrnt.c:91