source: mmcs/armadillo_bits/fn_ones.hpp @ 8ad4484

matrices
Last change on this file since 8ad4484 was 9dd61b1, checked in by rboet <rboet@…>, 9 years ago

Avance del proyecto 60%

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