Merge pull request #3826 from martin-frbg/lapack540+725
Add a LAPACKE interface for ?LANGB and fix ?TPMQRT (Reference-LAPACK PR 540+725)
This commit is contained in:
commit
ec0ae034bc
|
@ -318,6 +318,8 @@ set(CSRC
|
|||
lapacke_clacn2.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
|
||||
|
@ -803,6 +805,8 @@ set(DSRC
|
|||
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
|
||||
|
@ -1381,6 +1385,8 @@ set(SSRC
|
|||
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
|
||||
|
@ -2089,6 +2095,8 @@ set(ZSRC
|
|||
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
|
||||
|
|
|
@ -358,6 +358,8 @@ lapacke_clacrm.o \
|
|||
lapacke_clacrm_work.o \
|
||||
lapacke_clag2z.o \
|
||||
lapacke_clag2z_work.o \
|
||||
lapacke_clangb.o \
|
||||
lapacke_clangb_work.o \
|
||||
lapacke_clange.o \
|
||||
lapacke_clange_work.o \
|
||||
lapacke_clanhe.o \
|
||||
|
@ -842,6 +844,8 @@ lapacke_dlag2s.o \
|
|||
lapacke_dlag2s_work.o \
|
||||
lapacke_dlamch.o \
|
||||
lapacke_dlamch_work.o \
|
||||
lapacke_dlangb.o \
|
||||
lapacke_dlangb_work.o \
|
||||
lapacke_dlange.o \
|
||||
lapacke_dlange_work.o \
|
||||
lapacke_dlansy.o \
|
||||
|
@ -1414,6 +1418,8 @@ lapacke_slacpy.o \
|
|||
lapacke_slacpy_work.o \
|
||||
lapacke_slamch.o \
|
||||
lapacke_slamch_work.o \
|
||||
lapacke_slangb.o \
|
||||
lapacke_slangb_work.o \
|
||||
lapacke_slange.o \
|
||||
lapacke_slange_work.o \
|
||||
lapacke_slansy.o \
|
||||
|
@ -2116,6 +2122,8 @@ lapacke_zlacrm.o \
|
|||
lapacke_zlacrm_work.o \
|
||||
lapacke_zlag2c.o \
|
||||
lapacke_zlag2c_work.o \
|
||||
lapacke_zlangb.o \
|
||||
lapacke_zlangb_work.o \
|
||||
lapacke_zlange.o \
|
||||
lapacke_zlange_work.o \
|
||||
lapacke_zlanhe.o \
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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 ) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* 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 */
|
||||
if( work_lapack ) {
|
||||
LAPACKE_free( work_lapack );
|
||||
}
|
||||
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;
|
||||
}
|
|
@ -50,16 +50,24 @@ lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
|
||||
lapack_int lda_t = MAX(1,k);
|
||||
lapack_int nrowsA, ncolsA, nrowsV;
|
||||
if ( side == LAPACKE_lsame(side, 'l') ) { nrowsA = k; ncolsA = n; nrowsV = m; }
|
||||
else if ( side == LAPACKE_lsame(side, 'r') ) { nrowsA = m; ncolsA = k; nrowsV = n; }
|
||||
else {
|
||||
info = -2;
|
||||
LAPACKE_xerbla( "LAPACKE_ctpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
lapack_int lda_t = MAX(1,nrowsA);
|
||||
lapack_int ldb_t = MAX(1,m);
|
||||
lapack_int ldt_t = MAX(1,ldt);
|
||||
lapack_int ldv_t = MAX(1,ldv);
|
||||
lapack_int ldt_t = MAX(1,nb);
|
||||
lapack_int ldv_t = MAX(1,nrowsV);
|
||||
lapack_complex_float* v_t = NULL;
|
||||
lapack_complex_float* t_t = NULL;
|
||||
lapack_complex_float* a_t = NULL;
|
||||
lapack_complex_float* b_t = NULL;
|
||||
/* Check leading dimension(s) */
|
||||
if( lda < m ) {
|
||||
if( lda < ncolsA ) {
|
||||
info = -14;
|
||||
LAPACKE_xerbla( "LAPACKE_ctpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -69,7 +77,7 @@ lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans,
|
|||
LAPACKE_xerbla( "LAPACKE_ctpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
if( ldt < nb ) {
|
||||
if( ldt < k ) {
|
||||
info = -12;
|
||||
LAPACKE_xerbla( "LAPACKE_ctpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -87,13 +95,13 @@ lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_0;
|
||||
}
|
||||
t_t = (lapack_complex_float*)
|
||||
LAPACKE_malloc( sizeof(lapack_complex_float) * ldt_t * MAX(1,nb) );
|
||||
LAPACKE_malloc( sizeof(lapack_complex_float) * ldt_t * MAX(1,k) );
|
||||
if( t_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_1;
|
||||
}
|
||||
a_t = (lapack_complex_float*)
|
||||
LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,m) );
|
||||
LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,ncolsA) );
|
||||
if( a_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_2;
|
||||
|
@ -105,10 +113,10 @@ lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_3;
|
||||
}
|
||||
/* Transpose input matrices */
|
||||
LAPACKE_cge_trans( matrix_layout, ldv, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_cge_trans( matrix_layout, ldt, nb, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_cge_trans( matrix_layout, k, m, a, lda, a_t, lda_t );
|
||||
LAPACKE_cge_trans( matrix_layout, m, n, b, ldb, b_t, ldb_t );
|
||||
LAPACKE_cge_trans( LAPACK_ROW_MAJOR, nrowsV, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_cge_trans( LAPACK_ROW_MAJOR, nb, k, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_cge_trans( LAPACK_ROW_MAJOR, nrowsA, ncolsA, a, lda, a_t, lda_t );
|
||||
LAPACKE_cge_trans( LAPACK_ROW_MAJOR, m, n, b, ldb, b_t, ldb_t );
|
||||
/* Call LAPACK function and adjust info */
|
||||
LAPACK_ctpmqrt( &side, &trans, &m, &n, &k, &l, &nb, v_t, &ldv_t, t_t,
|
||||
&ldt_t, a_t, &lda_t, b_t, &ldb_t, work, &info );
|
||||
|
@ -116,7 +124,7 @@ lapack_int LAPACKE_ctpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
/* Transpose output matrices */
|
||||
LAPACKE_cge_trans( LAPACK_COL_MAJOR, k, m, a_t, lda_t, a, lda );
|
||||
LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrowsA, ncolsA, a_t, lda_t, a, lda );
|
||||
LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb );
|
||||
/* Release memory and exit */
|
||||
LAPACKE_free( b_t );
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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 ) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* 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 */
|
||||
if( work_lapack ) {
|
||||
LAPACKE_free( work_lapack );
|
||||
}
|
||||
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;
|
||||
}
|
|
@ -48,16 +48,24 @@ lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
|
||||
lapack_int lda_t = MAX(1,k);
|
||||
lapack_int nrowsA, ncolsA, nrowsV;
|
||||
if ( side == LAPACKE_lsame(side, 'l') ) { nrowsA = k; ncolsA = n; nrowsV = m; }
|
||||
else if ( side == LAPACKE_lsame(side, 'r') ) { nrowsA = m; ncolsA = k; nrowsV = n; }
|
||||
else {
|
||||
info = -2;
|
||||
LAPACKE_xerbla( "LAPACKE_dtpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
lapack_int lda_t = MAX(1,nrowsA);
|
||||
lapack_int ldb_t = MAX(1,m);
|
||||
lapack_int ldt_t = MAX(1,ldt);
|
||||
lapack_int ldv_t = MAX(1,ldv);
|
||||
lapack_int ldt_t = MAX(1,nb);
|
||||
lapack_int ldv_t = MAX(1,nrowsV);
|
||||
double* v_t = NULL;
|
||||
double* t_t = NULL;
|
||||
double* a_t = NULL;
|
||||
double* b_t = NULL;
|
||||
/* Check leading dimension(s) */
|
||||
if( lda < m ) {
|
||||
if( lda < ncolsA ) {
|
||||
info = -14;
|
||||
LAPACKE_xerbla( "LAPACKE_dtpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -67,7 +75,7 @@ lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans,
|
|||
LAPACKE_xerbla( "LAPACKE_dtpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
if( ldt < nb ) {
|
||||
if( ldt < k ) {
|
||||
info = -12;
|
||||
LAPACKE_xerbla( "LAPACKE_dtpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -83,12 +91,12 @@ lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_0;
|
||||
}
|
||||
t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,nb) );
|
||||
t_t = (double*)LAPACKE_malloc( sizeof(double) * ldt_t * MAX(1,k) );
|
||||
if( t_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_1;
|
||||
}
|
||||
a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,m) );
|
||||
a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,ncolsA) );
|
||||
if( a_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_2;
|
||||
|
@ -99,10 +107,10 @@ lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_3;
|
||||
}
|
||||
/* Transpose input matrices */
|
||||
LAPACKE_dge_trans( matrix_layout, ldv, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_dge_trans( matrix_layout, ldt, nb, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_dge_trans( matrix_layout, k, m, a, lda, a_t, lda_t );
|
||||
LAPACKE_dge_trans( matrix_layout, m, n, b, ldb, b_t, ldb_t );
|
||||
LAPACKE_dge_trans( LAPACK_ROW_MAJOR, nrowsV, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_dge_trans( LAPACK_ROW_MAJOR, nb, k, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_dge_trans( LAPACK_ROW_MAJOR, nrowsA, ncolsA, a, lda, a_t, lda_t );
|
||||
LAPACKE_dge_trans( LAPACK_ROW_MAJOR, m, n, b, ldb, b_t, ldb_t );
|
||||
/* Call LAPACK function and adjust info */
|
||||
LAPACK_dtpmqrt( &side, &trans, &m, &n, &k, &l, &nb, v_t, &ldv_t, t_t,
|
||||
&ldt_t, a_t, &lda_t, b_t, &ldb_t, work, &info );
|
||||
|
@ -110,7 +118,7 @@ lapack_int LAPACKE_dtpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
/* Transpose output matrices */
|
||||
LAPACKE_dge_trans( LAPACK_COL_MAJOR, k, m, a_t, lda_t, a, lda );
|
||||
LAPACKE_dge_trans( LAPACK_COL_MAJOR, nrowsA, ncolsA, a_t, lda_t, a, lda );
|
||||
LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb );
|
||||
/* Release memory and exit */
|
||||
LAPACKE_free( b_t );
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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 ) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* 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 */
|
||||
if( work_lapack ) {
|
||||
LAPACKE_free( work_lapack );
|
||||
}
|
||||
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;
|
||||
}
|
|
@ -48,16 +48,24 @@ lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
|
||||
lapack_int lda_t = MAX(1,k);
|
||||
lapack_int nrowsA, ncolsA, nrowsV;
|
||||
if ( side == LAPACKE_lsame(side, 'l') ) { nrowsA = k; ncolsA = n; nrowsV = m; }
|
||||
else if ( side == LAPACKE_lsame(side, 'r') ) { nrowsA = m; ncolsA = k; nrowsV = n; }
|
||||
else {
|
||||
info = -2;
|
||||
LAPACKE_xerbla( "LAPACKE_stpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
lapack_int lda_t = MAX(1,nrowsA);
|
||||
lapack_int ldb_t = MAX(1,m);
|
||||
lapack_int ldt_t = MAX(1,ldt);
|
||||
lapack_int ldv_t = MAX(1,ldv);
|
||||
lapack_int ldt_t = MAX(1,nb);
|
||||
lapack_int ldv_t = MAX(1,nrowsV);
|
||||
float* v_t = NULL;
|
||||
float* t_t = NULL;
|
||||
float* a_t = NULL;
|
||||
float* b_t = NULL;
|
||||
/* Check leading dimension(s) */
|
||||
if( lda < m ) {
|
||||
if( lda < ncolsA ) {
|
||||
info = -14;
|
||||
LAPACKE_xerbla( "LAPACKE_stpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -67,7 +75,7 @@ lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans,
|
|||
LAPACKE_xerbla( "LAPACKE_stpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
if( ldt < nb ) {
|
||||
if( ldt < k ) {
|
||||
info = -12;
|
||||
LAPACKE_xerbla( "LAPACKE_stpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -83,12 +91,12 @@ lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_0;
|
||||
}
|
||||
t_t = (float*)LAPACKE_malloc( sizeof(float) * ldt_t * MAX(1,nb) );
|
||||
t_t = (float*)LAPACKE_malloc( sizeof(float) * ldt_t * MAX(1,k) );
|
||||
if( t_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_1;
|
||||
}
|
||||
a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,m) );
|
||||
a_t = (float*)LAPACKE_malloc( sizeof(float) * lda_t * MAX(1,ncolsA) );
|
||||
if( a_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_2;
|
||||
|
@ -99,10 +107,10 @@ lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_3;
|
||||
}
|
||||
/* Transpose input matrices */
|
||||
LAPACKE_sge_trans( matrix_layout, ldv, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_sge_trans( matrix_layout, ldt, nb, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_sge_trans( matrix_layout, k, m, a, lda, a_t, lda_t );
|
||||
LAPACKE_sge_trans( matrix_layout, m, n, b, ldb, b_t, ldb_t );
|
||||
LAPACKE_sge_trans( LAPACK_ROW_MAJOR, nrowsV, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_sge_trans( LAPACK_ROW_MAJOR, nb, k, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_sge_trans( LAPACK_ROW_MAJOR, nrowsA, ncolsA, a, lda, a_t, lda_t );
|
||||
LAPACKE_sge_trans( LAPACK_ROW_MAJOR, m, n, b, ldb, b_t, ldb_t );
|
||||
/* Call LAPACK function and adjust info */
|
||||
LAPACK_stpmqrt( &side, &trans, &m, &n, &k, &l, &nb, v_t, &ldv_t, t_t,
|
||||
&ldt_t, a_t, &lda_t, b_t, &ldb_t, work, &info );
|
||||
|
@ -110,7 +118,7 @@ lapack_int LAPACKE_stpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
/* Transpose output matrices */
|
||||
LAPACKE_sge_trans( LAPACK_COL_MAJOR, k, m, a_t, lda_t, a, lda );
|
||||
LAPACKE_sge_trans( LAPACK_COL_MAJOR, nrowsA, ncolsA, a_t, lda_t, a, lda );
|
||||
LAPACKE_sge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb );
|
||||
/* Release memory and exit */
|
||||
LAPACKE_free( b_t );
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
Copyright (c) 2022, 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: Simon Märtens
|
||||
*****************************************************************************/
|
||||
|
||||
#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 ) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* 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 */
|
||||
if( work_lapack ) {
|
||||
LAPACKE_free( work_lapack );
|
||||
}
|
||||
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;
|
||||
}
|
|
@ -50,16 +50,24 @@ lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
} else if( matrix_layout == LAPACK_ROW_MAJOR ) {
|
||||
lapack_int lda_t = MAX(1,k);
|
||||
lapack_int nrowsA, ncolsA, nrowsV;
|
||||
if ( side == LAPACKE_lsame(side, 'l') ) { nrowsA = k; ncolsA = n; nrowsV = m; }
|
||||
else if ( side == LAPACKE_lsame(side, 'r') ) { nrowsA = m; ncolsA = k; nrowsV = n; }
|
||||
else {
|
||||
info = -2;
|
||||
LAPACKE_xerbla( "LAPACKE_ztpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
lapack_int lda_t = MAX(1,nrowsA);
|
||||
lapack_int ldb_t = MAX(1,m);
|
||||
lapack_int ldt_t = MAX(1,ldt);
|
||||
lapack_int ldv_t = MAX(1,ldv);
|
||||
lapack_int ldt_t = MAX(1,nb);
|
||||
lapack_int ldv_t = MAX(1,nrowsV);
|
||||
lapack_complex_double* v_t = NULL;
|
||||
lapack_complex_double* t_t = NULL;
|
||||
lapack_complex_double* a_t = NULL;
|
||||
lapack_complex_double* b_t = NULL;
|
||||
/* Check leading dimension(s) */
|
||||
if( lda < m ) {
|
||||
if( lda < ncolsA ) {
|
||||
info = -14;
|
||||
LAPACKE_xerbla( "LAPACKE_ztpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -69,7 +77,7 @@ lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans,
|
|||
LAPACKE_xerbla( "LAPACKE_ztpmqrt_work", info );
|
||||
return info;
|
||||
}
|
||||
if( ldt < nb ) {
|
||||
if( ldt < k ) {
|
||||
info = -12;
|
||||
LAPACKE_xerbla( "LAPACKE_ztpmqrt_work", info );
|
||||
return info;
|
||||
|
@ -87,13 +95,13 @@ lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_0;
|
||||
}
|
||||
t_t = (lapack_complex_double*)
|
||||
LAPACKE_malloc( sizeof(lapack_complex_double) * ldt_t * MAX(1,nb) );
|
||||
LAPACKE_malloc( sizeof(lapack_complex_double) * ldt_t * MAX(1,k) );
|
||||
if( t_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_1;
|
||||
}
|
||||
a_t = (lapack_complex_double*)
|
||||
LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,m) );
|
||||
LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,ncolsA) );
|
||||
if( a_t == NULL ) {
|
||||
info = LAPACK_TRANSPOSE_MEMORY_ERROR;
|
||||
goto exit_level_2;
|
||||
|
@ -105,10 +113,10 @@ lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans,
|
|||
goto exit_level_3;
|
||||
}
|
||||
/* Transpose input matrices */
|
||||
LAPACKE_zge_trans( matrix_layout, ldv, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_zge_trans( matrix_layout, ldt, nb, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_zge_trans( matrix_layout, k, m, a, lda, a_t, lda_t );
|
||||
LAPACKE_zge_trans( matrix_layout, m, n, b, ldb, b_t, ldb_t );
|
||||
LAPACKE_zge_trans( LAPACK_ROW_MAJOR, nrowsV, k, v, ldv, v_t, ldv_t );
|
||||
LAPACKE_zge_trans( LAPACK_ROW_MAJOR, nb, k, t, ldt, t_t, ldt_t );
|
||||
LAPACKE_zge_trans( LAPACK_ROW_MAJOR, nrowsA, ncolsA, a, lda, a_t, lda_t );
|
||||
LAPACKE_zge_trans( LAPACK_ROW_MAJOR, m, n, b, ldb, b_t, ldb_t );
|
||||
/* Call LAPACK function and adjust info */
|
||||
LAPACK_ztpmqrt( &side, &trans, &m, &n, &k, &l, &nb, v_t, &ldv_t, t_t,
|
||||
&ldt_t, a_t, &lda_t, b_t, &ldb_t, work, &info );
|
||||
|
@ -116,7 +124,7 @@ lapack_int LAPACKE_ztpmqrt_work( int matrix_layout, char side, char trans,
|
|||
info = info - 1;
|
||||
}
|
||||
/* Transpose output matrices */
|
||||
LAPACKE_zge_trans( LAPACK_COL_MAJOR, k, m, a_t, lda_t, a, lda );
|
||||
LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrowsA, ncolsA, a_t, lda_t, a, lda );
|
||||
LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb );
|
||||
/* Release memory and exit */
|
||||
LAPACKE_free( b_t );
|
||||
|
|
Loading…
Reference in New Issue