From 1de378bbb93787f8cba03a1b03ba67fea4c418a3 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Oct 2022 18:00:40 +0100 Subject: [PATCH 1/5] Added LAPACKE_?langb interfaces. --- LAPACKE/include/lapacke.h | 28 +++++++++++ LAPACKE/src/CMakeLists.txt | 8 ++++ LAPACKE/src/lapacke_clangb.c | 73 +++++++++++++++++++++++++++++ LAPACKE/src/lapacke_clangb_work.c | 77 +++++++++++++++++++++++++++++++ LAPACKE/src/lapacke_dlangb.c | 73 +++++++++++++++++++++++++++++ LAPACKE/src/lapacke_dlangb_work.c | 75 ++++++++++++++++++++++++++++++ LAPACKE/src/lapacke_slangb.c | 73 +++++++++++++++++++++++++++++ LAPACKE/src/lapacke_slangb_work.c | 75 ++++++++++++++++++++++++++++++ LAPACKE/src/lapacke_zlangb.c | 73 +++++++++++++++++++++++++++++ LAPACKE/src/lapacke_zlangb_work.c | 77 +++++++++++++++++++++++++++++++ 10 files changed, 632 insertions(+) create mode 100644 LAPACKE/src/lapacke_clangb.c create mode 100644 LAPACKE/src/lapacke_clangb_work.c create mode 100644 LAPACKE/src/lapacke_dlangb.c create mode 100644 LAPACKE/src/lapacke_dlangb_work.c create mode 100644 LAPACKE/src/lapacke_slangb.c create mode 100644 LAPACKE/src/lapacke_slangb_work.c create mode 100644 LAPACKE/src/lapacke_zlangb.c create mode 100644 LAPACKE/src/lapacke_zlangb_work.c diff --git a/LAPACKE/include/lapacke.h b/LAPACKE/include/lapacke.h index f6fbfcc33b..5e0a73ef28 100644 --- a/LAPACKE/include/lapacke.h +++ b/LAPACKE/include/lapacke.h @@ -2313,6 +2313,19 @@ lapack_int LAPACKE_zlagge( int matrix_layout, lapack_int m, lapack_int n, float LAPACKE_slamch( char cmach ); double LAPACKE_dlamch( char cmach ); +float LAPACKE_slangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const float* ab, + lapack_int ldab ); +double LAPACKE_dlangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const double* ab, + lapack_int ldab ); +float LAPACKE_clangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_float* ab, lapack_int ldab ); +double LAPACKE_zlangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_double* ab, lapack_int ldab ); + float LAPACKE_slange( int matrix_layout, char norm, lapack_int m, lapack_int n, const float* a, lapack_int lda ); 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 ); float LAPACKE_slamch_work( char cmach ); double LAPACKE_dlamch_work( char cmach ); +float LAPACKE_slangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const float* ab, + lapack_int ldab, float* work ); +double LAPACKE_dlangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const double* ab, + lapack_int ldab, double* work ); +float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_float* ab, lapack_int ldab, + float* work ); +double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_double* ab, lapack_int ldab, + double* work ); + float LAPACKE_slange_work( int matrix_layout, char norm, lapack_int m, lapack_int n, const float* a, lapack_int lda, float* work ); diff --git a/LAPACKE/src/CMakeLists.txt b/LAPACKE/src/CMakeLists.txt index 4171a3bd42..062aeb06ab 100644 --- a/LAPACKE/src/CMakeLists.txt +++ b/LAPACKE/src/CMakeLists.txt @@ -309,6 +309,8 @@ lapacke_clacrm.c lapacke_clacrm_work.c lapacke_clag2z.c lapacke_clag2z_work.c +lapacke_clangb.c +lapacke_clangb_work.c lapacke_clange.c lapacke_clange_work.c lapacke_clanhe.c @@ -791,6 +793,8 @@ lapacke_dlag2s.c lapacke_dlag2s_work.c lapacke_dlamch.c lapacke_dlamch_work.c +lapacke_dlangb.c +lapacke_dlangb_work.c lapacke_dlange.c lapacke_dlange_work.c lapacke_dlansy.c @@ -1366,6 +1370,8 @@ lapacke_slag2d.c lapacke_slag2d_work.c lapacke_slamch.c lapacke_slamch_work.c +lapacke_slangb.c +lapacke_slangb_work.c lapacke_slange.c lapacke_slange_work.c lapacke_slansy.c @@ -2066,6 +2072,8 @@ lapacke_zlacrm.c lapacke_zlacrm_work.c lapacke_zlag2c.c lapacke_zlag2c_work.c +lapacke_zlangb.c +lapacke_zlangb_work.c lapacke_zlange.c lapacke_zlange_work.c lapacke_zlanhe.c diff --git a/LAPACKE/src/lapacke_clangb.c b/LAPACKE/src/lapacke_clangb.c new file mode 100644 index 0000000000..f4e0ab8900 --- /dev/null +++ b/LAPACKE/src/lapacke_clangb.c @@ -0,0 +1,73 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native high-level C interface to LAPACK function clangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +float LAPACKE_clangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_float* ab, lapack_int ldab ) +{ + lapack_int info = 0; + float res = 0.; + float* work = NULL; + if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { + LAPACKE_xerbla( "LAPACKE_clangb", -1 ); + return -1; + } +#ifndef LAPACK_DISABLE_NAN_CHECK + if( LAPACKE_get_nancheck() ) { + /* Optionally check input matrices for NaNs */ + if( LAPACKE_cgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) { + return -6; + } + } +#endif + /* Allocate memory for working array(s) */ + if( LAPACKE_lsame( norm, 'i' ) ) { + work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); + if( work == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call middle-level interface */ + res = LAPACKE_clangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work ); + /* Release memory and exit */ + if( LAPACKE_lsame( norm, 'i' ) ) { + LAPACKE_free( work ); + } +exit_level_0: + if( info == LAPACK_WORK_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_clangb", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_clangb_work.c b/LAPACKE/src/lapacke_clangb_work.c new file mode 100644 index 0000000000..3d8a6447e7 --- /dev/null +++ b/LAPACKE/src/lapacke_clangb_work.c @@ -0,0 +1,77 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native middle-level C interface to LAPACK function clangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_float* ab, lapack_int ldab, + float* work ) +{ + lapack_int info = 0; + float res = 0.; + if( matrix_layout == LAPACK_COL_MAJOR ) { + /* Call LAPACK function and adjust info */ + res = LAPACK_clangb( &norm, &n, &kl, &ku, ab, &ldab, work ); + } else if( matrix_layout == LAPACK_ROW_MAJOR ) { + lapack_int ldab_t = MAX(1,kl+ku+1); + lapack_complex_float* ab_t = NULL; + /* Check leading dimension(s) */ + if( ldab < kl+ku+1 ) { + info = -7; + LAPACKE_xerbla( "LAPACKE_clangb_work", info ); + return info; + } + /* Allocate memory for temporary array(s) */ + ab_t = (lapack_complex_float*) + LAPACKE_malloc( sizeof(lapack_complex_float) * ldab_t * MAX(1,n) ); + if( ab_t == NULL ) { + info = LAPACK_TRANSPOSE_MEMORY_ERROR; + goto exit_level_0; + } + /* Transpose input matrices */ + LAPACKE_cgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); + /* Call LAPACK function and adjust info */ + res = LAPACK_clangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + info = 0; /* LAPACK call is ok! */ + /* Release memory and exit */ + LAPACKE_free( ab_t ); +exit_level_0: + if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_clangb_work", info ); + } + } else { + info = -1; + LAPACKE_xerbla( "LAPACKE_clangb_work", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_dlangb.c b/LAPACKE/src/lapacke_dlangb.c new file mode 100644 index 0000000000..93db8e9a2d --- /dev/null +++ b/LAPACKE/src/lapacke_dlangb.c @@ -0,0 +1,73 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native high-level C interface to LAPACK function dlangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +double LAPACKE_dlangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const double* ab, + lapack_int ldab ) +{ + lapack_int info = 0; + double res = 0.; + double* work = NULL; + if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { + LAPACKE_xerbla( "LAPACKE_dlangb", -1 ); + return -1; + } +#ifndef LAPACK_DISABLE_NAN_CHECK + if( LAPACKE_get_nancheck() ) { + /* Optionally check input matrices for NaNs */ + if( LAPACKE_dgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) { + return -6; + } + } +#endif + /* Allocate memory for working array(s) */ + if( LAPACKE_lsame( norm, 'i' ) ) { + work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); + if( work == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call middle-level interface */ + res = LAPACKE_dlangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work ); + /* Release memory and exit */ + if( LAPACKE_lsame( norm, 'i' ) ) { + LAPACKE_free( work ); + } +exit_level_0: + if( info == LAPACK_WORK_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_dlangb", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_dlangb_work.c b/LAPACKE/src/lapacke_dlangb_work.c new file mode 100644 index 0000000000..7fb56dccfd --- /dev/null +++ b/LAPACKE/src/lapacke_dlangb_work.c @@ -0,0 +1,75 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native middle-level C interface to LAPACK function dlangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +double LAPACKE_dlangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const double* ab, + lapack_int ldab, double* work ) +{ + lapack_int info = 0; + double res = 0.; + if( matrix_layout == LAPACK_COL_MAJOR ) { + /* Call LAPACK function and adjust info */ + res = LAPACK_dlangb( &norm, &n, &kl, &ku, ab, &ldab, work ); + } else if( matrix_layout == LAPACK_ROW_MAJOR ) { + lapack_int ldab_t = MAX(1,kl+ku+1); + double* ab_t = NULL; + /* Check leading dimension(s) */ + if( ldab < kl+ku+1 ) { + info = -7; + LAPACKE_xerbla( "LAPACKE_dlangb_work", info ); + return info; + } + /* Allocate memory for temporary array(s) */ + ab_t = (double*)LAPACKE_malloc( sizeof(double) * ldab_t * MAX(1,n) ); + if( ab_t == NULL ) { + info = LAPACK_TRANSPOSE_MEMORY_ERROR; + goto exit_level_0; + } + /* Transpose input matrices */ + LAPACKE_dgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); + /* Call LAPACK function and adjust info */ + res = LAPACK_dlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + info = 0; /* LAPACK call is ok! */ + /* Release memory and exit */ + LAPACKE_free( ab_t ); +exit_level_0: + if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_dlangb_work", info ); + } + } else { + info = -1; + LAPACKE_xerbla( "LAPACKE_dlangb_work", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_slangb.c b/LAPACKE/src/lapacke_slangb.c new file mode 100644 index 0000000000..bff77d1cc9 --- /dev/null +++ b/LAPACKE/src/lapacke_slangb.c @@ -0,0 +1,73 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native high-level C interface to LAPACK function slangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +float LAPACKE_slangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const float* ab, + lapack_int ldab ) +{ + lapack_int info = 0; + float res = 0.; + float* work = NULL; + if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { + LAPACKE_xerbla( "LAPACKE_slangb", -1 ); + return -1; + } +#ifndef LAPACK_DISABLE_NAN_CHECK + if( LAPACKE_get_nancheck() ) { + /* Optionally check input matrices for NaNs */ + if( LAPACKE_sgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) { + return -6; + } + } +#endif + /* Allocate memory for working array(s) */ + if( LAPACKE_lsame( norm, 'i' ) ) { + work = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); + if( work == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call middle-level interface */ + res = LAPACKE_slangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work ); + /* Release memory and exit */ + if( LAPACKE_lsame( norm, 'i' ) ) { + LAPACKE_free( work ); + } +exit_level_0: + if( info == LAPACK_WORK_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_slangb", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_slangb_work.c b/LAPACKE/src/lapacke_slangb_work.c new file mode 100644 index 0000000000..9cc4ee8dca --- /dev/null +++ b/LAPACKE/src/lapacke_slangb_work.c @@ -0,0 +1,75 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native middle-level C interface to LAPACK function slangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +float LAPACKE_slangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, const float* ab, + lapack_int ldab, float* work ) +{ + lapack_int info = 0; + float res = 0.; + if( matrix_layout == LAPACK_COL_MAJOR ) { + /* Call LAPACK function and adjust info */ + res = LAPACK_slangb( &norm, &n, &kl, &ku, ab, &ldab, work ); + } else if( matrix_layout == LAPACK_ROW_MAJOR ) { + lapack_int ldab_t = MAX(1,kl+ku+1); + float* ab_t = NULL; + /* Check leading dimension(s) */ + if( ldab < kl+ku+1 ) { + info = -7; + LAPACKE_xerbla( "LAPACKE_slangb_work", info ); + return info; + } + /* Allocate memory for temporary array(s) */ + ab_t = (float*)LAPACKE_malloc( sizeof(float) * ldab_t * MAX(1,n) ); + if( ab_t == NULL ) { + info = LAPACK_TRANSPOSE_MEMORY_ERROR; + goto exit_level_0; + } + /* Transpose input matrices */ + LAPACKE_sgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); + /* Call LAPACK function and adjust info */ + res = LAPACK_slangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + info = 0; /* LAPACK call is ok! */ + /* Release memory and exit */ + LAPACKE_free( ab_t ); +exit_level_0: + if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_slangb_work", info ); + } + } else { + info = -1; + LAPACKE_xerbla( "LAPACKE_slangb_work", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_zlangb.c b/LAPACKE/src/lapacke_zlangb.c new file mode 100644 index 0000000000..3ec1f21065 --- /dev/null +++ b/LAPACKE/src/lapacke_zlangb.c @@ -0,0 +1,73 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native high-level C interface to LAPACK function zlangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +double LAPACKE_zlangb( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_double* ab, lapack_int ldab ) +{ + lapack_int info = 0; + double res = 0.; + double* work = NULL; + if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) { + LAPACKE_xerbla( "LAPACKE_zlangb", -1 ); + return -1; + } +#ifndef LAPACK_DISABLE_NAN_CHECK + if( LAPACKE_get_nancheck() ) { + /* Optionally check input matrices for NaNs */ + if( LAPACKE_zgb_nancheck( matrix_layout, n, n, kl, ku, ab, ldab ) ) { + return -6; + } + } +#endif + /* Allocate memory for working array(s) */ + if( LAPACKE_lsame( norm, 'i' ) ) { + work = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); + if( work == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call middle-level interface */ + res = LAPACKE_zlangb_work( matrix_layout, norm, n, kl, ku, ab, ldab, work ); + /* Release memory and exit */ + if( LAPACKE_lsame( norm, 'i' ) ) { + LAPACKE_free( work ); + } +exit_level_0: + if( info == LAPACK_WORK_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_zlangb", info ); + } + return res; +} diff --git a/LAPACKE/src/lapacke_zlangb_work.c b/LAPACKE/src/lapacke_zlangb_work.c new file mode 100644 index 0000000000..3666891ce5 --- /dev/null +++ b/LAPACKE/src/lapacke_zlangb_work.c @@ -0,0 +1,77 @@ +/***************************************************************************** + Copyright (c) 2014, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Intel Corporation nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. +***************************************************************************** +* Contents: Native middle-level C interface to LAPACK function zlangb +* Author: Intel Corporation +*****************************************************************************/ + +#include "lapacke_utils.h" + +double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n, + lapack_int kl, lapack_int ku, + const lapack_complex_double* ab, lapack_int ldab, + double* work ) +{ + lapack_int info = 0; + double res = 0.; + if( matrix_layout == LAPACK_COL_MAJOR ) { + /* Call LAPACK function and adjust info */ + res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab, &ldab, work ); + } else if( matrix_layout == LAPACK_ROW_MAJOR ) { + lapack_int ldab_t = MAX(1,kl+ku+1); + lapack_complex_double* ab_t = NULL; + /* Check leading dimension(s) */ + if( ldab < kl+ku+1 ) { + info = -7; + LAPACKE_xerbla( "LAPACKE_zlangb_work", info ); + return info; + } + /* Allocate memory for temporary array(s) */ + ab_t = (lapack_complex_double*) + LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) ); + if( ab_t == NULL ) { + info = LAPACK_TRANSPOSE_MEMORY_ERROR; + goto exit_level_0; + } + /* Transpose input matrices */ + LAPACKE_zgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); + /* Call LAPACK function and adjust info */ + res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + info = 0; /* LAPACK call is ok! */ + /* Release memory and exit */ + LAPACKE_free( ab_t ); +exit_level_0: + if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { + LAPACKE_xerbla( "LAPACKE_zlangb_work", info ); + } + } else { + info = -1; + LAPACKE_xerbla( "LAPACKE_zlangb_work", info ); + } + return res; +} From 12ce4ff9776892847e8d077166bc69cbe3df7cf8 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Oct 2022 19:38:32 +0100 Subject: [PATCH 2/5] Changed auther of LAPACKE_?langb files. --- LAPACKE/src/lapacke_clangb.c | 2 +- LAPACKE/src/lapacke_clangb_work.c | 2 +- LAPACKE/src/lapacke_dlangb.c | 2 +- LAPACKE/src/lapacke_dlangb_work.c | 2 +- LAPACKE/src/lapacke_slangb.c | 2 +- LAPACKE/src/lapacke_slangb_work.c | 2 +- LAPACKE/src/lapacke_zlangb.c | 2 +- LAPACKE/src/lapacke_zlangb_work.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LAPACKE/src/lapacke_clangb.c b/LAPACKE/src/lapacke_clangb.c index f4e0ab8900..b98aebc277 100644 --- a/LAPACKE/src/lapacke_clangb.c +++ b/LAPACKE/src/lapacke_clangb.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native high-level C interface to LAPACK function clangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_clangb_work.c b/LAPACKE/src/lapacke_clangb_work.c index 3d8a6447e7..645c679050 100644 --- a/LAPACKE/src/lapacke_clangb_work.c +++ b/LAPACKE/src/lapacke_clangb_work.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native middle-level C interface to LAPACK function clangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_dlangb.c b/LAPACKE/src/lapacke_dlangb.c index 93db8e9a2d..0822997d38 100644 --- a/LAPACKE/src/lapacke_dlangb.c +++ b/LAPACKE/src/lapacke_dlangb.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native high-level C interface to LAPACK function dlangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_dlangb_work.c b/LAPACKE/src/lapacke_dlangb_work.c index 7fb56dccfd..b7495ddbb3 100644 --- a/LAPACKE/src/lapacke_dlangb_work.c +++ b/LAPACKE/src/lapacke_dlangb_work.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native middle-level C interface to LAPACK function dlangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_slangb.c b/LAPACKE/src/lapacke_slangb.c index bff77d1cc9..397e0081b6 100644 --- a/LAPACKE/src/lapacke_slangb.c +++ b/LAPACKE/src/lapacke_slangb.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native high-level C interface to LAPACK function slangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_slangb_work.c b/LAPACKE/src/lapacke_slangb_work.c index 9cc4ee8dca..4fcd485c31 100644 --- a/LAPACKE/src/lapacke_slangb_work.c +++ b/LAPACKE/src/lapacke_slangb_work.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native middle-level C interface to LAPACK function slangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_zlangb.c b/LAPACKE/src/lapacke_zlangb.c index 3ec1f21065..2933532075 100644 --- a/LAPACKE/src/lapacke_zlangb.c +++ b/LAPACKE/src/lapacke_zlangb.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native high-level C interface to LAPACK function zlangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" diff --git a/LAPACKE/src/lapacke_zlangb_work.c b/LAPACKE/src/lapacke_zlangb_work.c index 3666891ce5..6ab08b617e 100644 --- a/LAPACKE/src/lapacke_zlangb_work.c +++ b/LAPACKE/src/lapacke_zlangb_work.c @@ -27,7 +27,7 @@ THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native middle-level C interface to LAPACK function zlangb -* Author: Intel Corporation +* Author: Simon Märtens *****************************************************************************/ #include "lapacke_utils.h" From 6c6c5a5372d571a966b1f36bfc141d810b02696e Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Oct 2022 19:48:52 +0100 Subject: [PATCH 3/5] Changed copyright year of LAPACKE_?langb files. --- LAPACKE/src/lapacke_clangb.c | 2 +- LAPACKE/src/lapacke_clangb_work.c | 2 +- LAPACKE/src/lapacke_dlangb.c | 2 +- LAPACKE/src/lapacke_dlangb_work.c | 2 +- LAPACKE/src/lapacke_slangb.c | 2 +- LAPACKE/src/lapacke_slangb_work.c | 2 +- LAPACKE/src/lapacke_zlangb.c | 2 +- LAPACKE/src/lapacke_zlangb_work.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LAPACKE/src/lapacke_clangb.c b/LAPACKE/src/lapacke_clangb.c index b98aebc277..0d61575aaa 100644 --- a/LAPACKE/src/lapacke_clangb.c +++ b/LAPACKE/src/lapacke_clangb.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_clangb_work.c b/LAPACKE/src/lapacke_clangb_work.c index 645c679050..cff6ae4d51 100644 --- a/LAPACKE/src/lapacke_clangb_work.c +++ b/LAPACKE/src/lapacke_clangb_work.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_dlangb.c b/LAPACKE/src/lapacke_dlangb.c index 0822997d38..ca16ea7f46 100644 --- a/LAPACKE/src/lapacke_dlangb.c +++ b/LAPACKE/src/lapacke_dlangb.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_dlangb_work.c b/LAPACKE/src/lapacke_dlangb_work.c index b7495ddbb3..9732d35dc8 100644 --- a/LAPACKE/src/lapacke_dlangb_work.c +++ b/LAPACKE/src/lapacke_dlangb_work.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_slangb.c b/LAPACKE/src/lapacke_slangb.c index 397e0081b6..9ba3f30d8d 100644 --- a/LAPACKE/src/lapacke_slangb.c +++ b/LAPACKE/src/lapacke_slangb.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_slangb_work.c b/LAPACKE/src/lapacke_slangb_work.c index 4fcd485c31..312e9f0416 100644 --- a/LAPACKE/src/lapacke_slangb_work.c +++ b/LAPACKE/src/lapacke_slangb_work.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_zlangb.c b/LAPACKE/src/lapacke_zlangb.c index 2933532075..3a22ad9822 100644 --- a/LAPACKE/src/lapacke_zlangb.c +++ b/LAPACKE/src/lapacke_zlangb.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LAPACKE/src/lapacke_zlangb_work.c b/LAPACKE/src/lapacke_zlangb_work.c index 6ab08b617e..db4a83883b 100644 --- a/LAPACKE/src/lapacke_zlangb_work.c +++ b/LAPACKE/src/lapacke_zlangb_work.c @@ -1,5 +1,5 @@ /***************************************************************************** - Copyright (c) 2014, Intel Corp. + Copyright (c) 2022, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without From 945bb8d1700b319ae5dd0791d49de6c6e7140b52 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Oct 2022 19:58:26 +0100 Subject: [PATCH 4/5] Removed unnecessary assign to info. --- LAPACKE/src/lapacke_clangb_work.c | 1 - LAPACKE/src/lapacke_dlangb_work.c | 1 - LAPACKE/src/lapacke_slangb_work.c | 1 - LAPACKE/src/lapacke_zlangb_work.c | 1 - 4 files changed, 4 deletions(-) diff --git a/LAPACKE/src/lapacke_clangb_work.c b/LAPACKE/src/lapacke_clangb_work.c index cff6ae4d51..46d2c0d9ef 100644 --- a/LAPACKE/src/lapacke_clangb_work.c +++ b/LAPACKE/src/lapacke_clangb_work.c @@ -62,7 +62,6 @@ float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n, LAPACKE_cgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ res = LAPACK_clangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); - info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( ab_t ); exit_level_0: diff --git a/LAPACKE/src/lapacke_dlangb_work.c b/LAPACKE/src/lapacke_dlangb_work.c index 9732d35dc8..9e650b5eb7 100644 --- a/LAPACKE/src/lapacke_dlangb_work.c +++ b/LAPACKE/src/lapacke_dlangb_work.c @@ -60,7 +60,6 @@ double LAPACKE_dlangb_work( int matrix_layout, char norm, lapack_int n, LAPACKE_dgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ res = LAPACK_dlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); - info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( ab_t ); exit_level_0: diff --git a/LAPACKE/src/lapacke_slangb_work.c b/LAPACKE/src/lapacke_slangb_work.c index 312e9f0416..98cbc7a4ac 100644 --- a/LAPACKE/src/lapacke_slangb_work.c +++ b/LAPACKE/src/lapacke_slangb_work.c @@ -60,7 +60,6 @@ float LAPACKE_slangb_work( int matrix_layout, char norm, lapack_int n, LAPACKE_sgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ res = LAPACK_slangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); - info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( ab_t ); exit_level_0: diff --git a/LAPACKE/src/lapacke_zlangb_work.c b/LAPACKE/src/lapacke_zlangb_work.c index db4a83883b..a12bd113ef 100644 --- a/LAPACKE/src/lapacke_zlangb_work.c +++ b/LAPACKE/src/lapacke_zlangb_work.c @@ -62,7 +62,6 @@ double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n, LAPACKE_zgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); /* Call LAPACK function and adjust info */ res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); - info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( ab_t ); exit_level_0: From 15e62c3e701a7c75f177e215e125f288b0c73fbd Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Thu, 6 Oct 2022 13:59:10 +0100 Subject: [PATCH 5/5] Use the same trick as in ?lange to remove the matrix transposition. --- LAPACKE/src/lapacke_clangb_work.c | 34 +++++++++++++++++++------------ LAPACKE/src/lapacke_dlangb_work.c | 33 +++++++++++++++++++----------- LAPACKE/src/lapacke_slangb_work.c | 33 +++++++++++++++++++----------- LAPACKE/src/lapacke_zlangb_work.c | 34 +++++++++++++++++++------------ 4 files changed, 84 insertions(+), 50 deletions(-) diff --git a/LAPACKE/src/lapacke_clangb_work.c b/LAPACKE/src/lapacke_clangb_work.c index 46d2c0d9ef..b5b2cf8163 100644 --- a/LAPACKE/src/lapacke_clangb_work.c +++ b/LAPACKE/src/lapacke_clangb_work.c @@ -43,27 +43,35 @@ float LAPACKE_clangb_work( int matrix_layout, char norm, lapack_int n, /* Call LAPACK function and adjust info */ res = LAPACK_clangb( &norm, &n, &kl, &ku, ab, &ldab, work ); } else if( matrix_layout == LAPACK_ROW_MAJOR ) { - lapack_int ldab_t = MAX(1,kl+ku+1); - lapack_complex_float* ab_t = NULL; + char norm_lapack; + float* work_lapack = NULL; /* Check leading dimension(s) */ if( ldab < kl+ku+1 ) { info = -7; LAPACKE_xerbla( "LAPACKE_clangb_work", info ); return info; } - /* Allocate memory for temporary array(s) */ - ab_t = (lapack_complex_float*) - LAPACKE_malloc( sizeof(lapack_complex_float) * ldab_t * MAX(1,n) ); - if( ab_t == NULL ) { - info = LAPACK_TRANSPOSE_MEMORY_ERROR; - goto exit_level_0; + if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) { + norm_lapack = 'i'; + } else if( LAPACKE_lsame( norm, 'i' ) ) { + norm_lapack = '1'; + } else { + norm_lapack = norm; } - /* Transpose input matrices */ - LAPACKE_cgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); - /* Call LAPACK function and adjust info */ - res = LAPACK_clangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + /* Allocate memory for work array(s) */ + if( LAPACKE_lsame( norm_lapack, 'i' ) ) { + work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); + if( work_lapack == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call LAPACK function */ + res = LAPACK_clangb( &norm, &n, &ku, &kl, ab, &ldab, work ); /* Release memory and exit */ - LAPACKE_free( ab_t ); + if( work_lapack ) { + LAPACKE_free( work_lapack ); + } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_clangb_work", info ); diff --git a/LAPACKE/src/lapacke_dlangb_work.c b/LAPACKE/src/lapacke_dlangb_work.c index 9e650b5eb7..ba04c2b628 100644 --- a/LAPACKE/src/lapacke_dlangb_work.c +++ b/LAPACKE/src/lapacke_dlangb_work.c @@ -42,26 +42,35 @@ double LAPACKE_dlangb_work( int matrix_layout, char norm, lapack_int n, /* Call LAPACK function and adjust info */ res = LAPACK_dlangb( &norm, &n, &kl, &ku, ab, &ldab, work ); } else if( matrix_layout == LAPACK_ROW_MAJOR ) { - lapack_int ldab_t = MAX(1,kl+ku+1); - double* ab_t = NULL; + char norm_lapack; + double* work_lapack = NULL; /* Check leading dimension(s) */ if( ldab < kl+ku+1 ) { info = -7; LAPACKE_xerbla( "LAPACKE_dlangb_work", info ); return info; } - /* Allocate memory for temporary array(s) */ - ab_t = (double*)LAPACKE_malloc( sizeof(double) * ldab_t * MAX(1,n) ); - if( ab_t == NULL ) { - info = LAPACK_TRANSPOSE_MEMORY_ERROR; - goto exit_level_0; + if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) { + norm_lapack = 'i'; + } else if( LAPACKE_lsame( norm, 'i' ) ) { + norm_lapack = '1'; + } else { + norm_lapack = norm; } - /* Transpose input matrices */ - LAPACKE_dgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); - /* Call LAPACK function and adjust info */ - res = LAPACK_dlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + /* Allocate memory for work array(s) */ + if( LAPACKE_lsame( norm_lapack, 'i' ) ) { + work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); + if( work_lapack == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call LAPACK function */ + res = LAPACK_dlangb( &norm, &n, &ku, &kl, ab, &ldab, work ); /* Release memory and exit */ - LAPACKE_free( ab_t ); + if( work_lapack ) { + LAPACKE_free( work_lapack ); + } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dlangb_work", info ); diff --git a/LAPACKE/src/lapacke_slangb_work.c b/LAPACKE/src/lapacke_slangb_work.c index 98cbc7a4ac..7ef86e9d90 100644 --- a/LAPACKE/src/lapacke_slangb_work.c +++ b/LAPACKE/src/lapacke_slangb_work.c @@ -42,26 +42,35 @@ float LAPACKE_slangb_work( int matrix_layout, char norm, lapack_int n, /* Call LAPACK function and adjust info */ res = LAPACK_slangb( &norm, &n, &kl, &ku, ab, &ldab, work ); } else if( matrix_layout == LAPACK_ROW_MAJOR ) { - lapack_int ldab_t = MAX(1,kl+ku+1); - float* ab_t = NULL; + char norm_lapack; + float* work_lapack = NULL; /* Check leading dimension(s) */ if( ldab < kl+ku+1 ) { info = -7; LAPACKE_xerbla( "LAPACKE_slangb_work", info ); return info; } - /* Allocate memory for temporary array(s) */ - ab_t = (float*)LAPACKE_malloc( sizeof(float) * ldab_t * MAX(1,n) ); - if( ab_t == NULL ) { - info = LAPACK_TRANSPOSE_MEMORY_ERROR; - goto exit_level_0; + if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) { + norm_lapack = 'i'; + } else if( LAPACKE_lsame( norm, 'i' ) ) { + norm_lapack = '1'; + } else { + norm_lapack = norm; } - /* Transpose input matrices */ - LAPACKE_sgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); - /* Call LAPACK function and adjust info */ - res = LAPACK_slangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + /* Allocate memory for work array(s) */ + if( LAPACKE_lsame( norm_lapack, 'i' ) ) { + work_lapack = (float*)LAPACKE_malloc( sizeof(float) * MAX(1,n) ); + if( work_lapack == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call LAPACK function */ + res = LAPACK_slangb( &norm, &n, &ku, &kl, ab, &ldab, work ); /* Release memory and exit */ - LAPACKE_free( ab_t ); + if( work_lapack ) { + LAPACKE_free( work_lapack ); + } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_slangb_work", info ); diff --git a/LAPACKE/src/lapacke_zlangb_work.c b/LAPACKE/src/lapacke_zlangb_work.c index a12bd113ef..d64fb482d5 100644 --- a/LAPACKE/src/lapacke_zlangb_work.c +++ b/LAPACKE/src/lapacke_zlangb_work.c @@ -43,27 +43,35 @@ double LAPACKE_zlangb_work( int matrix_layout, char norm, lapack_int n, /* Call LAPACK function and adjust info */ res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab, &ldab, work ); } else if( matrix_layout == LAPACK_ROW_MAJOR ) { - lapack_int ldab_t = MAX(1,kl+ku+1); - lapack_complex_double* ab_t = NULL; + char norm_lapack; + double* work_lapack = NULL; /* Check leading dimension(s) */ if( ldab < kl+ku+1 ) { info = -7; LAPACKE_xerbla( "LAPACKE_zlangb_work", info ); return info; } - /* Allocate memory for temporary array(s) */ - ab_t = (lapack_complex_double*) - LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) ); - if( ab_t == NULL ) { - info = LAPACK_TRANSPOSE_MEMORY_ERROR; - goto exit_level_0; + if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) { + norm_lapack = 'i'; + } else if( LAPACKE_lsame( norm, 'i' ) ) { + norm_lapack = '1'; + } else { + norm_lapack = norm; } - /* Transpose input matrices */ - LAPACKE_zgb_trans( matrix_layout, n, n, kl, ku, ab, ldab, ab_t, ldab_t ); - /* Call LAPACK function and adjust info */ - res = LAPACK_zlangb( &norm, &n, &kl, &ku, ab_t, &ldab_t, work ); + /* Allocate memory for work array(s) */ + if( LAPACKE_lsame( norm_lapack, 'i' ) ) { + work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); + if( work_lapack == NULL ) { + info = LAPACK_WORK_MEMORY_ERROR; + goto exit_level_0; + } + } + /* Call LAPACK function */ + res = LAPACK_zlangb( &norm, &n, &ku, &kl, ab, &ldab, work ); /* Release memory and exit */ - LAPACKE_free( ab_t ); + if( work_lapack ) { + LAPACKE_free( work_lapack ); + } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_zlangb_work", info );