Skip to content

Commit 64771bc

Browse files
committed
Armadillo 12.8.2
1 parent ca8b294 commit 64771bc

File tree

8 files changed

+68
-96
lines changed

8 files changed

+68
-96
lines changed

inst/include/armadillo_bits/Mat_meat.hpp

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,19 @@ Mat<eT>::init(const std::initializer_list< std::initializer_list<eT> >& list)
942942

943943
uword x_n_rows = uword(list.size());
944944
uword x_n_cols = 0;
945+
uword x_n_elem = 0;
945946

946947
auto it = list.begin();
947948
auto it_end = list.end();
948949

949-
for(; it != it_end; ++it) { x_n_cols = (std::max)(x_n_cols, uword((*it).size())); }
950+
for(; it != it_end; ++it)
951+
{
952+
const uword x_n_cols_new = uword((*it).size());
953+
954+
x_n_elem += x_n_cols_new;
955+
956+
x_n_cols = (std::max)(x_n_cols, x_n_cols_new);
957+
}
950958

951959
Mat<eT>& t = (*this);
952960

@@ -959,6 +967,9 @@ Mat<eT>::init(const std::initializer_list< std::initializer_list<eT> >& list)
959967
t.set_size(x_n_rows, x_n_cols);
960968
}
961969

970+
// if the inner lists have varying number of elements, treat missing elements as zeros
971+
if(t.n_elem != x_n_elem) { t.zeros(); }
972+
962973
uword row_num = 0;
963974

964975
auto row_it = list.begin();
@@ -977,11 +988,6 @@ Mat<eT>::init(const std::initializer_list< std::initializer_list<eT> >& list)
977988
++col_num;
978989
}
979990

980-
for(uword c=col_num; c < x_n_cols; ++c)
981-
{
982-
t.at(row_num, c) = eT(0);
983-
}
984-
985991
++row_num;
986992
}
987993
}
@@ -6796,21 +6802,10 @@ Mat<eT>::set_size(const uword new_n_elem)
67966802
{
67976803
arma_extra_debug_sigprint();
67986804

6799-
switch(vec_state)
6800-
{
6801-
case 0:
6802-
// fallthrough
6803-
case 1:
6804-
init_warm(new_n_elem, 1);
6805-
break;
6806-
6807-
case 2:
6808-
init_warm(1, new_n_elem);
6809-
break;
6810-
6811-
default:
6812-
;
6813-
}
6805+
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
6806+
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
6807+
6808+
init_warm(new_n_rows, new_n_cols);
68146809

68156810
return *this;
68166811
}
@@ -6854,23 +6849,10 @@ Mat<eT>::resize(const uword new_n_elem)
68546849
{
68556850
arma_extra_debug_sigprint();
68566851

6857-
switch(vec_state)
6858-
{
6859-
case 0:
6860-
// fallthrough
6861-
case 1:
6862-
(*this).resize(new_n_elem, 1);
6863-
break;
6864-
6865-
case 2:
6866-
(*this).resize(1, new_n_elem);
6867-
break;
6868-
6869-
default:
6870-
;
6871-
}
6852+
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
6853+
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
68726854

6873-
return *this;
6855+
return (*this).resize(new_n_rows, new_n_cols);
68746856
}
68756857

68766858

inst/include/armadillo_bits/SpMat_bones.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class SpMat : public SpBase< eT, SpMat<eT> >
139139
template<typename T1> inline SpMat& operator*=(const Op<T1, op_diagmat>& expr);
140140
template<typename T1> inline SpMat& operator/=(const Op<T1, op_diagmat>& expr);
141141
template<typename T1> inline SpMat& operator%=(const Op<T1, op_diagmat>& expr);
142-
142+
143143
//! explicit specification of sparse +/- scalar
144144
template<typename T1, typename op_type> inline explicit SpMat(const SpToDOp<T1, op_type>& expr);
145145

