xref: /linux/tools/testing/selftests/powerpc/math/fpu.h (revision 06d07429858317ded2db7986113a9e0129cd599b)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright 2023, Michael Ellerman, IBM Corporation.
4  */
5 
6 #ifndef _SELFTESTS_POWERPC_FPU_H
7 #define _SELFTESTS_POWERPC_FPU_H
8 
randomise_darray(double * darray,int num)9 static inline void randomise_darray(double *darray, int num)
10 {
11 	long val;
12 
13 	for (int i = 0; i < num; i++) {
14 		val = random();
15 		if (val & 1)
16 			val *= -1;
17 
18 		if (val & 2)
19 			darray[i] = 1.0 / val;
20 		else
21 			darray[i] = val * val;
22 	}
23 }
24 
25 #endif /* _SELFTESTS_POWERPC_FPU_H */
26