Skip to content

Commit eb2fa71

Browse files
committed
Armadillo 15.2.4
1 parent 201718f commit eb2fa71

20 files changed

+890
-411
lines changed

inst/include/current/armadillo_bits/Col_meat.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,10 @@ Col<eT>::fixed<fixed_n_elem>::fixed(const fill::fill_class<fill_type>&)
13441344
if(is_same_type<fill_type, fill::fill_eye >::yes) { Mat<eT>::eye(); }
13451345
if(is_same_type<fill_type, fill::fill_randu>::yes) { Mat<eT>::randu(); }
13461346
if(is_same_type<fill_type, fill::fill_randn>::yes) { Mat<eT>::randn(); }
1347+
1348+
if(is_same_type<fill_type, fill::fill_nan >::yes) { (*this).fill( priv::Datum_helper::nan <eT>() ); }
1349+
if(is_same_type<fill_type, fill::fill_pos_inf>::yes) { (*this).fill( priv::Datum_helper::pos_inf<eT>() ); }
1350+
if(is_same_type<fill_type, fill::fill_neg_inf>::yes) { (*this).fill( priv::Datum_helper::neg_inf<eT>() ); }
13471351
}
13481352

13491353

inst/include/current/armadillo_bits/Cube_bones.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ class Cube : public BaseCube< eT, Cube<eT> >
360360

361361
inline Cube& fill(const eT val);
362362

363+
template<typename fill_type>
364+
inline Cube& fill(const fill::fill_class<fill_type>& f);
365+
363366
inline Cube& zeros();
364367
inline Cube& zeros(const uword new_n_rows, const uword new_n_cols, const uword new_n_slices);
365368
inline Cube& zeros(const SizeCube& s);

inst/include/current/armadillo_bits/Cube_meat.hpp

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Cube<eT>::Cube()
5252
, n_elem(0)
5353
, n_alloc(0)
5454
, mem_state(0)
55-
, mem()
55+
, mem(nullptr)
5656
{
5757
arma_debug_sigprint_this(this);
5858
}
@@ -172,7 +172,7 @@ Cube<eT>::Cube(const SizeCube& s, const arma_initmode_indicator<do_zeros>&)
172172
template<typename eT>
173173
template<typename fill_type>
174174
inline
175-
Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_slices, const fill::fill_class<fill_type>&)
175+
Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_slices, const fill::fill_class<fill_type>& f)
176176
: n_rows(in_n_rows)
177177
, n_cols(in_n_cols)
178178
, n_elem_slice(in_n_rows*in_n_cols)
@@ -186,20 +186,15 @@ Cube<eT>::Cube(const uword in_n_rows, const uword in_n_cols, const uword in_n_sl
186186

187187
init_cold();
188188

189-
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
190-
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
191-
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
192-
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
193-
194-
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::Cube(): unsupported fill type" );
189+
(*this).fill(f);
195190
}
196191

197192

198193

199194
template<typename eT>
200195
template<typename fill_type>
201196
inline
202-
Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>&)
197+
Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>& f)
203198
: n_rows(s.n_rows)
204199
, n_cols(s.n_cols)
205200
, n_elem_slice(s.n_rows*s.n_cols)
@@ -213,12 +208,7 @@ Cube<eT>::Cube(const SizeCube& s, const fill::fill_class<fill_type>&)
213208

214209
init_cold();
215210

216-
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
217-
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
218-
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
219-
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
220-
221-
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::Cube(): unsupported fill type" );
211+
(*this).fill(f);
222212
}
223213

224214