inst/include/armadillo_bits/SpMat_meat.hpp

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,21 +3701,14 @@ SpMat<eT>::copy_size(const Mat<eT2>& m)
37013701
template<typename eT>
37023702
inline
37033703
SpMat<eT>&
3704-
SpMat<eT>::set_size(const uword in_elem)
3704+
SpMat<eT>::set_size(const uword new_n_elem)
37053705
{
37063706
arma_extra_debug_sigprint();
37073707

3708-
// If this is a row vector, we resize to a row vector.
3709-
if(vec_state == 2)
3710-
{
3711-
set_size(1, in_elem);
3712-
}
3713-
else
3714-
{
3715-
set_size(in_elem, 1);
3716-
}
3708+
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
3709+
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
37173710

3718-
return *this;
3711+
return set_size(new_n_rows, new_n_cols);
37193712
}
37203713

37213714

@@ -4115,20 +4108,14 @@ SpMat<eT>::zeros()
41154108
template<typename eT>
41164109
inline
41174110
SpMat<eT>&
4118-
SpMat<eT>::zeros(const uword in_elem)
4111+
SpMat<eT>::zeros(const uword new_n_elem)
41194112
{
41204113
arma_extra_debug_sigprint();
41214114

4122-
if(vec_state == 2)
4123-
{
4124-
zeros(1, in_elem); // Row vector
4125-
}
4126-
else
4127-
{
4128-
zeros(in_elem, 1);
4129-
}
4115+
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
4116+
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
41304117

4131-
return *this;
4118+
return zeros(new_n_rows, new_n_cols);
41324119
}
41334120

41344121

@@ -4432,12 +4419,10 @@ SpMat<eT>::reset()
44324419
{
44334420
arma_extra_debug_sigprint();
44344421

4435-
switch(vec_state)
4436-
{
4437-
default: init(0, 0); break;
4438-
case 1: init(0, 1); break;
4439-
case 2: init(1, 0); break;
4440-
}
4422+
const uword new_n_rows = (vec_state == 2) ? 1 : 0;
4423+
const uword new_n_cols = (vec_state == 1) ? 1 : 0;
4424+
4425+
init(new_n_rows, new_n_cols);
44414426
}
44424427

44434428

inst/include/armadillo_bits/arma_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define ARMA_VERSION_MAJOR 12
2525
#define ARMA_VERSION_MINOR 8
26-
#define ARMA_VERSION_PATCH 1
26+
#define ARMA_VERSION_PATCH 2
2727
#define ARMA_VERSION_NAME "Cortisol Injector"
2828

2929

inst/include/armadillo_bits/def_fftw3.hpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,38 @@
1616
// ------------------------------------------------------------------------
1717

1818

19-
#if defined(ARMA_USE_FFTW3)
19+
#if defined(ARMA_USE_FFTW3) && !defined(FFTW3_H)
20+
21+
22+
// prefix for single precision: fftwf_
23+
// prefix for double precision: fftw_
24+
25+
26+
typedef void fftwf_complex;
27+
typedef void fftw_complex;
28+
29+
typedef void_ptr fftwf_plan;
30+
typedef void_ptr fftw_plan;
2031

2132

2233
extern "C"
2334
{
24-
// function prefix for single precision: fftwf_
25-
// function prefix for double precision: fftw_
26-
27-
2835
// single precision (float)
2936

30-
void_ptr fftwf_plan_dft_1d(int N, void* input, void* output, int fftw3_sign, unsigned int fftw3_flags);
37+
fftwf_plan fftwf_plan_dft_1d(int N, fftwf_complex* input, fftwf_complex* output, int fftw3_sign, unsigned int fftw3_flags);
3138

32-
void fftwf_execute(void_ptr plan);
33-
void fftwf_destroy_plan(void_ptr plan);
39+
void fftwf_execute(fftwf_plan plan);
40+
void fftwf_destroy_plan(fftwf_plan plan);
3441

3542
void fftwf_cleanup();
3643

3744

3845
// double precision (double)
3946

40-
void_ptr fftw_plan_dft_1d(int N, void* input, void* output, int fftw3_sign, unsigned int fftw3_flags);
47+
fftw_plan fftw_plan_dft_1d(int N, fftw_complex* input, fftw_complex* output, int fftw3_sign, unsigned int fftw3_flags);
4148

42-
void fftw_execute(void_ptr plan);
43-
void fftw_destroy_plan(void_ptr plan);
49+
void fftw_execute(fftw_plan plan);
50+
void fftw_destroy_plan(fftw_plan plan);
4451

4552
void fftw_cleanup();
4653
}

