lapacke_zgbbrd_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 zgbbrd
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_zgbbrd_work( int matrix_order, char vect, lapack_int m,
00038                                 lapack_int n, lapack_int ncc, lapack_int kl,
00039                                 lapack_int ku, lapack_complex_double* ab,
00040                                 lapack_int ldab, double* d, double* e,
00041                                 lapack_complex_double* q, lapack_int ldq,
00042                                 lapack_complex_double* pt, lapack_int ldpt,
00043                                 lapack_complex_double* c, lapack_int ldc,
00044                                 lapack_complex_double* work, double* rwork )
00045 {
00046     lapack_int info = 0;
00047     if( matrix_order == LAPACK_COL_MAJOR ) {
00048         /* Call LAPACK function and adjust info */
00049         LAPACK_zgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab, &ldab, d, e, q, &ldq,
00050                        pt, &ldpt, c, &ldc, work, rwork, &info );
00051         if( info < 0 ) {
00052             info = info - 1;
00053         }
00054     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00055         lapack_int ldab_t = MAX(1,kl+ku+1);
00056         lapack_int ldc_t = MAX(1,m);
00057         lapack_int ldpt_t = MAX(1,n);
00058         lapack_int ldq_t = MAX(1,m);
00059         lapack_complex_double* ab_t = NULL;
00060         lapack_complex_double* q_t = NULL;
00061         lapack_complex_double* pt_t = NULL;
00062         lapack_complex_double* c_t = NULL;
00063         /* Check leading dimension(s) */
00064         if( ldab < n ) {
00065             info = -9;
00066             LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00067             return info;
00068         }
00069         if( ldc < ncc ) {
00070             info = -17;
00071             LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00072             return info;
00073         }
00074         if( ldpt < n ) {
00075             info = -15;
00076             LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00077             return info;
00078         }
00079         if( ldq < m ) {
00080             info = -13;
00081             LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00082             return info;
00083         }
00084         /* Allocate memory for temporary array(s) */
00085         ab_t = (lapack_complex_double*)
00086             LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) );
00087         if( ab_t == NULL ) {
00088             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00089             goto exit_level_0;
00090         }
00091         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00092             q_t = (lapack_complex_double*)
00093                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00094                                 ldq_t * MAX(1,m) );
00095             if( q_t == NULL ) {
00096                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00097                 goto exit_level_1;
00098             }
00099         }
00100         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00101             pt_t = (lapack_complex_double*)
00102                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00103                                 ldpt_t * MAX(1,n) );
00104             if( pt_t == NULL ) {
00105                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00106                 goto exit_level_2;
00107             }
00108         }
00109         if( ncc != 0 ) {
00110             c_t = (lapack_complex_double*)
00111                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00112                                 ldc_t * MAX(1,ncc) );
00113             if( c_t == NULL ) {
00114                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00115                 goto exit_level_3;
00116             }
00117         }
00118         /* Transpose input matrices */
00119         LAPACKE_zgb_trans( matrix_order, m, n, kl, ku, ab, ldab, ab_t, ldab_t );
00120         if( ncc != 0 ) {
00121             LAPACKE_zge_trans( matrix_order, m, ncc, c, ldc, c_t, ldc_t );
00122         }
00123         /* Call LAPACK function and adjust info */
00124         LAPACK_zgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab_t, &ldab_t, d, e, q_t,
00125                        &ldq_t, pt_t, &ldpt_t, c_t, &ldc_t, work, rwork, &info );
00126         if( info < 0 ) {
00127             info = info - 1;
00128         }
00129         /* Transpose output matrices */
00130         LAPACKE_zgb_trans( LAPACK_COL_MAJOR, m, n, kl, ku, ab_t, ldab_t, ab,
00131                            ldab );
00132         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00133             LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, q_t, ldq_t, q, ldq );
00134         }
00135         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00136             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, pt_t, ldpt_t, pt, ldpt );
00137         }
00138         if( ncc != 0 ) {
00139             LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, ncc, c_t, ldc_t, c, ldc );
00140         }
00141         /* Release memory and exit */
00142         if( ncc != 0 ) {
00143             LAPACKE_free( c_t );
00144         }
00145 exit_level_3:
00146         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
00147             LAPACKE_free( pt_t );
00148         }
00149 exit_level_2:
00150         if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
00151             LAPACKE_free( q_t );
00152         }
00153 exit_level_1:
00154         LAPACKE_free( ab_t );
00155 exit_level_0:
00156         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00157             LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00158         }
00159     } else {
00160         info = -1;
00161         LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
00162     }
00163     return info;
00164 }


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