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_zeros
20 //! @{
21 
22 
23 
24 arma_warn_unused
25 arma_inline
26 const Gen<vec, gen_zeros>
zeros(const uword n_elem)27 zeros(const uword n_elem)
28   {
29   arma_extra_debug_sigprint();
30 
31   return Gen<vec, gen_zeros>(n_elem, 1);
32   }
33 
34 
35 
36 template<typename obj_type>
37 arma_warn_unused
38 arma_inline
39 const Gen<obj_type, gen_zeros>
zeros(const uword n_elem,const arma_empty_class junk1=arma_empty_class (),const typename arma_Mat_Col_Row_only<obj_type>::result * junk2=nullptr)40 zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = nullptr)
41   {
42   arma_extra_debug_sigprint();
43   arma_ignore(junk1);
44   arma_ignore(junk2);
45 
46   if(is_Row<obj_type>::value)
47     {
48     return Gen<obj_type, gen_zeros>(1, n_elem);
49     }
50   else
51     {
52     return Gen<obj_type, gen_zeros>(n_elem, 1);
53     }
54   }
55 
56 
57 
58 arma_warn_unused
59 arma_inline
60 const Gen<mat, gen_zeros>
zeros(const uword n_rows,const uword n_cols)61 zeros(const uword n_rows, const uword n_cols)
62   {
63   arma_extra_debug_sigprint();
64 
65   return Gen<mat, gen_zeros>(n_rows, n_cols);
66   }
67 
68 
69 
70 arma_warn_unused
71 arma_inline
72 const Gen<mat, gen_zeros>
zeros(const SizeMat & s)73 zeros(const SizeMat& s)
74   {
75   arma_extra_debug_sigprint();
76 
77   return Gen<mat, gen_zeros>(s.n_rows, s.n_cols);
78   }
79 
80 
81 
82 template<typename obj_type>
83 arma_warn_unused
84 arma_inline
85 const Gen<obj_type, gen_zeros>
zeros(const uword n_rows,const uword n_cols,const typename arma_Mat_Col_Row_only<obj_type>::result * junk=nullptr)86 zeros(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
87   {
88   arma_extra_debug_sigprint();
89   arma_ignore(junk);
90 
91   if(is_Col<obj_type>::value)
92     {
93     arma_debug_check( (n_cols != 1), "zeros(): incompatible size" );
94     }
95   else
96   if(is_Row<obj_type>::value)
97     {
98     arma_debug_check( (n_rows != 1), "zeros(): incompatible size" );
99     }
100 
101   return Gen<obj_type, gen_zeros>(n_rows, n_cols);
102   }
103 
104 
105 
106 template<typename obj_type>
107 arma_warn_unused
108 arma_inline
109 const Gen<obj_type, gen_zeros>
zeros(const SizeMat & s,const typename arma_Mat_Col_Row_only<obj_type>::result * junk=nullptr)110 zeros(const SizeMat& s, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
111   {
112   arma_extra_debug_sigprint();
113   arma_ignore(junk);
114 
115   return zeros<obj_type>(s.n_rows, s.n_cols);
116   }
117 
118 
119 
120 arma_warn_unused
121 arma_inline
122 const GenCube<cube::elem_type, gen_zeros>
zeros(const uword n_rows,const uword n_cols,const uword n_slices)123 zeros(const uword n_rows, const uword n_cols, const uword n_slices)
124   {
125   arma_extra_debug_sigprint();
126 
127   return GenCube<cube::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
128   }
129 
130 
131 
132 arma_warn_unused
133 arma_inline
134 const GenCube<cube::elem_type, gen_zeros>
zeros(const SizeCube & s)135 zeros(const SizeCube& s)
136   {
137   arma_extra_debug_sigprint();
138 
139   return GenCube<cube::elem_type, gen_zeros>(s.n_rows, s.n_cols, s.n_slices);
140   }
141 
142 
143 
144 template<typename cube_type>
145 arma_warn_unused
146 arma_inline
147 const GenCube<typename cube_type::elem_type, gen_zeros>
zeros(const uword n_rows,const uword n_cols,const uword n_slices,const typename arma_Cube_only<cube_type>::result * junk=nullptr)148 zeros(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
149   {
150   arma_extra_debug_sigprint();
151   arma_ignore(junk);
152 
153   return GenCube<typename cube_type::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
154   }
155 
156 
157 
158 template<typename cube_type>
159 arma_warn_unused
160 arma_inline
161 const GenCube<typename cube_type::elem_type, gen_zeros>
zeros(const SizeCube & s,const typename arma_Cube_only<cube_type>::result * junk=nullptr)162 zeros(const SizeCube& s, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
163   {
164   arma_extra_debug_sigprint();
165   arma_ignore(junk);
166 
167   return GenCube<typename cube_type::elem_type, gen_zeros>(s.n_rows, s.n_cols, s.n_slices);
168   }
169 
170 
171 
172 template<typename sp_obj_type>
173 arma_warn_unused
174 inline
175 sp_obj_type
zeros(const uword n_rows,const uword n_cols,const typename arma_SpMat_SpCol_SpRow_only<sp_obj_type>::result * junk=nullptr)176 zeros(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpCol_SpRow_only<sp_obj_type>::result* junk = nullptr)
177   {
178   arma_extra_debug_sigprint();
179   arma_ignore(junk);
180 
181   if(is_SpCol<sp_obj_type>::value)
182     {
183     arma_debug_check( (n_cols != 1), "zeros(): incompatible size" );
184     }
185   else
186   if(is_SpRow<sp_obj_type>::value)
187     {
188     arma_debug_check( (n_rows != 1), "zeros(): incompatible size" );
189     }
190 
191   return sp_obj_type(n_rows, n_cols);
192   }
193 
194 
195 
196 template<typename sp_obj_type>
197 arma_warn_unused
198 inline
199 sp_obj_type
zeros(const SizeMat & s,const typename arma_SpMat_SpCol_SpRow_only<sp_obj_type>::result * junk=nullptr)200 zeros(const SizeMat& s, const typename arma_SpMat_SpCol_SpRow_only<sp_obj_type>::result* junk = nullptr)
201   {
202   arma_extra_debug_sigprint();
203   arma_ignore(junk);
204 
205   return zeros<sp_obj_type>(s.n_rows, s.n_cols);
206   }
207 
208 
209 
210 //! @}
211