lapacke_zggesx_work.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002   Copyright (c) 2010, Intel Corp.
00003   All rights reserved.
00004 
00005   Redistribution and use in source and binary forms, with or without
00006   modification, are permitted provided that the following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice,
00009       this list of conditions and the following disclaimer.
00010     * Redistributions in binary form must reproduce the above copyright
00011       notice, this list of conditions and the following disclaimer in the
00012       documentation and/or other materials provided with the distribution.
00013     * Neither the name of Intel Corporation nor the names of its contributors
00014       may be used to endorse or promote products derived from this software
00015       without specific prior written permission.
00016 
00017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00027   THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************
00029 * Contents: Native middle-level C interface to LAPACK function zggesx
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_zggesx_work( int matrix_order, char jobvsl, char jobvsr,
00038                                 char sort, LAPACK_Z_SELECT2 selctg, char sense,
00039                                 lapack_int n, lapack_complex_double* a,
00040                                 lapack_int lda, lapack_complex_double* b,
00041                                 lapack_int ldb, lapack_int* sdim,
00042                                 lapack_complex_double* alpha,
00043                                 lapack_complex_double* beta,
00044                                 lapack_complex_double* vsl, lapack_int ldvsl,
00045                                 lapack_complex_double* vsr, lapack_int ldvsr,
00046                                 double* rconde, double* rcondv,
00047                                 lapack_complex_double* work, lapack_int lwork,
00048                                 double* rwork, lapack_int* iwork,
00049                                 lapack_int liwork, lapack_logical* bwork )
00050 {
00051     lapack_int info = 0;
00052     if( matrix_order == LAPACK_COL_MAJOR ) {
00053         /* Call LAPACK function and adjust info */
00054         LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a, &lda, b,
00055                        &ldb, sdim, alpha, beta, vsl, &ldvsl, vsr, &ldvsr,
00056                        rconde, rcondv, work, &lwork, rwork, iwork, &liwork,
00057                        bwork, &info );
00058         if( info < 0 ) {
00059             info = info - 1;
00060         }
00061     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00062         lapack_int lda_t = MAX(1,n);
00063         lapack_int ldb_t = MAX(1,n);
00064         lapack_int ldvsl_t = MAX(1,n);
00065         lapack_int ldvsr_t = MAX(1,n);
00066         lapack_complex_double* a_t = NULL;
00067         lapack_complex_double* b_t = NULL;
00068         lapack_complex_double* vsl_t = NULL;
00069         lapack_complex_double* vsr_t = NULL;
00070         /* Check leading dimension(s) */
00071         if( lda < n ) {
00072             info = -9;
00073             LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00074             return info;
00075         }
00076         if( ldb < n ) {
00077             info = -11;
00078             LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00079             return info;
00080         }
00081         if( ldvsl < n ) {
00082             info = -16;
00083             LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00084             return info;
00085         }
00086         if( ldvsr < n ) {
00087             info = -18;
00088             LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00089             return info;
00090         }
00091         /* Query optimal working array(s) size if requested */
00092         if( liwork == -1 || lwork == -1 ) {
00093             LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a,
00094                            &lda_t, b, &ldb_t, sdim, alpha, beta, vsl, &ldvsl_t,
00095                            vsr, &ldvsr_t, rconde, rcondv, work, &lwork, rwork,
00096                            iwork, &liwork, bwork, &info );
00097             return (info < 0) ? (info - 1) : info;
00098         }
00099         /* Allocate memory for temporary array(s) */
00100         a_t = (lapack_complex_double*)
00101             LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
00102         if( a_t == NULL ) {
00103             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00104             goto exit_level_0;
00105         }
00106         b_t = (lapack_complex_double*)
00107             LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
00108         if( b_t == NULL ) {
00109             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00110             goto exit_level_1;
00111         }
00112         if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00113             vsl_t = (lapack_complex_double*)
00114                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00115                                 ldvsl_t * MAX(1,n) );
00116             if( vsl_t == NULL ) {
00117                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00118                 goto exit_level_2;
00119             }
00120         }
00121         if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00122             vsr_t = (lapack_complex_double*)
00123                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00124                                 ldvsr_t * MAX(1,n) );
00125             if( vsr_t == NULL ) {
00126                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00127                 goto exit_level_3;
00128             }
00129         }
00130         /* Transpose input matrices */
00131         LAPACKE_zge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00132         LAPACKE_zge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00133         /* Call LAPACK function and adjust info */
00134         LAPACK_zggesx( &jobvsl, &jobvsr, &sort, selctg, &sense, &n, a_t, &lda_t,
00135                        b_t, &ldb_t, sdim, alpha, beta, vsl_t, &ldvsl_t, vsr_t,
00136                        &ldvsr_t, rconde, rcondv, work, &lwork, rwork, iwork,
00137                        &liwork, bwork, &info );
00138         if( info < 0 ) {
00139             info = info - 1;
00140         }
00141         /* Transpose output matrices */
00142         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
00143         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00144         if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00145             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vsl_t, ldvsl_t, vsl,
00146                                ldvsl );
00147         }
00148         if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00149             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vsr_t, ldvsr_t, vsr,
00150                                ldvsr );
00151         }
00152         /* Release memory and exit */
00153         if( LAPACKE_lsame( jobvsr, 'v' ) ) {
00154             LAPACKE_free( vsr_t );
00155         }
00156 exit_level_3:
00157         if( LAPACKE_lsame( jobvsl, 'v' ) ) {
00158             LAPACKE_free( vsl_t );
00159         }
00160 exit_level_2:
00161         LAPACKE_free( b_t );
00162 exit_level_1:
00163         LAPACKE_free( a_t );
00164 exit_level_0:
00165         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00166             LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00167         }
00168     } else {
00169         info = -1;
00170         LAPACKE_xerbla( "LAPACKE_zggesx_work", info );
00171     }
00172     return info;
00173 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:55