SpM Handbook 1.2.4
Loading...
Searching...
No Matches
d_spm_convert_to_csr.c
Go to the documentation of this file.
1/**
2 *
3 * @file d_spm_convert_to_csr.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-05-29
15 *
16 * @generated from /builds/2mk6rsew/0/fpruvost/spm/src/z_spm_convert_to_csr.c, normal z -> d, Fri Nov 29 11:34:29 2024
17 *
18 **/
19#include "common.h"
20
21/**
22 *******************************************************************************
23 *
24 * @ingroup spm_dev_convert
25 *
26 * @brief convert a matrix in IJV format to a matrix in CSR
27 * format.
28 *
29 *******************************************************************************
30 *
31 * @param[inout] spm
32 * The ijv matrix at enter,
33 * the csr matrix at exit.
34 *
35 *******************************************************************************
36 *
37 * @retval SPM_SUCCESS on success
38 * @retval SPM_ERR_NOTIMPLEMENTED on non supported cases
39 *
40 *******************************************************************************/
41int
43{
44 spm_int_t *tmp;
45 spm_int_t result;
46
47 /* Transpose the spm in IJV to trans(spm) */
48 tmp = spm->rowptr;
49 spm->rowptr = spm->colptr;
50 spm->colptr = tmp;
51
52 /* Convert trans(spm) in IJV to trans(spm) in CSC */
53 result = d_spmConvertIJV2CSC( spm );
54
55 /* Transpose trans(spm) in CSC to obtain the spm in CSR */
56 tmp = spm->rowptr;
57 spm->rowptr = spm->colptr;
58 spm->colptr = tmp;
59 spm->fmttype = SpmCSR;
60
61 return result;
62}
63
64/**
65 *******************************************************************************
66 *
67 * @ingroup spm_dev_convert
68 *
69 * @brief convert a matrix in CSC format to a matrix in CSR format.
70 *
71 * If the matrix is SpmSymmetric or SpmSymmetric, then the
72 * transpose or respectively the conjugate is returned.
73 *
74 *******************************************************************************
75 *
76 * @param[inout] spm
77 * The csc matrix at enter,
78 * the csr matrix at exit.
79 *
80 *******************************************************************************
81 *
82 * @retval SPM_SUCCESS
83 *
84 *******************************************************************************/
85int
87{
88 spm_int_t *tmp;
89 spm_int_t result;
90
91 /* Transpose the spm in CSC to trans(spm) in CSR */
92 tmp = spm->rowptr;
93 spm->rowptr = spm->colptr;
94 spm->colptr = tmp;
95 spm->fmttype = SpmCSR;
96
97 /* Convert trans(spm) in CSR to trans(spm) in CSC */
98 result = d_spmConvertCSR2CSC( spm );
99
100 /* Transpose trans(spm) in CSC to obtain the spm in CSR */
101 tmp = spm->rowptr;
102 spm->rowptr = spm->colptr;
103 spm->colptr = tmp;
104 spm->fmttype = SpmCSR;
105
106 return result;
107}
@ SpmCSR
Definition const.h:74
int d_spmConvertIJV2CSC(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSC format.
int d_spmConvertCSR2CSC(spmatrix_t *spm)
convert a matrix in CSR format to a matrix in CSC format.
int d_spmConvertCSC2CSR(spmatrix_t *spm)
convert a matrix in CSC format to a matrix in CSR format.
int d_spmConvertIJV2CSR(spmatrix_t *spm)
convert a matrix in IJV format to a matrix in CSR format.
spm_int_t * rowptr
Definition spm.h:90
spm_fmttype_t fmttype
Definition spm.h:69
spm_int_t * colptr
Definition spm.h:89
int spm_int_t
The main integer datatype used in spm arrays.
Definition datatypes.h:70
The sparse matrix data structure.
Definition spm.h:64