translate_superlu.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. #if defined(ARMA_USE_SUPERLU)
  16. //! \namespace superlu namespace for SuperLU functions
  17. namespace superlu
  18. {
  19. template<typename eT>
  20. inline
  21. void
  22. gssv(superlu_options_t* options, SuperMatrix* A, int* perm_c, int* perm_r, SuperMatrix* L, SuperMatrix* U, SuperMatrix* B, SuperLUStat_t* stat, int* info)
  23. {
  24. arma_type_check(( is_supported_blas_type<eT>::value == false ));
  25. if(is_float<eT>::value)
  26. {
  27. arma_wrapper(sgssv)(options, A, perm_c, perm_r, L, U, B, stat, info);
  28. }
  29. else
  30. if(is_double<eT>::value)
  31. {
  32. arma_wrapper(dgssv)(options, A, perm_c, perm_r, L, U, B, stat, info);
  33. }
  34. else
  35. if(is_cx_float<eT>::value)
  36. {
  37. arma_wrapper(cgssv)(options, A, perm_c, perm_r, L, U, B, stat, info);
  38. }
  39. else
  40. if(is_cx_double<eT>::value)
  41. {
  42. arma_wrapper(zgssv)(options, A, perm_c, perm_r, L, U, B, stat, info);
  43. }
  44. }
  45. template<typename eT>
  46. inline
  47. void
  48. gssvx(
  49. superlu_options_t* opts,
  50. SuperMatrix* A,
  51. int* perm_c, int* perm_r,
  52. int* etree, char* equed,
  53. typename get_pod_type<eT>::result* R, typename get_pod_type<eT>::result* C,
  54. SuperMatrix* L, SuperMatrix* U,
  55. void* work, int lwork,
  56. SuperMatrix* B, SuperMatrix* X,
  57. typename get_pod_type<eT>::result* rpg, typename get_pod_type<eT>::result* rcond,
  58. typename get_pod_type<eT>::result* ferr, typename get_pod_type<eT>::result* berr,
  59. GlobalLU_t* glu, mem_usage_t* mu, SuperLUStat_t* stat, int* info
  60. )
  61. {
  62. arma_type_check(( is_supported_blas_type<eT>::value == false ));
  63. if(is_float<eT>::value)
  64. {
  65. typedef float T;
  66. arma_wrapper(sgssvx)(opts, A, perm_c, perm_r, etree, equed, (T*)R, (T*)C, L, U, work, lwork, B, X, (T*)rpg, (T*)rcond, (T*)ferr, (T*)berr, glu, mu, stat, info);
  67. }
  68. else
  69. if(is_double<eT>::value)
  70. {
  71. typedef double T;
  72. arma_wrapper(dgssvx)(opts, A, perm_c, perm_r, etree, equed, (T*)R, (T*)C, L, U, work, lwork, B, X, (T*)rpg, (T*)rcond, (T*)ferr, (T*)berr, glu, mu, stat, info);
  73. }
  74. else
  75. if(is_cx_float<eT>::value)
  76. {
  77. typedef float T;
  78. arma_wrapper(cgssvx)(opts, A, perm_c, perm_r, etree, equed, (T*)R, (T*)C, L, U, work, lwork, B, X, (T*)rpg, (T*)rcond, (T*)ferr, (T*)berr, glu, mu, stat, info);
  79. }
  80. else
  81. if(is_cx_double<eT>::value)
  82. {
  83. typedef double T;
  84. arma_wrapper(zgssvx)(opts, A, perm_c, perm_r, etree, equed, (T*)R, (T*)C, L, U, work, lwork, B, X, (T*)rpg, (T*)rcond, (T*)ferr, (T*)berr, glu, mu, stat, info);
  85. }
  86. }
  87. inline
  88. void
  89. init_stat(SuperLUStat_t* stat)
  90. {
  91. arma_wrapper(StatInit)(stat);
  92. }
  93. inline
  94. void
  95. free_stat(SuperLUStat_t* stat)
  96. {
  97. arma_wrapper(StatFree)(stat);
  98. }
  99. inline
  100. void
  101. set_default_opts(superlu_options_t* opts)
  102. {
  103. arma_wrapper(set_default_options)(opts);
  104. }
  105. inline
  106. void
  107. destroy_supernode_mat(SuperMatrix* a)
  108. {
  109. arma_wrapper(Destroy_SuperNode_Matrix)(a);
  110. }
  111. inline
  112. void
  113. destroy_compcol_mat(SuperMatrix* a)
  114. {
  115. arma_wrapper(Destroy_CompCol_Matrix)(a);
  116. }
  117. inline
  118. void
  119. destroy_dense_mat(SuperMatrix* a)
  120. {
  121. arma_wrapper(Destroy_SuperMatrix_Store)(a);
  122. }
  123. inline
  124. void*
  125. malloc(size_t N)
  126. {
  127. return arma_wrapper(superlu_malloc)(N);
  128. }
  129. inline
  130. void
  131. free(void* mem)
  132. {
  133. arma_wrapper(superlu_free)(mem);
  134. }
  135. } // namespace superlu
  136. #endif