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_eye
20 //! @{
21 
22 
23 
24 arma_warn_unused
25 arma_inline
26 const Gen<mat, gen_eye>
eye(const uword n_rows,const uword n_cols)27 eye(const uword n_rows, const uword n_cols)
28   {
29   arma_extra_debug_sigprint();
30 
31   return Gen<mat, gen_eye>(n_rows, n_cols);
32   }
33 
34 
35 
36 arma_warn_unused
37 arma_inline
38 const Gen<mat, gen_eye>
eye(const SizeMat & s)39 eye(const SizeMat& s)
40   {
41   arma_extra_debug_sigprint();
42 
43   return Gen<mat, gen_eye>(s.n_rows, s.n_cols);
44   }
45 
46 
47 
48 template<typename obj_type>
49 arma_warn_unused
50 arma_inline
51 const Gen<obj_type, gen_eye>
eye(const uword n_rows,const uword n_cols,const typename arma_Mat_Col_Row_only<obj_type>::result * junk=nullptr)52 eye(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
53   {
54   arma_extra_debug_sigprint();
55   arma_ignore(junk);
56 
57   if(is_Col<obj_type>::value)
58     {
59     arma_debug_check( (n_cols != 1), "eye(): incompatible size" );
60     }
61   else
62   if(is_Row<obj_type>::value)
63     {
64     arma_debug_check( (n_rows != 1), "eye(): incompatible size" );
65     }
66 
67   return Gen<obj_type, gen_eye>(n_rows, n_cols);
68   }
69 
70 
71 
72 template<typename obj_type>
73 arma_warn_unused
74 arma_inline
75 const Gen<obj_type, gen_eye>
eye(const SizeMat & s,const typename arma_Mat_Col_Row_only<obj_type>::result * junk=nullptr)76 eye(const SizeMat& s, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
77   {
78   arma_extra_debug_sigprint();
79   arma_ignore(junk);
80 
81   return eye<obj_type>(s.n_rows, s.n_cols);
82   }
83 
84 
85 
86 template<typename obj_type>
87 arma_warn_unused
88 inline
89 obj_type
eye(const uword n_rows,const uword n_cols,const typename arma_SpMat_SpCol_SpRow_only<obj_type>::result * junk=nullptr)90 eye(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpCol_SpRow_only<obj_type>::result* junk = nullptr)
91   {
92   arma_extra_debug_sigprint();
93   arma_ignore(junk);
94 
95   if(is_SpCol<obj_type>::value)
96     {
97     arma_debug_check( (n_cols != 1), "eye(): incompatible size" );
98     }
99   else
100   if(is_SpRow<obj_type>::value)
101     {
102     arma_debug_check( (n_rows != 1), "eye(): incompatible size" );
103     }
104 
105   obj_type out;
106 
107   out.eye(n_rows, n_cols);
108 
109   return out;
110   }
111 
112 
113 
114 template<typename obj_type>
115 arma_warn_unused
116 inline
117 obj_type
eye(const SizeMat & s,const typename arma_SpMat_SpCol_SpRow_only<obj_type>::result * junk=nullptr)118 eye(const SizeMat& s, const typename arma_SpMat_SpCol_SpRow_only<obj_type>::result* junk = nullptr)
119   {
120   arma_extra_debug_sigprint();
121   arma_ignore(junk);
122 
123   return eye<obj_type>(s.n_rows, s.n_cols);
124   }
125 
126 
127 
128 //! @}
129