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_dtrsyl3.c 2.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "lapacke_utils.h"
  2. lapack_int LAPACKE_dtrsyl3( int matrix_layout, char trana, char tranb,
  3. lapack_int isgn, lapack_int m, lapack_int n,
  4. const double* a, lapack_int lda, const double* b,
  5. lapack_int ldb, double* c, lapack_int ldc,
  6. double* scale )
  7. {
  8. lapack_int info = 0;
  9. double swork_query[2];
  10. double* swork = NULL;
  11. lapack_int ldswork = -1;
  12. lapack_int swork_size = -1;
  13. lapack_int iwork_query;
  14. lapack_int* iwork = NULL;
  15. lapack_int liwork = -1;
  16. if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
  17. LAPACKE_xerbla( "LAPACKE_dtrsyl3", -1 );
  18. return -1;
  19. }
  20. #ifndef LAPACK_DISABLE_NAN_CHECK
  21. if( LAPACKE_get_nancheck() ) {
  22. /* Optionally check input matrices for NaNs */
  23. if( LAPACKE_dge_nancheck( matrix_layout, m, m, a, lda ) ) {
  24. return -7;
  25. }
  26. if( LAPACKE_dge_nancheck( matrix_layout, n, n, b, ldb ) ) {
  27. return -9;
  28. }
  29. if( LAPACKE_dge_nancheck( matrix_layout, m, n, c, ldc ) ) {
  30. return -11;
  31. }
  32. }
  33. #endif
  34. /* Query optimal working array sizes */
  35. info = LAPACKE_dtrsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a, lda,
  36. b, ldb, c, ldc, scale, &iwork_query, liwork,
  37. swork_query, ldswork );
  38. if( info != 0 ) {
  39. goto exit_level_0;
  40. }
  41. ldswork = swork_query[0];
  42. swork_size = ldswork * swork_query[1];
  43. swork = (double*)LAPACKE_malloc( sizeof(double) * swork_size);
  44. if( swork == NULL ) {
  45. info = LAPACK_WORK_MEMORY_ERROR;
  46. goto exit_level_0;
  47. }
  48. liwork = iwork_query;
  49. iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
  50. if ( iwork == NULL ) {
  51. info = LAPACK_WORK_MEMORY_ERROR;
  52. goto exit_level_1;
  53. }
  54. /* Call middle-level interface */
  55. info = LAPACKE_dtrsyl3_work( matrix_layout, trana, tranb, isgn, m, n, a,
  56. lda, b, ldb, c, ldc, scale, iwork, liwork,
  57. swork, ldswork );
  58. /* Release memory and exit */
  59. LAPACKE_free( iwork );
  60. exit_level_1:
  61. LAPACKE_free( swork );
  62. exit_level_0:
  63. if( info == LAPACK_WORK_MEMORY_ERROR ) {
  64. LAPACKE_xerbla( "LAPACKE_dtrsyl3", info );
  65. }
  66. return info;
  67. }