lapacke_zggevx_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 zggevx
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_zggevx_work( int matrix_order, char balanc, char jobvl,
00038                                 char jobvr, char sense, lapack_int n,
00039                                 lapack_complex_double* a, lapack_int lda,
00040                                 lapack_complex_double* b, lapack_int ldb,
00041                                 lapack_complex_double* alpha,
00042                                 lapack_complex_double* beta,
00043                                 lapack_complex_double* vl, lapack_int ldvl,
00044                                 lapack_complex_double* vr, lapack_int ldvr,
00045                                 lapack_int* ilo, lapack_int* ihi,
00046                                 double* lscale, double* rscale, double* abnrm,
00047                                 double* bbnrm, double* rconde, double* rcondv,
00048                                 lapack_complex_double* work, lapack_int lwork,
00049                                 double* rwork, lapack_int* iwork,
00050                                 lapack_logical* bwork )
00051 {
00052     lapack_int info = 0;
00053     if( matrix_order == LAPACK_COL_MAJOR ) {
00054         /* Call LAPACK function and adjust info */
00055         LAPACK_zggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda, b, &ldb,
00056                        alpha, beta, vl, &ldvl, vr, &ldvr, ilo, ihi, lscale,
00057                        rscale, abnrm, bbnrm, rconde, rcondv, work, &lwork,
00058                        rwork, iwork, bwork, &info );
00059         if( info < 0 ) {
00060             info = info - 1;
00061         }
00062     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00063         lapack_int lda_t = MAX(1,n);
00064         lapack_int ldb_t = MAX(1,n);
00065         lapack_int ldvl_t = MAX(1,n);
00066         lapack_int ldvr_t = MAX(1,n);
00067         lapack_complex_double* a_t = NULL;
00068         lapack_complex_double* b_t = NULL;
00069         lapack_complex_double* vl_t = NULL;
00070         lapack_complex_double* vr_t = NULL;
00071         /* Check leading dimension(s) */
00072         if( lda < n ) {
00073             info = -8;
00074             LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00075             return info;
00076         }
00077         if( ldb < n ) {
00078             info = -10;
00079             LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00080             return info;
00081         }
00082         if( ldvl < n ) {
00083             info = -14;
00084             LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00085             return info;
00086         }
00087         if( ldvr < n ) {
00088             info = -16;
00089             LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00090             return info;
00091         }
00092         /* Query optimal working array(s) size if requested */
00093         if( lwork == -1 ) {
00094             LAPACK_zggevx( &balanc, &jobvl, &jobvr, &sense, &n, a, &lda_t, b,
00095                            &ldb_t, alpha, beta, vl, &ldvl_t, vr, &ldvr_t, ilo,
00096                            ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv,
00097                            work, &lwork, rwork, iwork, bwork, &info );
00098             return (info < 0) ? (info - 1) : info;
00099         }
00100         /* Allocate memory for temporary array(s) */
00101         a_t = (lapack_complex_double*)
00102             LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
00103         if( a_t == NULL ) {
00104             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00105             goto exit_level_0;
00106         }
00107         b_t = (lapack_complex_double*)
00108             LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
00109         if( b_t == NULL ) {
00110             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00111             goto exit_level_1;
00112         }
00113         if( LAPACKE_lsame( jobvl, 'v' ) ) {
00114             vl_t = (lapack_complex_double*)
00115                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00116                                 ldvl_t * MAX(1,n) );
00117             if( vl_t == NULL ) {
00118                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00119                 goto exit_level_2;
00120             }
00121         }
00122         if( LAPACKE_lsame( jobvr, 'v' ) ) {
00123             vr_t = (lapack_complex_double*)
00124                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00125                                 ldvr_t * MAX(1,n) );
00126             if( vr_t == NULL ) {
00127                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00128                 goto exit_level_3;
00129             }
00130         }
00131         /* Transpose input matrices */
00132         LAPACKE_zge_trans( matrix_order, n, n, a, lda, a_t, lda_t );
00133         LAPACKE_zge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00134         /* Call LAPACK function and adjust info */
00135         LAPACK_zggevx( &balanc, &jobvl, &jobvr, &sense, &n, a_t, &lda_t, b_t,
00136                        &ldb_t, alpha, beta, vl_t, &ldvl_t, vr_t, &ldvr_t, ilo,
00137                        ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work,
00138                        &lwork, rwork, iwork, bwork, &info );
00139         if( info < 0 ) {
00140             info = info - 1;
00141         }
00142         /* Transpose output matrices */
00143         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
00144         LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, b_t, ldb_t, b, ldb );
00145         if( LAPACKE_lsame( jobvl, 'v' ) ) {
00146             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vl_t, ldvl_t, vl, ldvl );
00147         }
00148         if( LAPACKE_lsame( jobvr, 'v' ) ) {
00149             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, vr_t, ldvr_t, vr, ldvr );
00150         }
00151         /* Release memory and exit */
00152         if( LAPACKE_lsame( jobvr, 'v' ) ) {
00153             LAPACKE_free( vr_t );
00154         }
00155 exit_level_3:
00156         if( LAPACKE_lsame( jobvl, 'v' ) ) {
00157             LAPACKE_free( vl_t );
00158         }
00159 exit_level_2:
00160         LAPACKE_free( b_t );
00161 exit_level_1:
00162         LAPACKE_free( a_t );
00163 exit_level_0:
00164         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00165             LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00166         }
00167     } else {
00168         info = -1;
00169         LAPACKE_xerbla( "LAPACKE_zggevx_work", info );
00170     }
00171     return info;
00172 }


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