|
| 1 | +#include "lapacke_utils.h" |
| 2 | + |
| 3 | +lapack_int LAPACKE_ctrsyl3_work( int matrix_layout, char trana, char tranb, |
| 4 | + lapack_int isgn, lapack_int m, lapack_int n, |
| 5 | + const lapack_complex_float* a, lapack_int lda, |
| 6 | + const lapack_complex_float* b, lapack_int ldb, |
| 7 | + lapack_complex_float* c, lapack_int ldc, |
| 8 | + float* scale, float* swork, |
| 9 | + lapack_int ldswork ) |
| 10 | +{ |
| 11 | + lapack_int info = 0; |
| 12 | + if( matrix_layout == LAPACK_COL_MAJOR ) { |
| 13 | + /* Call LAPACK function and adjust info */ |
| 14 | + LAPACK_ctrsyl3( &trana, &tranb, &isgn, &m, &n, a, &lda, b, &ldb, c, &ldc, |
| 15 | + scale, swork, &ldswork, &info ); |
| 16 | + if( info < 0 ) { |
| 17 | + info = info - 1; |
| 18 | + } |
| 19 | + } else if( matrix_layout == LAPACK_ROW_MAJOR ) { |
| 20 | + lapack_int lda_t = MAX(1,m); |
| 21 | + lapack_int ldb_t = MAX(1,n); |
| 22 | + lapack_int ldc_t = MAX(1,m); |
| 23 | + lapack_complex_float* a_t = NULL; |
| 24 | + lapack_complex_float* b_t = NULL; |
| 25 | + lapack_complex_float* c_t = NULL; |
| 26 | + /* Check leading dimension(s) */ |
| 27 | + if( lda < m ) { |
| 28 | + info = -8; |
| 29 | + LAPACKE_xerbla( "LAPACKE_ctrsyl3_work", info ); |
| 30 | + return info; |
| 31 | + } |
| 32 | + if( ldb < n ) { |
| 33 | + info = -10; |
| 34 | + LAPACKE_xerbla( "LAPACKE_ctrsyl3_work", info ); |
| 35 | + return info; |
| 36 | + } |
| 37 | + if( ldc < n ) { |
| 38 | + info = -12; |
| 39 | + LAPACKE_xerbla( "LAPACKE_ctrsyl3_work", info ); |
| 40 | + return info; |
| 41 | + } |
| 42 | + /* Allocate memory for temporary array(s) */ |
| 43 | + a_t = (lapack_complex_float*) |
| 44 | + LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,m) ); |
| 45 | + if( a_t == NULL ) { |
| 46 | + info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 47 | + goto exit_level_0; |
| 48 | + } |
| 49 | + b_t = (lapack_complex_float*) |
| 50 | + LAPACKE_malloc( sizeof(lapack_complex_float) * ldb_t * MAX(1,n) ); |
| 51 | + if( b_t == NULL ) { |
| 52 | + info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 53 | + goto exit_level_1; |
| 54 | + } |
| 55 | + c_t = (lapack_complex_float*) |
| 56 | + LAPACKE_malloc( sizeof(lapack_complex_float) * ldc_t * MAX(1,n) ); |
| 57 | + if( c_t == NULL ) { |
| 58 | + info = LAPACK_TRANSPOSE_MEMORY_ERROR; |
| 59 | + goto exit_level_2; |
| 60 | + } |
| 61 | + /* Transpose input matrices */ |
| 62 | + LAPACKE_cge_trans( matrix_layout, m, m, a, lda, a_t, lda_t ); |
| 63 | + LAPACKE_cge_trans( matrix_layout, n, n, b, ldb, b_t, ldb_t ); |
| 64 | + LAPACKE_cge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t ); |
| 65 | + /* Call LAPACK function and adjust info */ |
| 66 | + LAPACK_ctrsyl3( &trana, &tranb, &isgn, &m, &n, a_t, &lda_t, b_t, &ldb_t, |
| 67 | + c_t, &ldc_t, scale, swork, &ldswork, &info ); |
| 68 | + if( info < 0 ) { |
| 69 | + info = info - 1; |
| 70 | + } |
| 71 | + /* Transpose output matrices */ |
| 72 | + LAPACKE_cge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc ); |
| 73 | + /* Release memory and exit */ |
| 74 | + LAPACKE_free( c_t ); |
| 75 | +exit_level_2: |
| 76 | + LAPACKE_free( b_t ); |
| 77 | +exit_level_1: |
| 78 | + LAPACKE_free( a_t ); |
| 79 | +exit_level_0: |
| 80 | + if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { |
| 81 | + LAPACKE_xerbla( "LAPACKE_ctrsyl3_work", info ); |
| 82 | + } |
| 83 | + } else { |
| 84 | + info = -1; |
| 85 | + LAPACKE_xerbla( "LAPACKE_ctrsyl3_work", info ); |
| 86 | + } |
| 87 | + return info; |
| 88 | +} |
0 commit comments