lapacke_zbdsqr_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 zbdsqr
00030 * Author: Intel Corporation
00031 * Generated October, 2010
00032 *****************************************************************************/
00033 
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036 
00037 lapack_int LAPACKE_zbdsqr_work( int matrix_order, char uplo, lapack_int n,
00038                                 lapack_int ncvt, lapack_int nru, lapack_int ncc,
00039                                 double* d, double* e, lapack_complex_double* vt,
00040                                 lapack_int ldvt, lapack_complex_double* u,
00041                                 lapack_int ldu, lapack_complex_double* c,
00042                                 lapack_int ldc, double* work )
00043 {
00044     lapack_int info = 0;
00045     if( matrix_order == LAPACK_COL_MAJOR ) {
00046         /* Call LAPACK function and adjust info */
00047         LAPACK_zbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt, &ldvt, u, &ldu,
00048                        c, &ldc, work, &info );
00049         if( info < 0 ) {
00050             info = info - 1;
00051         }
00052     } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00053         lapack_int ldc_t = MAX(1,n);
00054         lapack_int ldu_t = MAX(1,nru);
00055         lapack_int ldvt_t = MAX(1,n);
00056         lapack_complex_double* vt_t = NULL;
00057         lapack_complex_double* u_t = NULL;
00058         lapack_complex_double* c_t = NULL;
00059         /* Check leading dimension(s) */
00060         if( ldc < ncc ) {
00061             info = -14;
00062             LAPACKE_xerbla( "LAPACKE_zbdsqr_work", info );
00063             return info;
00064         }
00065         if( ldu < n ) {
00066             info = -12;
00067             LAPACKE_xerbla( "LAPACKE_zbdsqr_work", info );
00068             return info;
00069         }
00070         if( ldvt < ncvt ) {
00071             info = -10;
00072             LAPACKE_xerbla( "LAPACKE_zbdsqr_work", info );
00073             return info;
00074         }
00075         /* Allocate memory for temporary array(s) */
00076         if( ncvt != 0 ) {
00077             vt_t = (lapack_complex_double*)
00078                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00079                                 ldvt_t * MAX(1,ncvt) );
00080             if( vt_t == NULL ) {
00081                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00082                 goto exit_level_0;
00083             }
00084         }
00085         if( nru != 0 ) {
00086             u_t = (lapack_complex_double*)
00087                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00088                                 ldu_t * MAX(1,n) );
00089             if( u_t == NULL ) {
00090                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00091                 goto exit_level_1;
00092             }
00093         }
00094         if( ncc != 0 ) {
00095             c_t = (lapack_complex_double*)
00096                 LAPACKE_malloc( sizeof(lapack_complex_double) *
00097                                 ldc_t * MAX(1,ncc) );
00098             if( c_t == NULL ) {
00099                 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100                 goto exit_level_2;
00101             }
00102         }
00103         /* Transpose input matrices */
00104         if( ncvt != 0 ) {
00105             LAPACKE_zge_trans( matrix_order, n, ncvt, vt, ldvt, vt_t, ldvt_t );
00106         }
00107         if( nru != 0 ) {
00108             LAPACKE_zge_trans( matrix_order, nru, n, u, ldu, u_t, ldu_t );
00109         }
00110         if( ncc != 0 ) {
00111             LAPACKE_zge_trans( matrix_order, n, ncc, c, ldc, c_t, ldc_t );
00112         }
00113         /* Call LAPACK function and adjust info */
00114         LAPACK_zbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt_t, &ldvt_t, u_t,
00115                        &ldu_t, c_t, &ldc_t, work, &info );
00116         if( info < 0 ) {
00117             info = info - 1;
00118         }
00119         /* Transpose output matrices */
00120         if( ncvt != 0 ) {
00121             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncvt, vt_t, ldvt_t, vt,
00122                                ldvt );
00123         }
00124         if( nru != 0 ) {
00125             LAPACKE_zge_trans( LAPACK_COL_MAJOR, nru, n, u_t, ldu_t, u, ldu );
00126         }
00127         if( ncc != 0 ) {
00128             LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, ncc, c_t, ldc_t, c, ldc );
00129         }
00130         /* Release memory and exit */
00131         if( ncc != 0 ) {
00132             LAPACKE_free( c_t );
00133         }
00134 exit_level_2:
00135         if( nru != 0 ) {
00136             LAPACKE_free( u_t );
00137         }
00138 exit_level_1:
00139         if( ncvt != 0 ) {
00140             LAPACKE_free( vt_t );
00141         }
00142 exit_level_0:
00143         if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00144             LAPACKE_xerbla( "LAPACKE_zbdsqr_work", info );
00145         }
00146     } else {
00147         info = -1;
00148         LAPACKE_xerbla( "LAPACKE_zbdsqr_work", info );
00149     }
00150     return info;
00151 }


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