lapacke_zggsvd_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 zggsvd
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_zggsvd_work( int matrix_order, char jobu, char jobv,
00038                                 char jobq, lapack_int m, lapack_int n,
00039                                 lapack_int p, lapack_int* k, lapack_int* l,
00040                                 lapack_complex_double* a, lapack_int lda,
00041                                 lapack_complex_double* b, lapack_int ldb,
00042                                 double* alpha, double* beta,
00043                                 lapack_complex_double* u, lapack_int ldu,
00044                                 lapack_complex_double* v, lapack_int ldv,
00045                                 lapack_complex_double* q, lapack_int ldq,
00046                                 lapack_complex_double* work, double* rwork,
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_zggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
00053                        alpha, beta, u, &ldu, v, &ldv, q, &ldq, work, rwork,
00054                        iwork, &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_zggsvd_work", info );
00073             return info;
00074         }
00075         if( ldb < n ) {
00076             info = -13;
00077             LAPACKE_xerbla( "LAPACKE_zggsvd_work", info );
00078             return info;
00079         }
00080         if( ldq < n ) {
00081             info = -21;
00082             LAPACKE_xerbla( "LAPACKE_zggsvd_work", info );
00083             return info;
00084         }
00085         if( ldu < m ) {
00086             info = -17;
00087             LAPACKE_xerbla( "LAPACKE_zggsvd_work", info );
00088             return info;
00089         }
00090         if( ldv < p ) {
00091             info = -19;
00092             LAPACKE_xerbla( "LAPACKE_zggsvd_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, '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, '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, '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         /* Call LAPACK function and adjust info */
00139         LAPACK_zggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a_t, &lda_t, b_t,
00140                        &ldb_t, alpha, beta, u_t, &ldu_t, v_t, &ldv_t, q_t,
00141                        &ldq_t, work, rwork, iwork, &info );
00142         if( info < 0 ) {
00143             info = info - 1;
00144         }
00145         /* Transpose output matrices */
00146         LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, a_t, lda_t, a, lda );
00147         LAPACKE_zge_trans( LAPACK_COL_MAJOR, p, n, b_t, ldb_t, b, ldb );
00148         if( LAPACKE_lsame( jobu, 'u' ) ) {
00149             LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, u_t, ldu_t, u, ldu );
00150         }
00151         if( LAPACKE_lsame( jobv, 'v' ) ) {
00152             LAPACKE_zge_trans( LAPACK_COL_MAJOR, p, p, v_t, ldv_t, v, ldv );
00153         }
00154         if( LAPACKE_lsame( jobq, 'q' ) ) {
00155             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq );
00156         }
00157         /* Release memory and exit */
00158         if( LAPACKE_lsame( jobq, 'q' ) ) {
00159             LAPACKE_free( q_t );
00160         }
00161 exit_level_4:
00162         if( LAPACKE_lsame( jobv, 'v' ) ) {
00163             LAPACKE_free( v_t );
00164         }
00165 exit_level_3:
00166         if( LAPACKE_lsame( jobu, 'u' ) ) {
00167             LAPACKE_free( u_t );
00168         }
00169 exit_level_2:
00170         LAPACKE_free( b_t );
00171 exit_level_1:
00172         LAPACKE_free( a_t );
00173 exit_level_0:
00174         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00175             LAPACKE_xerbla( "LAPACKE_zggsvd_work", info );
00176         }
00177     } else {
00178         info = -1;
00179         LAPACKE_xerbla( "LAPACKE_zggsvd_work", info );
00180     }
00181     return info;
00182 }


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