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_reshape
20 //! @{
21
22
23
24 template<typename T1>
25 arma_warn_unused
26 inline
27 typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_reshape> >::result
reshape(const T1 & X,const uword in_n_rows,const uword in_n_cols)28 reshape(const T1& X, const uword in_n_rows, const uword in_n_cols)
29 {
30 arma_extra_debug_sigprint();
31
32 return Op<T1, op_reshape>(X, in_n_rows, in_n_cols);
33 }
34
35
36
37 template<typename T1>
38 arma_warn_unused
39 inline
40 typename enable_if2< is_arma_type<T1>::value, const Op<T1, op_reshape> >::result
reshape(const T1 & X,const SizeMat & s)41 reshape(const T1& X, const SizeMat& s)
42 {
43 arma_extra_debug_sigprint();
44
45 return Op<T1, op_reshape>(X, s.n_rows, s.n_cols);
46 }
47
48
49
50 //! NOTE: don't use this form: it will be removed
51 template<typename T1>
52 arma_deprecated
53 inline
54 const Op<T1, op_reshape_old>
reshape(const Base<typename T1::elem_type,T1> & X,const uword in_n_rows,const uword in_n_cols,const uword dim)55 reshape(const Base<typename T1::elem_type,T1>& X, const uword in_n_rows, const uword in_n_cols, const uword dim) //!< NOTE: don't use this form: it will be removed
56 {
57 arma_extra_debug_sigprint();
58
59 // arma_debug_warn_level(1, "this form of reshape() is deprecated and will be removed");
60
61 arma_debug_check( (dim > 1), "reshape(): parameter 'dim' must be 0 or 1" );
62
63 return Op<T1, op_reshape_old>(X.get_ref(), in_n_rows, in_n_cols, dim, 'j');
64 }
65
66
67
68 template<typename T1>
69 arma_warn_unused
70 inline
71 const OpCube<T1, op_reshape>
reshape(const BaseCube<typename T1::elem_type,T1> & X,const uword in_n_rows,const uword in_n_cols,const uword in_n_slices)72 reshape(const BaseCube<typename T1::elem_type,T1>& X, const uword in_n_rows, const uword in_n_cols, const uword in_n_slices)
73 {
74 arma_extra_debug_sigprint();
75
76 return OpCube<T1, op_reshape>(X.get_ref(), in_n_rows, in_n_cols, in_n_slices);
77 }
78
79
80
81 template<typename T1>
82 arma_warn_unused
83 inline
84 const OpCube<T1, op_reshape>
reshape(const BaseCube<typename T1::elem_type,T1> & X,const SizeCube & s)85 reshape(const BaseCube<typename T1::elem_type,T1>& X, const SizeCube& s)
86 {
87 arma_extra_debug_sigprint();
88
89 return OpCube<T1, op_reshape>(X.get_ref(), s.n_rows, s.n_cols, s.n_slices);
90 }
91
92
93
94 template<typename T1>
95 arma_warn_unused
96 inline
97 const SpOp<T1, spop_reshape>
reshape(const SpBase<typename T1::elem_type,T1> & X,const uword in_n_rows,const uword in_n_cols)98 reshape(const SpBase<typename T1::elem_type, T1>& X, const uword in_n_rows, const uword in_n_cols)
99 {
100 arma_extra_debug_sigprint();
101
102 return SpOp<T1, spop_reshape>(X.get_ref(), in_n_rows, in_n_cols);
103 }
104
105
106
107 template<typename T1>
108 arma_warn_unused
109 inline
110 const SpOp<T1, spop_reshape>
reshape(const SpBase<typename T1::elem_type,T1> & X,const SizeMat & s)111 reshape(const SpBase<typename T1::elem_type, T1>& X, const SizeMat& s)
112 {
113 arma_extra_debug_sigprint();
114
115 return SpOp<T1, spop_reshape>(X.get_ref(), s.n_rows, s.n_cols);
116 }
117
118
119
120 //! @}
121