LAPACK 3.11.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
lapacke_ztz_nancheck.c
Go to the documentation of this file.
1/*****************************************************************************
2 Copyright (c) 2022, Intel Corp.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 THE POSSIBILITY OF SUCH DAMAGE.
28******************************************************************************
29* Contents: Native C interface to LAPACK utility function
30* Author: Simon Märtens
31*****************************************************************************/
32
33#include "lapacke_utils.h"
34
35/*****************************************************************************
36 Check a trapezoidal matrix for NaN entries. The shape of the trapezoidal
37 matrix is determined by the arguments `direct` and `uplo`. `Direct` chooses
38 the diagonal which shall be considered and `uplo` tells us whether we use the
39 upper or lower part of the matrix with respect to the chosen diagonal.
40
41 Diagonals 'F' (front / forward) and 'B' (back / backward):
42
43 A = ( F ) A = ( F B )
44 ( F ) ( F B )
45 ( B F ) ( F B )
46 ( B )
47 ( B )
48
49 direct = 'F', uplo = 'L':
50
51 A = ( * ) A = ( * )
52 ( * * ) ( * * )
53 ( * * * ) ( * * * )
54 ( * * * )
55 ( * * * )
56
57 direct = 'F', uplo = 'U':
58
59 A = ( * * * ) A = ( * * * * * )
60 ( * * ) ( * * * * )
61 ( * ) ( * * * )
62 ( )
63 ( )
64
65 direct = 'B', uplo = 'L':
66
67 A = ( ) A = ( * * * )
68 ( ) ( * * * * )
69 ( * ) ( * * * * * )
70 ( * * )
71 ( * * * )
72
73 direct = 'B', uplo = 'U':
74
75 A = ( * * * ) A = ( * * * )
76 ( * * * ) ( * * )
77 ( * * * ) ( * )
78 ( * * )
79 ( * )
80
81*****************************************************************************/
82
83lapack_logical LAPACKE_ztz_nancheck( int matrix_layout, char direct, char uplo,
84 char diag, lapack_int m, lapack_int n,
85 const lapack_complex_double *a,
86 lapack_int lda )
87{
88 lapack_logical colmaj, front, lower, unit;
89
90 if( a == NULL ) return (lapack_logical) 0;
91
92 colmaj = ( matrix_layout == LAPACK_COL_MAJOR );
93 front = LAPACKE_lsame( direct, 'f' );
94 lower = LAPACKE_lsame( uplo, 'l' );
95 unit = LAPACKE_lsame( diag, 'u' );
96
97 if( ( !colmaj && ( matrix_layout != LAPACK_ROW_MAJOR ) ) ||
98 ( !front && !LAPACKE_lsame( direct, 'b' ) ) ||
99 ( !lower && !LAPACKE_lsame( uplo, 'u' ) ) ||
100 ( !unit && !LAPACKE_lsame( diag, 'n' ) ) ) {
101 /* Just exit if any of input parameters are wrong */
102 return (lapack_logical) 0;
103 }
104
105 /* Initial offsets and sizes of triangular and rectangular parts */
106 lapack_int tri_offset = 0;
107 lapack_int tri_n = MIN(m,n);
108 lapack_int rect_offset = -1;
109 lapack_int rect_m = ( m > n ) ? m - n : m;
110 lapack_int rect_n = ( n > m ) ? n - m : n;
111
112 /* Fix offsets depending on the shape of the matrix */
113 if( front ) {
114 if( lower && m > n ) {
115 rect_offset = tri_n * ( !colmaj ? lda : 1 );
116 } else if( !lower && n > m ) {
117 rect_offset = tri_n * ( colmaj ? lda : 1 );
118 }
119 } else {
120 if( m > n ) {
121 tri_offset = rect_m * ( !colmaj ? lda : 1 );
122 if( !lower ) {
123 rect_offset = 0;
124 }
125 } else if( n > m ) {
126 tri_offset = rect_n * ( colmaj ? lda : 1 );
127 if( lower ) {
128 rect_offset = 0;
129 }
130 }
131 }
132
133 /* Check rectangular part */
134 if( rect_offset >= 0 ) {
135 if( LAPACKE_zge_nancheck( matrix_layout, rect_m, rect_n,
136 &a[rect_offset], lda) ) {
137 return (lapack_logical) 1;
138 }
139 }
140
141 /* Check triangular part */
142 return LAPACKE_ztr_nancheck( matrix_layout, uplo, diag, tri_n,
143 &a[tri_offset], lda );
144}
#define lapack_int
Definition: lapack.h:87
#define lapack_complex_double
Definition: lapack.h:64
#define lapack_logical
Definition: lapack.h:103
#define LAPACK_COL_MAJOR
Definition: lapacke.h:53
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:52
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:35
lapack_logical LAPACKE_zge_nancheck(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *a, lapack_int lda)
lapack_logical LAPACKE_ztr_nancheck(int matrix_layout, char uplo, char diag, lapack_int n, const lapack_complex_double *a, lapack_int lda)
#define MIN(x, y)
Definition: lapacke_utils.h:49
lapack_logical LAPACKE_ztz_nancheck(int matrix_layout, char direct, char uplo, char diag, lapack_int m, lapack_int n, const lapack_complex_double *a, lapack_int lda)