PaStiX Handbook  6.2.1
core_zlrnrm.c
Go to the documentation of this file.
1 /**
2  *
3  * @file core_zlrnrm.c
4  *
5  * PaStiX low-rank kernel to compute the norms of a low-rank block.
6  *
7  * @copyright 2016-2021 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.0.3
11  * @author Mathieu Faverge
12  * @date 2019-11-12
13  * @generated from /builds/solverstack/pastix/kernels/core_zlrnrm.c, normal z -> z, Tue Apr 12 09:38:37 2022
14  *
15  **/
16 #include "common.h"
17 #include <lapacke.h>
18 #include "pastix_zlrcores.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] A
31  * The low-rank matrix
32  *
33  *******************************************************************************
34  *
35  * @return The norm of the matrix A
36  *
37  *******************************************************************************/
38 double
39 core_zlrnrm( pastix_normtype_t ntype, int transV,
40  pastix_int_t M, pastix_int_t N,
41  const pastix_lrblock_t *A )
42 {
43  if ( ntype != PastixFrobeniusNorm ) {
44  fprintf( stderr, "core_zlrnrm: Only the Frobenius norm is available for now\n");
45  ntype = PastixFrobeniusNorm;
46  }
47 
48  if ( A->rk == -1 ) {
49  assert( transV == PastixNoTrans );
50  return LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'f',
51  M, N, A->u, M, NULL );
52  }
53  else if ( A->rk == 0 ) {
54  return 0.;
55  }
56  else {
57  double normU, normV;
58 
59  normU = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'f',
60  M, A->rk, A->u, M, NULL );
61  if ( transV == PastixNoTrans ) {
62  normV = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'f',
63  A->rk, N, A->v, A->rkmax, NULL );
64  }
65  else {
66  normV = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'f',
67  N, A->rk, A->v, N, NULL );
68  }
69  /* This is an over-estimation of the norm as with frobenius ||UV|| <= ||U|| * ||V|| */
70  return normU * normV;
71  }
72 }
PastixFrobeniusNorm
@ PastixFrobeniusNorm
Definition: api.h:482
pastix_lrblock_s
The block low-rank structure to hold a matrix in low-rank form.
Definition: pastix_lowrank.h:112
PastixNoTrans
@ PastixNoTrans
Definition: api.h:424
core_zlrnrm
double core_zlrnrm(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_zlrnrm.c:39
pastix_zlrcores.h
pastix_normtype_t
enum pastix_normtype_e pastix_normtype_t
Norms.