PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
diag.c
Go to the documentation of this file.
1/**
2 *
3 * @file sopalin/diag.c
4 *
5 * PaStiX diagonal interface functions
6 *
7 * @copyright 2017-2025 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author Mathieu Faverge
12 * @author Pierre Ramet
13 * @author Xavier Lacoste
14 * @date 2024-07-05
15 *
16 * @addtogroup pastix_schur
17 * @{
18 *
19 **/
20#include "common.h"
21#include <spm.h>
22#include "blend/solver.h"
23#include "sopalin/coeftab_z.h"
24#include "sopalin/coeftab_c.h"
25#include "sopalin/coeftab_d.h"
26#include "sopalin/coeftab_s.h"
27
28/**
29 *******************************************************************************
30 *
31 * @brief Return the diagonal of the matrix.
32 *
33 * The diagonal is returned in the D vector such that D[incD *i] = A(i, i)
34 *
35 *******************************************************************************
36 *
37 * @param[in] pastix_data
38 * The pastix data structure of the problem solved.
39 *
40 * @param[inout] D
41 * The pointer to the allocated vector array that will store the diagonal.
42 * D must be of size spm->nexp * incD.
43 *
44 * @param[in] incD
45 * The leading dimension of the D array.
46 *
47 ********************************************************************************
48 *
49 * @retval PASTIX_SUCCESS on successful exit,
50 * @retval PASTIX_ERR_BADPARAMETER if one parameter is incorrect.
51 *
52 *******************************************************************************/
53int
54pastixGetDiag( const pastix_data_t *pastix_data,
55 void *D,
56 pastix_int_t incD )
57{
58 pastix_int_t *iparm;
59
60 /*
61 * Check parameters
62 */
63 if (pastix_data == NULL) {
64 pastix_print_error( "pastix_getDiag: wrong pastix_data parameter" );
66 }
67 if (D == NULL) {
68 pastix_print_error( "pastix_getDiag: D parameter" );
70 }
71 if (incD <= 0) {
72 pastix_print_error( "pastix_getDiag: incD parameter" );
74 }
75 if ( !(pastix_data->steps & STEP_NUMFACT) ) {
76 pastix_print_error( "pastix_getDiag: All steps from pastix_task_init() to pastix_task_numfact() have to be called before calling this function" );
78 }
79
80 iparm = pastix_data->iparm;
81 switch(iparm[IPARM_FLOAT])
82 {
83 case PastixPattern:
84 break;
85 case PastixFloat:
86 coeftab_sgetdiag( pastix_data->solvmatr, D, incD );
87 break;
88 case PastixComplex32:
89 coeftab_cgetdiag( pastix_data->solvmatr, D, incD );
90 break;
91 case PastixComplex64:
92 coeftab_zgetdiag( pastix_data->solvmatr, D, incD );
93 break;
94 case PastixDouble:
95 default:
96 coeftab_dgetdiag( pastix_data->solvmatr, D, incD );
97 }
98 return PASTIX_SUCCESS;
99}
100
101/**
102 * @}
103 */
104
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
void coeftab_sgetdiag(const SolverMatrix *solvmtx, float *D, pastix_int_t incD)
Extract the diagonal.
Definition coeftab_s.c:677
void coeftab_cgetdiag(const SolverMatrix *solvmtx, pastix_complex32_t *D, pastix_int_t incD)
Extract the diagonal.
Definition coeftab_c.c:677
void coeftab_dgetdiag(const SolverMatrix *solvmtx, double *D, pastix_int_t incD)
Extract the diagonal.
Definition coeftab_d.c:677
void coeftab_zgetdiag(const SolverMatrix *solvmtx, pastix_complex64_t *D, pastix_int_t incD)
Extract the diagonal.
Definition coeftab_z.c:677
@ IPARM_FLOAT
Definition api.h:149
@ PASTIX_SUCCESS
Definition api.h:367
@ PASTIX_ERR_BADPARAMETER
Definition api.h:374
int pastixGetDiag(const pastix_data_t *pastix_data, void *D, pastix_int_t incD)
Return the diagonal of the matrix.
Definition diag.c:54
SolverMatrix * solvmatr
Definition pastixdata.h:103
pastix_int_t * iparm
Definition pastixdata.h:70
pastix_int_t steps
Definition pastixdata.h:73
Main PaStiX data structure.
Definition pastixdata.h:68