@@ -934,7 +924,7 @@ Cube<eT>::Cube
934924
, n_elem(0)
935925
, n_alloc(0)
936926
, mem_state(0)
937-
, mem()
927+
, mem(nullptr)
938928
{
939929
arma_debug_sigprint_this(this);
940930

@@ -1064,7 +1054,7 @@ Cube<eT>::Cube(const subview_cube_slices<eT,T1>& X)
10641054
, n_elem(0)
10651055
, n_alloc(0)
10661056
, mem_state(0)
1067-
, mem()
1057+
, mem(nullptr)
10681058
{
10691059
arma_debug_sigprint_this(this);
10701060

@@ -2751,7 +2741,7 @@ Cube<eT>::Cube(const OpCube<T1, op_type>& X)
27512741
, n_elem(0)
27522742
, n_alloc(0)
27532743
, mem_state(0)
2754-
, mem()
2744+
, mem(nullptr)
27552745
{
27562746
arma_debug_sigprint_this(this);
27572747

@@ -3048,7 +3038,7 @@ Cube<eT>::Cube(const mtOpCube<eT, T1, op_type>& X)
30483038
, n_elem(0)
30493039
, n_alloc(0)
30503040
, mem_state(0)
3051-
, mem()
3041+
, mem(nullptr)
30523042
{
30533043
arma_debug_sigprint_this(this);
30543044

@@ -3144,7 +3134,7 @@ Cube<eT>::Cube(const GlueCube<T1, T2, glue_type>& X)
31443134
, n_elem(0)
31453135
, n_alloc(0)
31463136
, mem_state(0)
3147-
, mem()
3137+
, mem(nullptr)
31483138
{
31493139
arma_debug_sigprint_this(this);
31503140

@@ -3401,7 +3391,7 @@ Cube<eT>::Cube(const mtGlueCube<eT, T1, T2, glue_type>& X)
34013391
, n_elem(0)
34023392
, n_alloc(0)
34033393
, mem_state(0)
3404-
, mem()
3394+
, mem(nullptr)
34053395
{
34063396
arma_debug_sigprint_this(this);
34073397

@@ -3887,7 +3877,7 @@ arma_inline
38873877
eT*
38883878
Cube<eT>::slice_memptr(const uword uslice)
38893879
{
3890-
return const_cast<eT*>( &mem[ uslice*n_elem_slice ] );
3880+
return access::rwp( mem + (uslice*n_elem_slice) );
38913881
}
38923882

38933883

@@ -3898,7 +3888,7 @@ arma_inline
38983888
const eT*
38993889
Cube<eT>::slice_memptr(const uword uslice) const
39003890
{
3901-
return &mem[ uslice*n_elem_slice ];
3891+
return mem + (uslice*n_elem_slice);
39023892
}
39033893

39043894

@@ -3909,7 +3899,7 @@ arma_inline
39093899
eT*
39103900
Cube<eT>::slice_colptr(const uword uslice, const uword col)
39113901
{
3912-
return const_cast<eT*>( &mem[ uslice*n_elem_slice + col*n_rows] );
3902+
return access::rwp( mem + (uslice*n_elem_slice + col*n_rows) );
39133903
}
39143904

39153905

@@ -3920,7 +3910,7 @@ arma_inline
39203910
const eT*
39213911
Cube<eT>::slice_colptr(const uword uslice, const uword col) const
39223912
{
3923-
return &mem[ uslice*n_elem_slice + col*n_rows ];
3913+
return mem + (uslice*n_elem_slice + col*n_rows);
39243914
}
39253915

39263916

@@ -4227,6 +4217,30 @@ Cube<eT>::fill(const eT val)
42274217

42284218

42294219

4220+
template<typename eT>
4221+
template<typename fill_type>
4222+
inline
4223+
Cube<eT>&
4224+
Cube<eT>::fill(const fill::fill_class<fill_type>&)
4225+
{
4226+
arma_debug_sigprint();
4227+
4228+
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::fill(): unsupported fill type" );
4229+
4230+
if(is_same_type<fill_type, fill::fill_zeros>::yes) { (*this).zeros(); }
4231+
if(is_same_type<fill_type, fill::fill_ones >::yes) { (*this).ones(); }
4232+
if(is_same_type<fill_type, fill::fill_randu>::yes) { (*this).randu(); }
4233+
if(is_same_type<fill_type, fill::fill_randn>::yes) { (*this).randn(); }
4234+
4235+
if(is_same_type<fill_type, fill::fill_nan >::yes) { (*this).fill( priv::Datum_helper::nan <eT>() ); }
4236+
if(is_same_type<fill_type, fill::fill_pos_inf>::yes) { (*this).fill( priv::Datum_helper::pos_inf<eT>() ); }
4237+
if(is_same_type<fill_type, fill::fill_neg_inf>::yes) { (*this).fill( priv::Datum_helper::neg_inf<eT>() ); }
4238+
4239+
return *this;
4240+
}
4241+
4242+
4243+
42304244
template<typename eT>
42314245
inline
42324246
Cube<eT>&
@@ -5458,18 +5472,13 @@ template<typename eT>
54585472
template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices>
54595473
template<typename fill_type>
54605474
inline
5461-
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::fixed(const fill::fill_class<fill_type>&)
5475+
Cube<eT>::fixed<fixed_n_rows, fixed_n_cols, fixed_n_slices>::fixed(const fill::fill_class<fill_type>& f)
54625476
{
54635477
arma_debug_sigprint_this(this);
54645478

54655479
mem_setup();
54665480

5467-
if(is_same_type<fill_type, fill::fill_zeros>::yes) { Cube<eT>::zeros(); }
5468-
if(is_same_type<fill_type, fill::fill_ones >::yes) { Cube<eT>::ones(); }
5469-
if(is_same_type<fill_type, fill::fill_randu>::yes) { Cube<eT>::randu(); }
5470-
if(is_same_type<fill_type, fill::fill_randn>::yes) { Cube<eT>::randn(); }
5471-
5472-
arma_static_check( (is_same_type<fill_type, fill::fill_eye>::yes), "Cube::fixed::fixed(): unsupported fill type" );
5481+
(*this).fill(f);
54735482
}
54745483

54755484

0 commit comments

Comments
 (0)