Skip to content

Commit 64023f5

Browse files
authored
Merge pull request #725 from ACSimon33/LAPACKE_xlangb
Implemented a LAPACKE_?langb interface
2 parents 83c7e0d + 15e62c3 commit 64023f5

File tree

10 files changed

+662
-0
lines changed

10 files changed

+662
-0
lines changed

LAPACKE/include/lapacke.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,19 @@ lapack_int LAPACKE_zlagge( int matrix_layout, lapack_int m, lapack_int n,
23132313
float LAPACKE_slamch( char cmach );
23142314
double LAPACKE_dlamch( char cmach );
23152315

2316+
float LAPACKE_slangb( int matrix_layout, char norm, lapack_int n,
2317+
lapack_int kl, lapack_int ku, const float* ab,
2318+
lapack_int ldab );
2319+
double LAPACKE_dlangb( int matrix_layout, char norm, lapack_int n,
2320+
lapack_int kl, lapack_int ku, const double* ab,
2321+
lapack_int ldab );
2322+
float LAPACKE_clangb( int matrix_layout, char norm, lapack_int n,
2323+
lapack_int kl, lapack_int ku,
2324+
const lapack_complex_float* ab, lapack_int ldab );
2325+
double LAPACKE_zlangb( int matrix_layout, char norm, lapack_int n,
2326+
lapack_int kl, lapack_int ku,
2327+
const lapack_complex_double* ab, lapack_int ldab );
2328+
23162329
float LAPACKE_slange( int matrix_layout, char norm, lapack_int m,
23172330
lapack_int n, const float* a, lapack_int lda );
23182331
double LAPACKE_dlange( int matrix_layout, char norm, lapack_int m,
@@ -7576,6 +7589,21 @@ double LAPACKE_dlapy3_work( double x, double y, double z );
75767589
float LAPACKE_slamch_work( char cmach );
75777590
double LAPACKE_dlamch_work( char cmach );
75787591

7592+
float LAPACKE_slangb_work( int matrix_layout, char norm, lapack_int n,
7593+
lapack_int kl, lapack_int ku, const float* ab,
7594+
lapack_int ldab, float* work );
7595+
double LAPACKE_dlangb_work( int matrix_layout, char norm, lapack_int n,
7596+
lapack_int kl, lapack_int ku, const double* ab,
7597+
lapack_int ldab, double* work );
7598+
float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n,
7599+
lapack_int kl, lapack_int ku,
7600+
const lapack_complex_float* ab, lapack_int ldab,
7601+
float* work );
7602+
double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n,
7603+
lapack_int kl, lapack_int ku,
7604+
const lapack_complex_double* ab, lapack_int ldab,
7605+
double* work );
7606+
75797607
float LAPACKE_slange_work( int matrix_layout, char norm, lapack_int m,
75807608
lapack_int n, const float* a, lapack_int lda,
75817609
float* work );

LAPACKE/src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ lapacke_clacrm.c
309309
lapacke_clacrm_work.c
310310
lapacke_clag2z.c
311311
lapacke_clag2z_work.c
312+
lapacke_clangb.c
313+
lapacke_clangb_work.c
312314
lapacke_clange.c
313315
lapacke_clange_work.c
314316
lapacke_clanhe.c
@@ -791,6 +793,8 @@ lapacke_dlag2s.c
791793
lapacke_dlag2s_work.c
792794
lapacke_dlamch.c
793795
lapacke_dlamch_work.c
796+
lapacke_dlangb.c
797+
lapacke_dlangb_work.c
794798
lapacke_dlange.c
795799
lapacke_dlange_work.c
796800
lapacke_dlansy.c
@@ -1366,6 +1370,8 @@ lapacke_slag2d.c
13661370
lapacke_slag2d_work.c
13671371
lapacke_slamch.c
13681372
lapacke_slamch_work.c
1373+
lapacke_slangb.c
1374+
lapacke_slangb_work.c
13691375
lapacke_slange.c
13701376
lapacke_slange_work.c
13711377
lapacke_slansy.c
@@ -2066,6 +2072,8 @@ lapacke_zlacrm.c
20662072
lapacke_zlacrm_work.c
20672073
lapacke_zlag2c.c
20682074
lapacke_zlag2c_work.c
2075+
lapacke_zlangb.c
2076+
lapacke_zlangb_work.c
20692077
lapacke_zlange.c
20702078
lapacke_zlange_work.c
20712079
lapacke_zlanhe.c

