lapacke_chsein_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 chsein
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_chsein_work( int matrix_order, char job, char eigsrc,
00038                                 char initv, const lapack_logical* select,
00039                                 lapack_int n, const lapack_complex_float* h,
00040                                 lapack_int ldh, lapack_complex_float* w,
00041                                 lapack_complex_float* vl, lapack_int ldvl,
00042                                 lapack_complex_float* vr, lapack_int ldvr,
00043                                 lapack_int mm, lapack_int* m,
00044                                 lapack_complex_float* work, float* rwork,
00045                                 lapack_int* ifaill, lapack_int* ifailr )
00046 {
00047     lapack_int info = 0;
00048     if( matrix_order == LAPACK_COL_MAJOR ) {
00049         /* Call LAPACK function and adjust info */
00050         LAPACK_chsein( &job, &eigsrc, &initv, select, &n, h, &ldh, w, vl, &ldvl,
00051                        vr, &ldvr, &mm, m, work, rwork, ifaill, ifailr, &info );
00052         if( info < 0 ) {
00053             info = info - 1;
00054         }
00055     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00056         lapack_int ldh_t = MAX(1,n);
00057         lapack_int ldvl_t = MAX(1,n);
00058         lapack_int ldvr_t = MAX(1,n);
00059         lapack_complex_float* h_t = NULL;
00060         lapack_complex_float* vl_t = NULL;
00061         lapack_complex_float* vr_t = NULL;
00062         /* Check leading dimension(s) */
00063         if( ldh < n ) {
00064             info = -8;
00065             LAPACKE_xerbla( "LAPACKE_chsein_work", info );
00066             return info;
00067         }
00068         if( ldvl < mm ) {
00069             info = -11;
00070             LAPACKE_xerbla( "LAPACKE_chsein_work", info );
00071             return info;
00072         }
00073         if( ldvr < mm ) {
00074             info = -13;
00075             LAPACKE_xerbla( "LAPACKE_chsein_work", info );
00076             return info;
00077         }
00078         /* Allocate memory for temporary array(s) */
00079         h_t = (lapack_complex_float*)
00080             LAPACKE_malloc( sizeof(lapack_complex_float) * ldh_t * MAX(1,n) );
00081         if( h_t == NULL ) {
00082             info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00083             goto exit_level_0;
00084         }
00085         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00086             vl_t = (lapack_complex_float*)
00087                 LAPACKE_malloc( sizeof(lapack_complex_float) *
00088                                 ldvl_t * MAX(1,mm) );
00089             if( vl_t == NULL ) {
00090                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00091                 goto exit_level_1;
00092             }
00093         }
00094         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00095             vr_t = (lapack_complex_float*)
00096                 LAPACKE_malloc( sizeof(lapack_complex_float) *
00097                                 ldvr_t * MAX(1,mm) );
00098             if( vr_t == NULL ) {
00099                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100                 goto exit_level_2;
00101             }
00102         }
00103         /* Transpose input matrices */
00104         LAPACKE_cge_trans( matrix_order, n, n, h, ldh, h_t, ldh_t );
00105         if( ( LAPACKE_lsame( job, 'l' ) || LAPACKE_lsame( job, 'b' ) ) &&
00106             LAPACKE_lsame( initv, 'v' ) ) {
00107             LAPACKE_cge_trans( matrix_order, n, mm, vl, ldvl, vl_t, ldvl_t );
00108         }
00109         if( ( LAPACKE_lsame( job, 'r' ) || LAPACKE_lsame( job, 'b' ) ) &&
00110             LAPACKE_lsame( initv, 'v' ) ) {
00111             LAPACKE_cge_trans( matrix_order, n, mm, vr, ldvr, vr_t, ldvr_t );
00112         }
00113         /* Call LAPACK function and adjust info */
00114         LAPACK_chsein( &job, &eigsrc, &initv, select, &n, h_t, &ldh_t, w, vl_t,
00115                        &ldvl_t, vr_t, &ldvr_t, &mm, m, work, rwork, ifaill,
00116                        ifailr, &info );
00117         if( info < 0 ) {
00118             info = info - 1;
00119         }
00120         /* Transpose output matrices */
00121         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00122             LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vl_t, ldvl_t, vl,
00123                                ldvl );
00124         }
00125         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00126             LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, mm, vr_t, ldvr_t, vr,
00127                                ldvr );
00128         }
00129         /* Release memory and exit */
00130         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'r' ) ) {
00131             LAPACKE_free( vr_t );
00132         }
00133 exit_level_2:
00134         if( LAPACKE_lsame( job, 'b' ) || LAPACKE_lsame( job, 'l' ) ) {
00135             LAPACKE_free( vl_t );
00136         }
00137 exit_level_1:
00138         LAPACKE_free( h_t );
00139 exit_level_0:
00140         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00141             LAPACKE_xerbla( "LAPACKE_chsein_work", info );
00142         }
00143     } else {
00144         info = -1;
00145         LAPACKE_xerbla( "LAPACKE_chsein_work", info );
00146     }
00147     return info;
00148 }


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