PaStiX Handbook  6.4.0
core_dlrnrm.c
Go to the documentation of this file.
1 /**
2  *
3  * @file core_dlrnrm.c
4  *
5  * PaStiX low-rank kernel to compute the norms of a low-rank block.
6  *
7  * @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.4.0
11  * @author Mathieu Faverge
12  * @date 2024-07-05
13  * @generated from /builds/solverstack/pastix/kernels/core_zlrnrm.c, normal z -> d, Tue Oct 8 14:17:20 2024
14  *
15  **/
16 #include "common.h"
17 #include <lapacke.h>
18 #include "pastix_dlrcores.h"
19 
20 /**
21  *******************************************************************************
22  *
23  * @brief Compute the norm of a low-rank matrix.
24  *
25  *******************************************************************************
26  *
27  * @param[in] ntype
28  * The matrix norm to compute.
29  *
30  * @param[in] transV
31  * TODO
32  *
33  * @param[in] M
34  * TODO
35  *
36  * @param[in] N
37  * TODO
38  *
39  * @param[in] A
40  * The low-rank matrix
41  *
42  *******************************************************************************
43  *
44  * @return The norm of the matrix A
45  *
46  *******************************************************************************/
47 double
49  int transV,
50  pastix_int_t M,
51  pastix_int_t N,
52  const pastix_lrblock_t *A )
53 {
54  if ( ntype != PastixFrobeniusNorm ) {
55  fprintf( stderr, "core_dlrnrm: Only the Frobenius norm is available for now\n");
56  ntype = PastixFrobeniusNorm;
57  }
58 
59  if ( A->rk == -1 ) {
60  assert( transV == PastixNoTrans );
61  return LAPACKE_dlange_work( LAPACK_COL_MAJOR, 'f',
62  M, N, A->u, M, NULL );
63  }
64  else if ( A->rk == 0 ) {
65  return 0.;
66  }
67  else {
68  double normU, normV;
69 
70  normU = LAPACKE_dlange_work( LAPACK_COL_MAJOR, 'f',
71  M, A->rk, A->u, M, NULL );
72  if ( transV == PastixNoTrans ) {
73  normV = LAPACKE_dlange_work( LAPACK_COL_MAJOR, 'f',
74  A->rk, N, A->v, A->rkmax, NULL );
75  }
76  else {
77  normV = LAPACKE_dlange_work( LAPACK_COL_MAJOR, 'f',
78  N, A->rk, A->v, N, NULL );
79  }
80  /* This is an over-estimation of the norm as with frobenius ||UV|| <= ||U|| * ||V|| */
81  return normU * normV;
82  }
83 }
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
The block low-rank structure to hold a matrix in low-rank form.
double core_dlrnrm(pastix_normtype_t ntype, int transV, pastix_int_t M, pastix_int_t N, const pastix_lrblock_t *A)
Compute the norm of a low-rank matrix.
Definition: core_dlrnrm.c:48
enum pastix_normtype_e pastix_normtype_t
Norms.
@ PastixFrobeniusNorm
Definition: api.h:504
@ PastixNoTrans
Definition: api.h:445