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


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