Chris@49
|
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2008-2012 Conrad Sanderson
|
Chris@49
|
3 //
|
Chris@49
|
4 // This Source Code Form is subject to the terms of the Mozilla Public
|
Chris@49
|
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
|
Chris@49
|
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Chris@49
|
7
|
Chris@49
|
8
|
Chris@49
|
9 //! \addtogroup fn_zeros
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13 //! Generate a vector with all elements set to zero
|
Chris@49
|
14 arma_inline
|
Chris@49
|
15 const Gen<vec, gen_zeros>
|
Chris@49
|
16 zeros(const uword n_elem)
|
Chris@49
|
17 {
|
Chris@49
|
18 arma_extra_debug_sigprint();
|
Chris@49
|
19
|
Chris@49
|
20 return Gen<vec, gen_zeros>(n_elem, 1);
|
Chris@49
|
21 }
|
Chris@49
|
22
|
Chris@49
|
23
|
Chris@49
|
24
|
Chris@49
|
25 template<typename obj_type>
|
Chris@49
|
26 arma_inline
|
Chris@49
|
27 const Gen<obj_type, gen_zeros>
|
Chris@49
|
28 zeros(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = 0)
|
Chris@49
|
29 {
|
Chris@49
|
30 arma_extra_debug_sigprint();
|
Chris@49
|
31 arma_ignore(junk1);
|
Chris@49
|
32 arma_ignore(junk2);
|
Chris@49
|
33
|
Chris@49
|
34 if(is_Row<obj_type>::value == true)
|
Chris@49
|
35 {
|
Chris@49
|
36 return Gen<obj_type, gen_zeros>(1, n_elem);
|
Chris@49
|
37 }
|
Chris@49
|
38 else
|
Chris@49
|
39 {
|
Chris@49
|
40 return Gen<obj_type, gen_zeros>(n_elem, 1);
|
Chris@49
|
41 }
|
Chris@49
|
42 }
|
Chris@49
|
43
|
Chris@49
|
44
|
Chris@49
|
45
|
Chris@49
|
46 //! Generate a dense matrix with all elements set to zero
|
Chris@49
|
47 arma_inline
|
Chris@49
|
48 const Gen<mat, gen_zeros>
|
Chris@49
|
49 zeros(const uword n_rows, const uword n_cols)
|
Chris@49
|
50 {
|
Chris@49
|
51 arma_extra_debug_sigprint();
|
Chris@49
|
52
|
Chris@49
|
53 return Gen<mat, gen_zeros>(n_rows, n_cols);
|
Chris@49
|
54 }
|
Chris@49
|
55
|
Chris@49
|
56
|
Chris@49
|
57
|
Chris@49
|
58 template<typename obj_type>
|
Chris@49
|
59 arma_inline
|
Chris@49
|
60 const Gen<obj_type, gen_zeros>
|
Chris@49
|
61 zeros(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = 0)
|
Chris@49
|
62 {
|
Chris@49
|
63 arma_extra_debug_sigprint();
|
Chris@49
|
64 arma_ignore(junk);
|
Chris@49
|
65
|
Chris@49
|
66 if(is_Col<obj_type>::value == true)
|
Chris@49
|
67 {
|
Chris@49
|
68 arma_debug_check( (n_cols != 1), "zeros(): incompatible size" );
|
Chris@49
|
69 }
|
Chris@49
|
70 else
|
Chris@49
|
71 if(is_Row<obj_type>::value == true)
|
Chris@49
|
72 {
|
Chris@49
|
73 arma_debug_check( (n_rows != 1), "zeros(): incompatible size" );
|
Chris@49
|
74 }
|
Chris@49
|
75
|
Chris@49
|
76 return Gen<obj_type, gen_zeros>(n_rows, n_cols);
|
Chris@49
|
77 }
|
Chris@49
|
78
|
Chris@49
|
79
|
Chris@49
|
80
|
Chris@49
|
81 arma_inline
|
Chris@49
|
82 const GenCube<cube::elem_type, gen_zeros>
|
Chris@49
|
83 zeros(const uword n_rows, const uword n_cols, const uword n_slices)
|
Chris@49
|
84 {
|
Chris@49
|
85 arma_extra_debug_sigprint();
|
Chris@49
|
86
|
Chris@49
|
87 return GenCube<cube::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
|
Chris@49
|
88 }
|
Chris@49
|
89
|
Chris@49
|
90
|
Chris@49
|
91
|
Chris@49
|
92 template<typename cube_type>
|
Chris@49
|
93 arma_inline
|
Chris@49
|
94 const GenCube<typename cube_type::elem_type, gen_zeros>
|
Chris@49
|
95 zeros(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only<cube_type>::result* junk = 0)
|
Chris@49
|
96 {
|
Chris@49
|
97 arma_extra_debug_sigprint();
|
Chris@49
|
98 arma_ignore(junk);
|
Chris@49
|
99
|
Chris@49
|
100 return GenCube<typename cube_type::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
|
Chris@49
|
101 }
|
Chris@49
|
102
|
Chris@49
|
103
|
Chris@49
|
104
|
Chris@49
|
105 //! @}
|