Skip to content

Commit 9fe75af

Browse files
authored
Add a LAPACKE interface for ?LANGB (Reference-LAPACK PR725)
1 parent 48c9c6e commit 9fe75af

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 middle-level C interface to LAPACK function zlangb
30+
* Author: Simon Märtens
31+
*****************************************************************************/
32+
33+
#include "lapacke_utils.h"
34+
35+
double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n,
36+
lapack_int kl, lapack_int ku,
37+
const lapack_complex_double* ab, lapack_int ldab,
38+
double* work )
39+
{
40+
lapack_int info = 0;
41+
double res = 0.;
42+
if( matrix_layout == LAPACK_COL_MAJOR ) {
43+
/* Call LAPACK function and adjust info */
44+
res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab, &ldab, work );
45+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
46+
char norm_lapack;
47+
double* work_lapack = NULL;
48+
/* Check leading dimension(s) */
49+
if( ldab < kl+ku+1 ) {
50+
info = -7;
51+
LAPACKE_xerbla( "LAPACKE_zlangb_work", info );
52+
return info;
53+
}
54+
if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) {
55+
norm_lapack = 'i';
56+
} else if( LAPACKE_lsame( norm, 'i' ) ) {
57+
norm_lapack = '1';
58+
} else {
59+
norm_lapack = norm;
60+
}
61+
/* Allocate memory for work array(s) */
62+
if( LAPACKE_lsame( norm_lapack, 'i' ) ) {
63+
work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) );
64+
if( work_lapack == NULL ) {
65+
info = LAPACK_WORK_MEMORY_ERROR;
66+
goto exit_level_0;
67+
}
68+
}
69+
/* Call LAPACK function */
70+
res = LAPACK_zlangb( &norm, &n, &ku, &kl, ab, &ldab, work );
71+
/* Release memory and exit */
72+
if( work_lapack ) {
73+
LAPACKE_free( work_lapack );
74+
}
75+
exit_level_0:
76+
if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
77+
LAPACKE_xerbla( "LAPACKE_zlangb_work", info );
78+
}
79+
} else {
80+
info = -1;
81+
LAPACKE_xerbla( "LAPACKE_zlangb_work", info );
82+
}
83+
return res;
84+
}

0 commit comments

Comments
 (0)