lapacke_chgeqz_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 chgeqz
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_chgeqz_work( int matrix_order, char job, char compq,
00038                                 char compz, lapack_int n, lapack_int ilo,
00039                                 lapack_int ihi, lapack_complex_float* h,
00040                                 lapack_int ldh, lapack_complex_float* t,
00041                                 lapack_int ldt, lapack_complex_float* alpha,
00042                                 lapack_complex_float* beta,
00043                                 lapack_complex_float* q, lapack_int ldq,
00044                                 lapack_complex_float* z, lapack_int ldz,
00045                                 lapack_complex_float* work, lapack_int lwork,
00046                                 float* rwork )
00047 {
00048     lapack_int info = 0;
00049     if( matrix_order == LAPACK_COL_MAJOR ) {
00050         /* Call LAPACK function and adjust info */
00051         LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh, t, &ldt,
00052                        alpha, beta, q, &ldq, z, &ldz, work, &lwork, rwork,
00053                        &info );
00054         if( info < 0 ) {
00055             info = info - 1;
00056         }
00057     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00058         lapack_int ldh_t = MAX(1,n);
00059         lapack_int ldq_t = MAX(1,n);
00060         lapack_int ldt_t = MAX(1,n);
00061         lapack_int ldz_t = MAX(1,n);
00062         lapack_complex_float* h_t = NULL;
00063         lapack_complex_float* t_t = NULL;
00064         lapack_complex_float* q_t = NULL;
00065         lapack_complex_float* z_t = NULL;
00066         /* Check leading dimension(s) */
00067         if( ldh < n ) {
00068             info = -9;
00069             LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00070             return info;
00071         }
00072         if( ldq < n ) {
00073             info = -15;
00074             LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00075             return info;
00076         }
00077         if( ldt < n ) {
00078             info = -11;
00079             LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00080             return info;
00081         }
00082         if( ldz < n ) {
00083             info = -17;
00084             LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00085             return info;
00086         }
00087         /* Query optimal working array(s) size if requested */
00088         if( lwork == -1 ) {
00089             LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h, &ldh_t, t,
00090                            &ldt_t, alpha, beta, q, &ldq_t, z, &ldz_t, work,
00091                            &lwork, rwork, &info );
00092             return (info < 0) ? (info - 1) : info;
00093         }
00094         /* Allocate memory for temporary array(s) */
00095         h_t = (lapack_complex_float*)
00096             LAPACKE_malloc( sizeof(lapack_complex_float) * ldh_t * MAX(1,n) );
00097         if( h_t == NULL ) {
00098             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00099             goto exit_level_0;
00100         }
00101         t_t = (lapack_complex_float*)
00102             LAPACKE_malloc( sizeof(lapack_complex_float) * ldt_t * MAX(1,n) );
00103         if( t_t == NULL ) {
00104             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00105             goto exit_level_1;
00106         }
00107         if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00108             q_t = (lapack_complex_float*)
00109                 LAPACKE_malloc( sizeof(lapack_complex_float) *
00110                                 ldq_t * MAX(1,n) );
00111             if( q_t == NULL ) {
00112                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00113                 goto exit_level_2;
00114             }
00115         }
00116         if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00117             z_t = (lapack_complex_float*)
00118                 LAPACKE_malloc( sizeof(lapack_complex_float) *
00119                                 ldz_t * MAX(1,n) );
00120             if( z_t == NULL ) {
00121                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00122                 goto exit_level_3;
00123             }
00124         }
00125         /* Transpose input matrices */
00126         LAPACKE_cge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t );
00127         LAPACKE_cge_trans( matrix_order, n, n, t, ldt, t_t, ldt_t );
00128         if( LAPACKE_lsame( compq, 'v' ) ) {
00129             LAPACKE_cge_trans( matrix_order, n, n, q, ldq, q_t, ldq_t );
00130         }
00131         if( LAPACKE_lsame( compz, 'v' ) ) {
00132             LAPACKE_cge_trans( matrix_order, n, n, z, ldz, z_t, ldz_t );
00133         }
00134         /* Call LAPACK function and adjust info */
00135         LAPACK_chgeqz( &job, &compq, &compz, &n, &ilo, &ihi, h_t, &ldh_t, t_t,
00136                        &ldt_t, alpha, beta, q_t, &ldq_t, z_t, &ldz_t, work,
00137                        &lwork, rwork, &info );
00138         if( info < 0 ) {
00139             info = info - 1;
00140         }
00141         /* Transpose output matrices */
00142         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, h_t, ldh_t, h, ldh );
00143         LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, t_t, ldt_t, t, ldt );
00144         if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00145             LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00146         }
00147         if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00148             LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00149         }
00150         /* Release memory and exit */
00151         if( LAPACKE_lsame( compz, 'i' ) || LAPACKE_lsame( compz, 'v' ) ) {
00152             LAPACKE_free( z_t );
00153         }
00154 exit_level_3:
00155         if( LAPACKE_lsame( compq, 'i' ) || LAPACKE_lsame( compq, 'v' ) ) {
00156             LAPACKE_free( q_t );
00157         }
00158 exit_level_2:
00159         LAPACKE_free( t_t );
00160 exit_level_1:
00161         LAPACKE_free( h_t );
00162 exit_level_0:
00163         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00164             LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00165         }
00166     } else {
00167         info = -1;
00168         LAPACKE_xerbla( "LAPACKE_chgeqz_work", info );
00169     }
00170     return info;
00171 }


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