SpM Handbook
1.2.4
Loading...
Searching...
No Matches
z_spm_integer.c
Go to the documentation of this file.
1
/**
2
*
3
* @file z_spm_integer.c
4
*
5
* SParse Matrix package integer sorting routines.
6
*
7
* @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8
* Univ. Bordeaux. All rights reserved.
9
*
10
* @version 1.2.4
11
* @author Mathieu Faverge
12
* @author Pierre Ramet
13
* @author Tony Delarue
14
* @author Alycia Lisito
15
* @date 2024-05-29
16
*
17
* @generated from /builds/2mk6rsew/0/fpruvost/spm/src/z_spm_integer.c, normal z -> z, Fri Nov 29 11:34:31 2024
18
*
19
**/
20
#include "common.h"
21
22
/**
23
*******************************************************************************
24
*
25
* @fn void z_spmIntFltSortAsc(void ** const pbase, const spm_int_t n)
26
* @ingroup spm_dev_integer
27
* @brief Sort 2 arrays simultaneously, the first array is an array of
28
* spm_int_t and used as key for sorting. The second array is an array of
29
* spm_complex64_t.
30
*
31
*******************************************************************************
32
*
33
* @param[inout] pbase
34
* Couple of pointers to an array of integers and to an array of
35
* spm_complex64_t to sort.
36
*
37
* @param[in] n
38
* The number of elements in the array.
39
*
40
*******************************************************************************/
41
#ifndef DOXYGEN_SHOULD_SKIP_THIS
42
static
size_t
intsortsize_if[2] = {
sizeof
(
spm_int_t
),
sizeof
(spm_complex64_t) };
43
#define INTSORTNAME z_spmIntFltSortAsc
44
#define INTSORTSIZE(x) (intsortsize_if[x])
45
#define INTSORTNTAB 2
46
#define INTSORTSWAP(p,q) do { \
47
spm_int_t t; \
48
long disp_p = (((spm_int_t*)p)-((spm_int_t*)base_ptr)); \
49
long disp_q = (((spm_int_t*)q)-((spm_int_t*)base_ptr)); \
50
spm_complex64_t * floatptr = *(pbase+1); \
51
spm_complex64_t f; \
52
/* swap integers */
\
53
t = *((spm_int_t *) (p)); \
54
*((spm_int_t *) (p)) = *((spm_int_t *) (q)); \
55
*((spm_int_t *) (q)) = t; \
56
/* swap corresponding values */
\
57
f = floatptr[disp_p]; \
58
floatptr[disp_p] = floatptr[disp_q]; \
59
floatptr[disp_q] = f; \
60
} while (0)
61
#define INTSORTCMP(p,q) (*((spm_int_t *) (p)) < *((spm_int_t *) (q)))
62
#include "integer_sort_mtypes.c"
63
#undef INTSORTNAME
64
#undef INTSORTSIZE
65
#undef INTSORTSWAP
66
#undef INTSORTCMP
67
#undef INTSORTNTAB
68
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
69
70
/**
71
*******************************************************************************
72
*
73
* @fn void z_spmIntIntFltSortAsc(void ** const pbase, const spm_int_t n)
74
* @ingroup spm_dev_integer
75
* @brief Sort 2 arrays simultaneously, the first array is an array of
76
* spm_int_t and used as key for sorting. The second array is an array of
77
* spm_complex64_t.
78
*
79
*******************************************************************************
80
*
81
* @param[inout] pbase
82
* Couple of pointers to an array of integers and to an array of
83
* spm_complex64_t to sort.
84
*
85
* @param[in] n
86
* The number of elements in the array.
87
*
88
*******************************************************************************/
89
#ifndef DOXYGEN_SHOULD_SKIP_THIS
90
static
size_t
intsortsize_iif[3] = {
sizeof
(
spm_int_t
),
sizeof
(
spm_int_t
),
sizeof
(spm_complex64_t) };
91
#define INTSORTNAME z_spmIntIntFltSortAsc
92
#define INTSORTSIZE(x) (intsortsize_iif[x])
93
#define INTSORTNTAB 3
94
#define INTSORTSWAP(p,q) do { \
95
spm_int_t t; \
96
long disp_p = (((spm_int_t*)p)-((spm_int_t*)base_ptr)); \
97
long disp_q = (((spm_int_t*)q)-((spm_int_t*)base_ptr)); \
98
spm_int_t * intptr = *(pbase+1); \
99
spm_complex64_t * fltptr = *(pbase+2); \
100
spm_complex64_t f; \
101
/* swap integers */
\
102
t = *((spm_int_t *) (p)); \
103
*((spm_int_t *) (p)) = *((spm_int_t *) (q)); \
104
*((spm_int_t *) (q)) = t; \
105
/* swap on second integer array */
\
106
t = intptr[disp_p]; \
107
intptr[disp_p] = intptr[disp_q]; \
108
intptr[disp_q] = t; \
109
/* swap corresponding values */
\
110
f = fltptr[disp_p]; \
111
fltptr[disp_p] = fltptr[disp_q]; \
112
fltptr[disp_q] = f; \
113
} while (0)
114
115
/**
116
*******************************************************************************
117
*
118
* @brief TODO
119
*
120
*******************************************************************************
121
*
122
* @param[inout] pbase
123
* Couple of pointers to an array of integers and to an array of
124
* spm_complex64_t to sort.
125
*
126
* @param[in] p
127
* TODO
128
*
129
* @param[in] q
130
* TODO
131
*
132
*******************************************************************************
133
*
134
* @retval TODO
135
*
136
*******************************************************************************/
137
static
inline
int
138
intsortcmp_iif(
void
**
const
pbase,
139
spm_int_t
*p,
140
spm_int_t
*q )
141
{
142
spm_int_t
*int1ptr = pbase[0];
143
spm_int_t
*int2ptr = pbase[1];
144
return
( *p < *q ) || (( *p == *q ) && ( int2ptr[ p - int1ptr ] < int2ptr[ q - int1ptr ] ));
145
}
146
#define INTSORTCMP(p,q) intsortcmp_iif( pbase, (spm_int_t*)p, (spm_int_t*)q )
147
#include "integer_sort_mtypes.c"
148
#undef INTSORTNAME
149
#undef INTSORTSIZE
150
#undef INTSORTSWAP
151
#undef INTSORTCMP
152
#undef INTSORTNTAB
153
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
spm_int_t
int spm_int_t
The main integer datatype used in spm arrays.
Definition
datatypes.h:70
build
src
z_spm_integer.c
Generated by
1.9.8