lapacke_ctgsyl_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 ctgsyl
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_ctgsyl_work( int matrix_order, char trans, lapack_int ijob,
00038                                 lapack_int m, lapack_int n,
00039                                 const lapack_complex_float* a, lapack_int lda,
00040                                 const lapack_complex_float* b, lapack_int ldb,
00041                                 lapack_complex_float* c, lapack_int ldc,
00042                                 const lapack_complex_float* d, lapack_int ldd,
00043                                 const lapack_complex_float* e, lapack_int lde,
00044                                 lapack_complex_float* f, lapack_int ldf,
00045                                 float* scale, float* dif,
00046                                 lapack_complex_float* work, lapack_int lwork,
00047                                 lapack_int* iwork )
00048 {
00049     lapack_int info = 0;
00050     if( matrix_order == LAPACK_COL_MAJOR ) {
00051         /* Call LAPACK function and adjust info */
00052         LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d,
00053                        &ldd, e, &lde, f, &ldf, scale, dif, work, &lwork, iwork,
00054                        &info );
00055         if( info < 0 ) {
00056             info = info - 1;
00057         }
00058     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00059         lapack_int lda_t = MAX(1,m);
00060         lapack_int ldb_t = MAX(1,n);
00061         lapack_int ldc_t = MAX(1,m);
00062         lapack_int ldd_t = MAX(1,m);
00063         lapack_int lde_t = MAX(1,n);
00064         lapack_int ldf_t = MAX(1,m);
00065         lapack_complex_float* a_t = NULL;
00066         lapack_complex_float* b_t = NULL;
00067         lapack_complex_float* c_t = NULL;
00068         lapack_complex_float* d_t = NULL;
00069         lapack_complex_float* e_t = NULL;
00070         lapack_complex_float* f_t = NULL;
00071         /* Check leading dimension(s) */
00072         if( lda < m ) {
00073             info = -7;
00074             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00075             return info;
00076         }
00077         if( ldb < n ) {
00078             info = -9;
00079             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00080             return info;
00081         }
00082         if( ldc < n ) {
00083             info = -11;
00084             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00085             return info;
00086         }
00087         if( ldd < m ) {
00088             info = -13;
00089             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00090             return info;
00091         }
00092         if( lde < n ) {
00093             info = -15;
00094             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00095             return info;
00096         }
00097         if( ldf < n ) {
00098             info = -17;
00099             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00100             return info;
00101         }
00102         /* Query optimal working array(s) size if requested */
00103         if( lwork == -1 ) {
00104             LAPACK_ctgsyl( &trans, &ijob, &m, &n, a, &lda_t, b, &ldb_t, c,
00105                            &ldc_t, d, &ldd_t, e, &lde_t, f, &ldf_t, scale, dif,
00106                            work, &lwork, iwork, &info );
00107             return (info < 0) ? (info - 1) : info;
00108         }
00109         /* Allocate memory for temporary array(s) */
00110         a_t = (lapack_complex_float*)
00111             LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,m) );
00112         if( a_t == NULL ) {
00113             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00114             goto exit_level_0;
00115         }
00116         b_t = (lapack_complex_float*)
00117             LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) );
00118         if( b_t == NULL ) {
00119             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00120             goto exit_level_1;
00121         }
00122         c_t = (lapack_complex_float*)
00123             LAPACKE_malloc( sizeof(lapack_complex_float) * ldc_t * MAX(1,n) );
00124         if( c_t == NULL ) {
00125             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00126             goto exit_level_2;
00127         }
00128         d_t = (lapack_complex_float*)
00129             LAPACKE_malloc( sizeof(lapack_complex_float) * ldd_t * MAX(1,m) );
00130         if( d_t == NULL ) {
00131             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00132             goto exit_level_3;
00133         }
00134         e_t = (lapack_complex_float*)
00135             LAPACKE_malloc( sizeof(lapack_complex_float) * lde_t * MAX(1,n) );
00136         if( e_t == NULL ) {
00137             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00138             goto exit_level_4;
00139         }
00140         f_t = (lapack_complex_float*)
00141             LAPACKE_malloc( sizeof(lapack_complex_float) * ldf_t * MAX(1,n) );
00142         if( f_t == NULL ) {
00143             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00144             goto exit_level_5;
00145         }
00146         /* Transpose input matrices */
00147         LAPACKE_cge_trans( matrix_order, m, m, a, lda, a_t, lda_t );
00148         LAPACKE_cge_trans( matrix_order, n, n, b, ldb, b_t, ldb_t );
00149         LAPACKE_cge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t );
00150         LAPACKE_cge_trans( matrix_order, m, m, d, ldd, d_t, ldd_t );
00151         LAPACKE_cge_trans( matrix_order, n, n, e, lde, e_t, lde_t );
00152         LAPACKE_cge_trans( matrix_order, m, n, f, ldf, f_t, ldf_t );
00153         /* Call LAPACK function and adjust info */
00154         LAPACK_ctgsyl( &trans, &ijob, &m, &n, a_t, &lda_t, b_t, &ldb_t, c_t,
00155                        &ldc_t, d_t, &ldd_t, e_t, &lde_t, f_t, &ldf_t, scale,
00156                        dif, work, &lwork, iwork, &info );
00157         if( info < 0 ) {
00158             info = info - 1;
00159         }
00160         /* Transpose output matrices */
00161         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
00162         LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, f_t, ldf_t, f, ldf );
00163         /* Release memory and exit */
00164         LAPACKE_free( f_t );
00165 exit_level_5:
00166         LAPACKE_free( e_t );
00167 exit_level_4:
00168         LAPACKE_free( d_t );
00169 exit_level_3:
00170         LAPACKE_free( c_t );
00171 exit_level_2:
00172         LAPACKE_free( b_t );
00173 exit_level_1:
00174         LAPACKE_free( a_t );
00175 exit_level_0:
00176         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00177             LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00178         }
00179     } else {
00180         info = -1;
00181         LAPACKE_xerbla( "LAPACKE_ctgsyl_work", info );
00182     }
00183     return info;
00184 }


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