lapacke_ztgsja_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 ztgsja
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_ztgsja_work( int matrix_order, char jobu, char jobv,
00038                                 char jobq, lapack_int m, lapack_int p,
00039                                 lapack_int n, lapack_int k, lapack_int l,
00040                                 lapack_complex_double* a, lapack_int lda,
00041                                 lapack_complex_double* b, lapack_int ldb,
00042                                 double tola, double tolb, double* alpha,
00043                                 double* beta, lapack_complex_double* u,
00044                                 lapack_int ldu, lapack_complex_double* v,
00045                                 lapack_int ldv, lapack_complex_double* q,
00046                                 lapack_int ldq, lapack_complex_double* work,
00047                                 lapack_int* ncycle )
00048 {
00049     lapack_int info = 0;
00050     if( matrix_order == LAPACK_COL_MAJOR ) {
00051         /* Call LAPACK function and adjust info */
00052         LAPACK_ztgsja( &jobu, &jobv, &jobq, &m, &p, &n, &k, &l, a, &lda, b,
00053                        &ldb, &tola, &tolb, alpha, beta, u, &ldu, v, &ldv, q,
00054                        &ldq, work, ncycle, &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,p);
00061         lapack_int ldq_t = MAX(1,n);
00062         lapack_int ldu_t = MAX(1,m);
00063         lapack_int ldv_t = MAX(1,p);
00064         lapack_complex_double* a_t = NULL;
00065         lapack_complex_double* b_t = NULL;
00066         lapack_complex_double* u_t = NULL;
00067         lapack_complex_double* v_t = NULL;
00068         lapack_complex_double* q_t = NULL;
00069         /* Check leading dimension(s) */
00070         if( lda < n ) {
00071             info = -11;
00072             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00073             return info;
00074         }
00075         if( ldb < n ) {
00076             info = -13;
00077             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00078             return info;
00079         }
00080         if( ldq < n ) {
00081             info = -23;
00082             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00083             return info;
00084         }
00085         if( ldu < m ) {
00086             info = -19;
00087             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00088             return info;
00089         }
00090         if( ldv < p ) {
00091             info = -21;
00092             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00093             return info;
00094         }
00095         /* Allocate memory for temporary array(s) */
00096         a_t = (lapack_complex_double*)
00097             LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
00098         if( a_t == NULL ) {
00099             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100             goto exit_level_0;
00101         }
00102         b_t = (lapack_complex_double*)
00103             LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
00104         if( b_t == NULL ) {
00105             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00106             goto exit_level_1;
00107         }
00108         if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00109             u_t = (lapack_complex_double*)
00110                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00111                                 ldu_t * MAX(1,m) );
00112             if( u_t == NULL ) {
00113                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00114                 goto exit_level_2;
00115             }
00116         }
00117         if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00118             v_t = (lapack_complex_double*)
00119                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00120                                 ldv_t * MAX(1,p) );
00121             if( v_t == NULL ) {
00122                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00123                 goto exit_level_3;
00124             }
00125         }
00126         if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00127             q_t = (lapack_complex_double*)
00128                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00129                                 ldq_t * MAX(1,n) );
00130             if( q_t == NULL ) {
00131                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00132                 goto exit_level_4;
00133             }
00134         }
00135         /* Transpose input matrices */
00136         LAPACKE_zge_trans( matrix_order, m, n, a, lda, a_t, lda_t );
00137         LAPACKE_zge_trans( matrix_order, p, n, b, ldb, b_t, ldb_t );
00138         if( LAPACKE_lsame( jobu, 'u' ) ) {
00139             LAPACKE_zge_trans( matrix_order, m, m, u, ldu, u_t, ldu_t );
00140         }
00141         if( LAPACKE_lsame( jobv, 'v' ) ) {
00142             LAPACKE_zge_trans( matrix_order, p, p, v, ldv, v_t, ldv_t );
00143         }
00144         if( LAPACKE_lsame( jobq, 'q' ) ) {
00145             LAPACKE_zge_trans( matrix_order, n, n, q, ldq, q_t, ldq_t );
00146         }
00147         /* Call LAPACK function and adjust info */
00148         LAPACK_ztgsja( &jobu, &jobv, &jobq, &m, &p, &n, &k, &l, a_t, &lda_t,
00149                        b_t, &ldb_t, &tola, &tolb, alpha, beta, u_t, &ldu_t, v_t,
00150                        &ldv_t, q_t, &ldq_t, work, ncycle, &info );
00151         if( info < 0 ) {
00152             info = info - 1;
00153         }
00154         /* Transpose output matrices */
00155         LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
00156         LAPACKE_zge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
00157         if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00158             LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
00159         }
00160         if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00161             LAPACKE_zge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv );
00162         }
00163         if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00164             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00165         }
00166         /* Release memory and exit */
00167         if( LAPACKE_lsame( jobq, 'i' ) || LAPACKE_lsame( jobq, 'q' ) ) {
00168             LAPACKE_free( q_t );
00169         }
00170 exit_level_4:
00171         if( LAPACKE_lsame( jobv, 'i' ) || LAPACKE_lsame( jobv, 'v' ) ) {
00172             LAPACKE_free( v_t );
00173         }
00174 exit_level_3:
00175         if( LAPACKE_lsame( jobu, 'i' ) || LAPACKE_lsame( jobu, 'u' ) ) {
00176             LAPACKE_free( u_t );
00177         }
00178 exit_level_2:
00179         LAPACKE_free( b_t );
00180 exit_level_1:
00181         LAPACKE_free( a_t );
00182 exit_level_0:
00183         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00184             LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00185         }
00186     } else {
00187         info = -1;
00188         LAPACKE_xerbla( "LAPACKE_ztgsja_work", info );
00189     }
00190     return info;
00191 }


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