1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17 
18 
19 //! \addtogroup fn_vectorise
20 //! @{
21 
22 
23 
24 template<typename T1>
25 arma_warn_unused
26 inline
27 typename
28 enable_if2
29   <
30   is_arma_type<T1>::value,
31   const Op<T1, op_vectorise_col>
32   >::result
vectorise(const T1 & X)33 vectorise(const T1& X)
34   {
35   arma_extra_debug_sigprint();
36 
37   return Op<T1, op_vectorise_col>(X);
38   }
39 
40 
41 
42 template<typename T1>
43 arma_warn_unused
44 inline
45 typename
46 enable_if2
47   <
48   is_arma_type<T1>::value,
49   const Op<T1, op_vectorise_all>
50   >::result
vectorise(const T1 & X,const uword dim)51 vectorise(const T1& X, const uword dim)
52   {
53   arma_extra_debug_sigprint();
54 
55   arma_debug_check( (dim > 1), "vectorise(): parameter 'dim' must be 0 or 1" );
56 
57   return Op<T1, op_vectorise_all>(X, dim, 0);
58   }
59 
60 
61 
62 template<typename T1>
63 arma_warn_unused
64 inline
65 CubeToMatOp<T1, op_vectorise_cube_col>
vectorise(const BaseCube<typename T1::elem_type,T1> & X)66 vectorise(const BaseCube<typename T1::elem_type, T1>& X)
67   {
68   arma_extra_debug_sigprint();
69 
70   return CubeToMatOp<T1, op_vectorise_cube_col>(X.get_ref());
71   }
72 
73 
74 
75 //! Vectorization for sparse objects.
76 template<typename T1>
77 arma_warn_unused
78 inline
79 typename
80 enable_if2
81   <
82   is_arma_sparse_type<T1>::value,
83   const SpOp<T1, spop_vectorise_col>
84   >::result
vectorise(const T1 & X)85 vectorise(const T1& X)
86   {
87   arma_extra_debug_sigprint();
88 
89   return SpOp<T1, spop_vectorise_col>(X);
90   }
91 
92 
93 
94 //! Vectorization for sparse objects.
95 template<typename T1>
96 arma_warn_unused
97 inline
98 typename
99 enable_if2
100   <
101   is_arma_sparse_type<T1>::value,
102   const SpOp<T1, spop_vectorise_all>
103   >::result
vectorise(const T1 & X,const uword dim)104 vectorise(const T1& X, const uword dim)
105   {
106   arma_extra_debug_sigprint();
107 
108   arma_debug_check( (dim > 1), "vectorise(): parameter 'dim' must be 0 or 1" );
109 
110   return SpOp<T1, spop_vectorise_all>(X, dim, 0);
111   }
112 
113 
114 //! @}
115