LAPACKE/src/lapacke_clangb.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 high-level C interface to LAPACK function clangb
30+
* Author: Simon Märtens
31+
*****************************************************************************/
32+
33+
#include "lapacke_utils.h"
34+
35+
float LAPACKE_clangb( int matrix_layout, char norm, lapack_int n,
36+
lapack_int kl, lapack_int ku,
37+
const lapack_complex_float* ab, lapack_int ldab )
38+
{
39+
lapack_int info = 0;
40+
float res = 0.;
41+
float* work = NULL;
42+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
43+
LAPACKE_xerbla( "LAPACKE_clangb", -1 );
44+
return -1;
45+
}
46+
#ifndef LAPACK_DISABLE_NAN_CHECK
47+
if( LAPACKE_get_nancheck() ) {
48+
/* Optionally check input matrices for NaNs */
49+
if( LAPACKE_cgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) {
50+
return -6;
51+
}
52+
}
53+
#endif
54+
/* Allocate memory for working array(s) */
55+
if( LAPACKE_lsame( norm, 'i' ) ) {
56+
work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) );
57+
if( work == NULL ) {
58+
info = LAPACK_WORK_MEMORY_ERROR;
59+
goto exit_level_0;
60+
}
61+
}
62+
/* Call middle-level interface */
63+
res = LAPACKE_clangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work );
64+
/* Release memory and exit */
65+
if( LAPACKE_lsame( norm, 'i' ) ) {
66+
LAPACKE_free( work );
67+
}
68+
exit_level_0:
69+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
70+
LAPACKE_xerbla( "LAPACKE_clangb", info );
71+
}
72+
return res;
73+
}

LAPACKE/src/lapacke_clangb_work.c

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 clangb
30+
* Author: Simon Märtens
31+
*****************************************************************************/
32+
33+
#include "lapacke_utils.h"
34+
35+
float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n,
36+
lapack_int kl, lapack_int ku,
37+
const lapack_complex_float* ab, lapack_int ldab,
38+
float* work )
39+
{
40+
lapack_int info = 0;
41+
float res = 0.;
42+
if( matrix_layout == LAPACK_COL_MAJOR ) {
43+
/* Call LAPACK function and adjust info */
44+
res = LAPACK_clangb( &norm, &n, &kl, &ku, ab, &ldab, work );
45+
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
46+
char norm_lapack;
47+
float* work_lapack = NULL;
48+
/* Check leading dimension(s) */
49+
if( ldab < kl+ku+1 ) {
50+
info = -7;
51+
LAPACKE_xerbla( "LAPACKE_clangb_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 = (float*)LAPACKE_malloc( sizeof(float) * 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_clangb( &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_clangb_work", info );
78+
}
79+
} else {
80+
info = -1;
81+
LAPACKE_xerbla( "LAPACKE_clangb_work", info );
82+
}
83+
return res;
84+
}

LAPACKE/src/lapacke_dlangb.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 high-level C interface to LAPACK function dlangb
30+
* Author: Simon Märtens
31+
*****************************************************************************/
32+
33+
#include "lapacke_utils.h"
34+
35+
double LAPACKE_dlangb( int matrix_layout, char norm, lapack_int n,
36+
lapack_int kl, lapack_int ku, const double* ab,
37+
lapack_int ldab )
38+
{
39+
lapack_int info = 0;
40+
double res = 0.;
41+
double* work = NULL;
42+
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
43+
LAPACKE_xerbla( "LAPACKE_dlangb", -1 );
44+
return -1;
45+
}
46+
#ifndef LAPACK_DISABLE_NAN_CHECK
47+
if( LAPACKE_get_nancheck() ) {
48+
/* Optionally check input matrices for NaNs */
49+
if( LAPACKE_dgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) {
50+
return -6;
51+
}
52+
}
53+
#endif
54+
/* Allocate memory for working array(s) */
55+
if( LAPACKE_lsame( norm, 'i' ) ) {
56+
work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) );
57+
if( work == NULL ) {
58+
info = LAPACK_WORK_MEMORY_ERROR;
59+
goto exit_level_0;
60+
}
61+
}
62+
/* Call middle-level interface */
63+
res = LAPACKE_dlangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work );
64+
/* Release memory and exit */
65+
if( LAPACKE_lsame( norm, 'i' ) ) {
66+
LAPACKE_free( work );
67+
}
68+
exit_level_0:
69+
if( info == LAPACK_WORK_MEMORY_ERROR ) {
70+
LAPACKE_xerbla( "LAPACKE_dlangb", info );
71+
}
72+
return res;
73+
}

LAPACKE/src/lapacke_dlangb_work.c

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

0 commit comments

Comments
 (0)