LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
lapacke_zgbbrd_work.c
Go to the documentation of this file.
1 /*****************************************************************************
2  Copyright (c) 2014, Intel Corp.
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of Intel Corporation nor the names of its contributors
14  may be used to endorse or promote products derived from this software
15  without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27  THE POSSIBILITY OF SUCH DAMAGE.
28 *****************************************************************************
29 * Contents: Native middle-level C interface to LAPACK function zgbbrd
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_zgbbrd_work( int matrix_layout, char vect, lapack_int m,
37  lapack_int n, lapack_int ncc, lapack_int kl,
39  lapack_int ldab, double* d, double* e,
43  lapack_complex_double* work, double* rwork )
44 {
45  lapack_int info = 0;
46  if( matrix_layout == LAPACK_COL_MAJOR ) {
47  /* Call LAPACK function and adjust info */
48  LAPACK_zgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab, &ldab, d, e, q, &ldq,
49  pt, &ldpt, c, &ldc, work, rwork, &info );
50  if( info < 0 ) {
51  info = info - 1;
52  }
53  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
54  lapack_int ldab_t = MAX(1,kl+ku+1);
55  lapack_int ldc_t = MAX(1,m);
56  lapack_int ldpt_t = MAX(1,n);
57  lapack_int ldq_t = MAX(1,m);
58  lapack_complex_double* ab_t = NULL;
59  lapack_complex_double* q_t = NULL;
60  lapack_complex_double* pt_t = NULL;
61  lapack_complex_double* c_t = NULL;
62  /* Check leading dimension(s) */
63  if( ldab < n ) {
64  info = -9;
65  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
66  return info;
67  }
68  if( ldc < ncc ) {
69  info = -17;
70  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
71  return info;
72  }
73  if( ldpt < n ) {
74  info = -15;
75  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
76  return info;
77  }
78  if( ldq < m ) {
79  info = -13;
80  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
81  return info;
82  }
83  /* Allocate memory for temporary array(s) */
84  ab_t = (lapack_complex_double*)
85  LAPACKE_malloc( sizeof(lapack_complex_double) * ldab_t * MAX(1,n) );
86  if( ab_t == NULL ) {
88  goto exit_level_0;
89  }
90  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
91  q_t = (lapack_complex_double*)
93  ldq_t * MAX(1,m) );
94  if( q_t == NULL ) {
96  goto exit_level_1;
97  }
98  }
99  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
100  pt_t = (lapack_complex_double*)
102  ldpt_t * MAX(1,n) );
103  if( pt_t == NULL ) {
105  goto exit_level_2;
106  }
107  }
108  if( ncc != 0 ) {
109  c_t = (lapack_complex_double*)
111  ldc_t * MAX(1,ncc) );
112  if( c_t == NULL ) {
114  goto exit_level_3;
115  }
116  }
117  /* Transpose input matrices */
118  LAPACKE_zgb_trans( matrix_layout, m, n, kl, ku, ab, ldab, ab_t, ldab_t );
119  if( ncc != 0 ) {
120  LAPACKE_zge_trans( matrix_layout, m, ncc, c, ldc, c_t, ldc_t );
121  }
122  /* Call LAPACK function and adjust info */
123  LAPACK_zgbbrd( &vect, &m, &n, &ncc, &kl, &ku, ab_t, &ldab_t, d, e, q_t,
124  &ldq_t, pt_t, &ldpt_t, c_t, &ldc_t, work, rwork, &info );
125  if( info < 0 ) {
126  info = info - 1;
127  }
128  /* Transpose output matrices */
129  LAPACKE_zgb_trans( LAPACK_COL_MAJOR, m, n, kl, ku, ab_t, ldab_t, ab,
130  ldab );
131  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
132  LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, m, q_t, ldq_t, q, ldq );
133  }
134  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
135  LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, n, pt_t, ldpt_t, pt, ldpt );
136  }
137  if( ncc != 0 ) {
138  LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, ncc, c_t, ldc_t, c, ldc );
139  }
140  /* Release memory and exit */
141  if( ncc != 0 ) {
142  LAPACKE_free( c_t );
143  }
144 exit_level_3:
145  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
146  LAPACKE_free( pt_t );
147  }
148 exit_level_2:
149  if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'q' ) ) {
150  LAPACKE_free( q_t );
151  }
152 exit_level_1:
153  LAPACKE_free( ab_t );
154 exit_level_0:
155  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
156  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
157  }
158  } else {
159  info = -1;
160  LAPACKE_xerbla( "LAPACKE_zgbbrd_work", info );
161  }
162  return info;
163 }
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123
void LAPACKE_zgb_trans(int matrix_layout, lapack_int m, lapack_int n, lapack_int kl, lapack_int ku, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
void LAPACKE_zge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
#define lapack_int
Definition: lapacke.h:47
#define lapack_complex_double
Definition: lapacke.h:90
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:36
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
#define LAPACKE_free(p)
Definition: lapacke.h:113
void LAPACKE_xerbla(const char *name, lapack_int info)
lapack_int LAPACKE_zgbbrd_work(int matrix_layout, char vect, lapack_int m, lapack_int n, lapack_int ncc, lapack_int kl, lapack_int ku, lapack_complex_double *ab, lapack_int ldab, double *d, double *e, lapack_complex_double *q, lapack_int ldq, lapack_complex_double *pt, lapack_int ldpt, lapack_complex_double *c, lapack_int ldc, lapack_complex_double *work, double *rwork)
void LAPACK_zgbbrd(char *vect, lapack_int *m, lapack_int *n, lapack_int *ncc, lapack_int *kl, lapack_int *ku, lapack_complex_double *ab, lapack_int *ldab, double *d, double *e, lapack_complex_double *q, lapack_int *ldq, lapack_complex_double *pt, lapack_int *ldpt, lapack_complex_double *c, lapack_int *ldc, lapack_complex_double *work, double *rwork, lapack_int *info)