unwrap_spmat.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. //! \addtogroup unwrap_spmat
  16. //! @{
  17. template<typename T1>
  18. struct unwrap_spmat
  19. {
  20. typedef typename T1::elem_type eT;
  21. typedef SpMat<eT> stored_type;
  22. inline
  23. unwrap_spmat(const T1& A)
  24. : M(A)
  25. {
  26. arma_extra_debug_sigprint();
  27. }
  28. const SpMat<eT> M;
  29. template<typename eT2>
  30. arma_inline bool is_alias(const SpMat<eT2>&) const { return false; }
  31. };
  32. template<typename eT>
  33. struct unwrap_spmat< SpMat<eT> >
  34. {
  35. typedef SpMat<eT> stored_type;
  36. inline
  37. unwrap_spmat(const SpMat<eT>& A)
  38. : M(A)
  39. {
  40. arma_extra_debug_sigprint();
  41. M.sync();
  42. }
  43. const SpMat<eT>& M;
  44. template<typename eT2>
  45. arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
  46. };
  47. template<typename eT>
  48. struct unwrap_spmat< SpRow<eT> >
  49. {
  50. typedef SpRow<eT> stored_type;
  51. inline
  52. unwrap_spmat(const SpRow<eT>& A)
  53. : M(A)
  54. {
  55. arma_extra_debug_sigprint();
  56. M.sync();
  57. }
  58. const SpRow<eT>& M;
  59. template<typename eT2>
  60. arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
  61. };
  62. template<typename eT>
  63. struct unwrap_spmat< SpCol<eT> >
  64. {
  65. typedef SpCol<eT> stored_type;
  66. inline
  67. unwrap_spmat(const SpCol<eT>& A)
  68. : M(A)
  69. {
  70. arma_extra_debug_sigprint();
  71. M.sync();
  72. }
  73. const SpCol<eT>& M;
  74. template<typename eT2>
  75. arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
  76. };
  77. template<typename T1, typename spop_type>
  78. struct unwrap_spmat< SpOp<T1, spop_type> >
  79. {
  80. typedef typename T1::elem_type eT;
  81. typedef SpMat<eT> stored_type;
  82. inline
  83. unwrap_spmat(const SpOp<T1, spop_type>& A)
  84. : M(A)
  85. {
  86. arma_extra_debug_sigprint();
  87. }
  88. const SpMat<eT> M;
  89. template<typename eT2>
  90. arma_inline bool is_alias(const SpMat<eT2>&) const { return false; }
  91. };
  92. template<typename T1, typename T2, typename spglue_type>
  93. struct unwrap_spmat< SpGlue<T1, T2, spglue_type> >
  94. {
  95. typedef typename T1::elem_type eT;
  96. typedef SpMat<eT> stored_type;
  97. inline
  98. unwrap_spmat(const SpGlue<T1, T2, spglue_type>& A)
  99. : M(A)
  100. {
  101. arma_extra_debug_sigprint();
  102. }
  103. const SpMat<eT> M;
  104. template<typename eT2>
  105. arma_inline bool is_alias(const SpMat<eT2>&) const { return false; }
  106. };
  107. template<typename out_eT, typename T1, typename spop_type>
  108. struct unwrap_spmat< mtSpOp<out_eT, T1, spop_type> >
  109. {
  110. typedef SpMat<out_eT> stored_type;
  111. inline
  112. unwrap_spmat(const mtSpOp<out_eT, T1, spop_type>& A)
  113. : M(A)
  114. {
  115. arma_extra_debug_sigprint();
  116. }
  117. const SpMat<out_eT> M;
  118. template<typename eT2>
  119. arma_inline bool is_alias(const SpMat<eT2>&) const { return false; }
  120. };
  121. template<typename out_eT, typename T1, typename T2, typename spglue_type>
  122. struct unwrap_spmat< mtSpGlue<out_eT, T1, T2, spglue_type> >
  123. {
  124. typedef SpMat<out_eT> stored_type;
  125. inline
  126. unwrap_spmat(const mtSpGlue<out_eT, T1, T2, spglue_type>& A)
  127. : M(A)
  128. {
  129. arma_extra_debug_sigprint();
  130. }
  131. const SpMat<out_eT> M;
  132. template<typename eT2>
  133. arma_inline bool is_alias(const SpMat<eT2>&) const { return false; }
  134. };
  135. //! @}