fn_vectorise.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 fn_vectorise
  16. //! @{
  17. template<typename T1>
  18. arma_warn_unused
  19. inline
  20. typename
  21. enable_if2
  22. <
  23. is_arma_type<T1>::value,
  24. const Op<T1, op_vectorise_col>
  25. >::result
  26. vectorise(const T1& X)
  27. {
  28. arma_extra_debug_sigprint();
  29. return Op<T1, op_vectorise_col>(X);
  30. }
  31. template<typename T1>
  32. arma_warn_unused
  33. inline
  34. typename
  35. enable_if2
  36. <
  37. is_arma_type<T1>::value,
  38. const Op<T1, op_vectorise_all>
  39. >::result
  40. vectorise(const T1& X, const uword dim)
  41. {
  42. arma_extra_debug_sigprint();
  43. arma_debug_check( (dim > 1), "vectorise(): parameter 'dim' must be 0 or 1" );
  44. return Op<T1, op_vectorise_all>(X, dim, 0);
  45. }
  46. template<typename T1>
  47. arma_warn_unused
  48. inline
  49. CubeToMatOp<T1, op_vectorise_cube_col>
  50. vectorise(const BaseCube<typename T1::elem_type, T1>& X)
  51. {
  52. arma_extra_debug_sigprint();
  53. return CubeToMatOp<T1, op_vectorise_cube_col>(X.get_ref());
  54. }
  55. //! Vectorization for sparse objects.
  56. template<typename T1>
  57. arma_warn_unused
  58. inline
  59. typename
  60. enable_if2
  61. <
  62. is_arma_sparse_type<T1>::value,
  63. const SpOp<T1, spop_vectorise_col>
  64. >::result
  65. vectorise(const T1& X)
  66. {
  67. arma_extra_debug_sigprint();
  68. return SpOp<T1, spop_vectorise_col>(X);
  69. }
  70. //! Vectorization for sparse objects.
  71. template<typename T1>
  72. arma_warn_unused
  73. inline
  74. typename
  75. enable_if2
  76. <
  77. is_arma_sparse_type<T1>::value,
  78. const SpOp<T1, spop_vectorise_all>
  79. >::result
  80. vectorise(const T1& X, const uword dim)
  81. {
  82. arma_extra_debug_sigprint();
  83. arma_debug_check( (dim > 1), "vectorise(): parameter 'dim' must be 0 or 1" );
  84. return SpOp<T1, spop_vectorise_all>(X, dim, 0);
  85. }
  86. //! @}