inst/include/armadillo_bits/translate_fftw3.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ namespace fftw3
3030

3131
if(is_cx_float<eT>::value)
3232
{
33-
return fftwf_plan_dft_1d(N, (cx_float*)input, (cx_float*)output, fftw3_sign, fftw3_flags);
33+
return fftwf_plan_dft_1d(N, (fftwf_complex*)(input), (fftwf_complex*)(output), fftw3_sign, fftw3_flags);
3434
}
3535
else
3636
if(is_cx_double<eT>::value)
3737
{
38-
return fftw_plan_dft_1d(N, (cx_double*)input, (cx_double*)output, fftw3_sign, fftw3_flags);
38+
return fftw_plan_dft_1d(N, (fftw_complex*)(input), (fftw_complex*)(output), fftw3_sign, fftw3_flags);
3939
}
4040

4141
return nullptr;
@@ -52,12 +52,12 @@ namespace fftw3
5252

5353
if(is_cx_float<eT>::value)
5454
{
55-
fftwf_execute(plan);
55+
fftwf_execute(fftwf_plan(plan));
5656
}
5757
else
5858
if(is_cx_double<eT>::value)
5959
{
60-
fftw_execute(plan);
60+
fftw_execute(fftw_plan(plan));
6161
}
6262
}
6363

@@ -72,12 +72,12 @@ namespace fftw3
7272

7373
if(is_cx_float<eT>::value)
7474
{
75-
fftwf_destroy_plan(plan);
75+
fftwf_destroy_plan(fftwf_plan(plan));
7676
}
7777
else
7878
if(is_cx_double<eT>::value)
7979
{
80-
fftw_destroy_plan(plan);
80+
fftw_destroy_plan(fftw_plan(plan));
8181
}
8282
}
8383

inst/include/armadillo_bits/wall_clock_bones.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class wall_clock
3434

3535
private:
3636

37-
bool valid = false;
38-
3937
std::chrono::steady_clock::time_point chrono_time1;
38+
39+
bool valid = false;
4040
};
4141

4242

inst/include/armadillo_bits/wall_clock_meat.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ inline
2424
wall_clock::wall_clock()
2525
{
2626
arma_extra_debug_sigprint();
27+
28+
chrono_time1 = std::chrono::steady_clock::now(); // warmup
2729
}
2830

2931

@@ -43,6 +45,7 @@ wall_clock::tic()
4345
arma_extra_debug_sigprint();
4446

4547
chrono_time1 = std::chrono::steady_clock::now();
48+
4649
valid = true;
4750
}
4851

@@ -54,18 +57,13 @@ wall_clock::toc()
5457
{
5558
arma_extra_debug_sigprint();
5659

57-
if(valid)
58-
{
59-
const std::chrono::steady_clock::time_point chrono_time2 = std::chrono::steady_clock::now();
60-
61-
typedef std::chrono::duration<double> duration_type; // TODO: check this
62-
63-
const duration_type chrono_span = std::chrono::duration_cast< duration_type >(chrono_time2 - chrono_time1);
64-
65-
return chrono_span.count();
66-
}
60+
const std::chrono::steady_clock::time_point chrono_time2 = std::chrono::steady_clock::now();
61+
62+
typedef std::chrono::duration<double> duration_type; // TODO: check this
63+
64+
const duration_type chrono_span = std::chrono::duration_cast< duration_type >(chrono_time2 - chrono_time1);
6765

68-
return 0.0;
66+
return (valid) ? double(chrono_span.count()) : double(0);
6967
}
7068

7169

0 commit comments

Comments
 (0)