Skip to content

Commit 6c9dbe5

Browse files
authored
Add a LAPACKE interface for ?LANGB (Reference-LAPACK PR725)
1 parent 4f82699 commit 6c9dbe5

7 files changed

Lines changed: 542 additions & 0 deletions

File tree

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+
}
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+
}
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+
}
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+
}
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 slangb
30+
* Author: Simon Märtens
31+
*****************************************************************************/
32+
33+
#include "lapacke_utils.h"
34+
35+
float LAPACKE_slangb( int matrix_layout, char norm, lapack_int n,
36+
lapack_int kl, lapack_int ku, const float* ab,
37+
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_slangb", -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_sgb_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_slangb_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_slangb", info );
71+
}
72+
return res;
73+
}

0 commit comments

Comments
 (0)