SpM Handbook
1.2.4
Loading...
Searching...
No Matches
z_spm_convert_to_ijv.c
Go to the documentation of this file.
1
/**
2
*
3
* @file z_spm_convert_to_ijv.c
4
*
5
* SParse Matrix package conversion 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 Matias Hastaran
13
* @author Tony Delarue
14
* @date 2024-06-25
15
*
16
* @generated from /builds/2mk6rsew/0/fpruvost/spm/src/z_spm_convert_to_ijv.c, normal z -> z, Fri Nov 29 11:34:31 2024
17
**/
18
#include "common.h"
19
20
/**
21
*******************************************************************************
22
*
23
* @ingroup spm_dev_convert
24
*
25
* @brief Convert a matrix in CSC format to a matrix in IJV format.
26
*
27
*******************************************************************************
28
*
29
* @param[inout] spm
30
* The csc matrix at enter,
31
* the ijv matrix at exit.
32
*
33
*******************************************************************************
34
*
35
* @retval SPM_SUCCESS
36
*
37
*******************************************************************************/
38
int
39
z_spmConvertCSC2IJV
(
spmatrix_t
*spm )
40
{
41
const
spm_int_t
*colcscptr, *colcsc;
42
spm_int_t
*colijvptr, *colijv;
43
spm_int_t
i, j, nnz;
44
45
nnz = spm->
nnz
;
46
47
colijvptr = malloc( nnz *
sizeof
(
spm_int_t
) );
48
colijv = colijvptr;
49
assert( colijvptr );
50
51
colcscptr = spm->
colptr
;
52
colcsc = colcscptr;
53
54
if
( !spm->
replicated
) {
55
const
spm_int_t
*loc2glob = spm->
loc2glob
;
56
spm_int_t
ig;
57
58
for
(i=0; i<spm->
n
; i++, colcsc++, loc2glob++)
59
{
60
ig = *loc2glob;
61
for
(j=colcsc[0]; j<colcsc[1]; j++)
62
{
63
*colijv = ig;
64
colijv++;
65
}
66
}
67
}
68
else
{
69
spm_int_t
baseval = spm->
baseval
;
70
spm_int_t
n = spm->
n
+ baseval;
71
72
for
(i=baseval; i<n; i++, colcsc++)
73
{
74
for
(j=colcsc[0]; j<colcsc[1]; j++)
75
{
76
*colijv = i;
77
colijv++;
78
}
79
}
80
}
81
82
free( (
spm_int_t
*)colcscptr );
83
spm->
colptr
= colijvptr;
84
spm->
fmttype
=
SpmIJV
;
85
86
return
SPM_SUCCESS
;
87
}
88
89
/**
90
*******************************************************************************
91
*
92
* @ingroup spm_dev_convert
93
*
94
* @brief convert a matrix in CSR format to a matrix in IJV format.
95
*
96
*******************************************************************************
97
*
98
* @param[inout] spm
99
* The csr matrix at enter,
100
* the ijv matrix at exit.
101
*
102
*******************************************************************************
103
*
104
* @retval SPM_SUCCESS
105
*
106
*******************************************************************************/
107
int
108
z_spmConvertCSR2IJV
(
spmatrix_t
*spm )
109
{
110
const
spm_int_t
*rowcscptr, *rowcsc;
111
spm_int_t
*rowijvptr, *rowijv;
112
spm_int_t
i, j, nnz;
113
114
nnz = spm->
nnz
;
115
116
rowijvptr = malloc( nnz *
sizeof
(
spm_int_t
) );
117
rowijv = rowijvptr;
118
assert( rowijvptr );
119
120
rowcscptr = spm->
rowptr
;
121
rowcsc = rowcscptr;
122
123
if
( !spm->
replicated
) {
124
const
spm_int_t
*loc2glob = spm->
loc2glob
;
125
spm_int_t
jg;
126
127
for
(j=0; j<spm->
n
; j++, rowcsc++, loc2glob++)
128
{
129
jg = *loc2glob;
130
for
(i=rowcsc[0]; i<rowcsc[1]; i++)
131
{
132
*rowijv = jg;
133
rowijv++;
134
}
135
}
136
}
137
else
{
138
spm_int_t
baseval = spm->
baseval
;
139
spm_int_t
n = spm->
n
+ baseval;
140
141
for
(j=baseval; j<n; j++, rowcsc++)
142
{
143
for
(i=rowcsc[0]; i<rowcsc[1]; i++)
144
{
145
*rowijv = j;
146
rowijv++;
147
}
148
}
149
}
150
151
free( (
spm_int_t
*)rowcscptr );
152
spm->
rowptr
= rowijvptr;
153
spm->
fmttype
=
SpmIJV
;
154
155
return
SPM_SUCCESS
;
156
}
SPM_SUCCESS
@ SPM_SUCCESS
Definition
const.h:82
SpmIJV
@ SpmIJV
Definition
const.h:75
z_spmConvertCSR2IJV
int z_spmConvertCSR2IJV(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in IJV format.
Definition
z_spm_convert_to_ijv.c:108
z_spmConvertCSC2IJV
int z_spmConvertCSC2IJV(spmatrix_t *spm)
Convert a matrix in CSC format to a matrix in IJV format.
Definition
z_spm_convert_to_ijv.c:39
spmatrix_s::nnz
spm_int_t nnz
Definition
spm.h:75
spmatrix_s::rowptr
spm_int_t * rowptr
Definition
spm.h:90
spmatrix_s::fmttype
spm_fmttype_t fmttype
Definition
spm.h:69
spmatrix_s::n
spm_int_t n
Definition
spm.h:73
spmatrix_s::loc2glob
spm_int_t * loc2glob
Definition
spm.h:91
spmatrix_s::baseval
spm_int_t baseval
Definition
spm.h:71
spmatrix_s::colptr
spm_int_t * colptr
Definition
spm.h:89
spmatrix_s::replicated
int replicated
Definition
spm.h:98
spm_int_t
int spm_int_t
The main integer datatype used in spm arrays.
Definition
datatypes.h:70
spmatrix_s
The sparse matrix data structure.
Definition
spm.h:64
build
src
z_spm_convert_to_ijv.c
Generated by
1.9.8