You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

lapacke_ztrsyl3_work.c 3.4 kB

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