| OpCube_meat.hpp | | OpCube_meat.hpp | |
| | | | |
| skipping to change at line 63 | | skipping to change at line 63 | |
| : m(in_m.get_ref()) | | : m(in_m.get_ref()) | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| , aux_u32_c(in_aux_u32_c) | | , aux_u32_c(in_aux_u32_c) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
|
| | | OpCube<T1, op_type>::OpCube(const BaseCube<typename T1::elem_type, T1>& in_ | |
| | | m, const typename T1::elem_type in_aux, const u32 in_aux_u32_a, const u32 i | |
| | | n_aux_u32_b, const u32 in_aux_u32_c) | |
| | | : m(in_m.get_ref()) | |
| | | , aux(in_aux) | |
| | | , aux_u32_a(in_aux_u32_a) | |
| | | , aux_u32_b(in_aux_u32_b) | |
| | | , aux_u32_c(in_aux_u32_c) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | template<typename T1, typename op_type> | |
| OpCube<T1, op_type>::OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b,
const u32 in_aux_u32_c) | | OpCube<T1, op_type>::OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b,
const u32 in_aux_u32_c) | |
| : m(m) | | : m(m) | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| , aux_u32_c(in_aux_u32_c) | | , aux_u32_c(in_aux_u32_c) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| | | | |
End of changes. 1 change blocks. |
| 0 lines changed or deleted | | 13 lines changed or added | |
|
| OpCube_proto.hpp | | OpCube_proto.hpp | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| { | | { | |
| public: | | public: | |
| | | | |
| typedef typename T1::elem_type elem_type; | | typedef typename T1::elem_type elem_type; | |
| typedef typename get_pod_type<elem_type>::pod_type pod_type; | | typedef typename get_pod_type<elem_type>::pod_type pod_type; | |
| | | | |
| inline explicit OpCube(const BaseCube<typename T1::elem_type, T1>& in_m); | | inline explicit OpCube(const BaseCube<typename T1::elem_type, T1>& in_m); | |
| inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const elem_type in_aux); | | inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const elem_type in_aux); | |
| inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b); | | inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b); | |
| inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c); | | inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const u32 in_aux_u32_a, const u32 in_aux_u32_b, const u32 in_aux_u32_c); | |
|
| | | inline OpCube(const BaseCube<typename T1::elem_type, T1>& in_m,
const elem_type in_aux, const u32 in_aux_u32_a, const u32 in_aux_u32_b, con
st u32 in_aux_u32_c); | |
| inline OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b, co
nst u32 in_aux_u32_c); | | inline OpCube(const u32 in_aux_u32_a, const u32 in_aux_u32_b, co
nst u32 in_aux_u32_c); | |
| inline ~OpCube(); | | inline ~OpCube(); | |
| | | | |
| // TODO:MAT: if the restriction to inputs of type BaseCube works, the use
of the "junk" parameter may no longer be necessary | | // TODO:MAT: if the restriction to inputs of type BaseCube works, the use
of the "junk" parameter may no longer be necessary | |
| | | | |
| const T1& m; //!< storage of reference to the operand (e.g
. a cube) | | const T1& m; //!< storage of reference to the operand (e.g
. a cube) | |
| const elem_type aux; //!< storage of auxiliary data, user defined
format | | const elem_type aux; //!< storage of auxiliary data, user defined
format | |
| const u32 aux_u32_a; //!< storage of auxiliary data, u32 format | | const u32 aux_u32_a; //!< storage of auxiliary data, u32 format | |
| const u32 aux_u32_b; //!< storage of auxiliary data, u32 format | | const u32 aux_u32_b; //!< storage of auxiliary data, u32 format | |
| const u32 aux_u32_c; //!< storage of auxiliary data, u32 format | | const u32 aux_u32_c; //!< storage of auxiliary data, u32 format | |
| | | | |
End of changes. 1 change blocks. |
| 0 lines changed or deleted | | 1 lines changed or added | |
|
| Op_meat.hpp | | Op_meat.hpp | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux) | | Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux) | |
| : m(in_m) | | : m(in_m) | |
| , aux(in_aux) | | , aux(in_aux) | |
| , aux_u32_a(aux_u32_a) | | , aux_u32_a(aux_u32_a) | |
| , aux_u32_b(aux_u32_b) | | , aux_u32_b(aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
|
| //Op<T1, op_type>::Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_
aux_u32_b = 0) | | | |
| Op<T1, op_type>::Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_au
x_u32_b) | | Op<T1, op_type>::Op(const T1& in_m, const u32 in_aux_u32_a, const u32 in_au
x_u32_b) | |
| : m(in_m) | | : m(in_m) | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
|
| | | Op<T1, op_type>::Op(const T1& in_m, const typename T1::elem_type in_aux, co | |
| | | nst u32 in_aux_u32_a, const u32 in_aux_u32_b) | |
| | | : m(in_m) | |
| | | , aux(in_aux) | |
| | | , aux_u32_a(in_aux_u32_a) | |
| | | , aux_u32_b(in_aux_u32_b) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | } | |
| | | | |
| | | template<typename T1, typename op_type> | |
| Op<T1, op_type>::Op(const u32 in_aux_u32_a, const u32 in_aux_u32_b, const c
har junk) | | Op<T1, op_type>::Op(const u32 in_aux_u32_a, const u32 in_aux_u32_b, const c
har junk) | |
| : m(m) | | : m(m) | |
| , aux(aux) | | , aux(aux) | |
| , aux_u32_a(in_aux_u32_a) | | , aux_u32_a(in_aux_u32_a) | |
| , aux_u32_b(in_aux_u32_b) | | , aux_u32_b(in_aux_u32_b) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 11 lines changed or added | |
|
| armadillo | | armadillo | |
| | | | |
| skipping to change at line 177 | | skipping to change at line 177 | |
| #include "armadillo_bits/op_randn_proto.hpp" | | #include "armadillo_bits/op_randn_proto.hpp" | |
| #include "armadillo_bits/op_scalar_misc_proto.hpp" | | #include "armadillo_bits/op_scalar_misc_proto.hpp" | |
| #include "armadillo_bits/op_sort_proto.hpp" | | #include "armadillo_bits/op_sort_proto.hpp" | |
| #include "armadillo_bits/op_sum_proto.hpp" | | #include "armadillo_bits/op_sum_proto.hpp" | |
| #include "armadillo_bits/op_stddev_proto.hpp" | | #include "armadillo_bits/op_stddev_proto.hpp" | |
| #include "armadillo_bits/op_trig_proto.hpp" | | #include "armadillo_bits/op_trig_proto.hpp" | |
| #include "armadillo_bits/op_trans_proto.hpp" | | #include "armadillo_bits/op_trans_proto.hpp" | |
| #include "armadillo_bits/op_var_proto.hpp" | | #include "armadillo_bits/op_var_proto.hpp" | |
| #include "armadillo_bits/op_zeros_proto.hpp" | | #include "armadillo_bits/op_zeros_proto.hpp" | |
| #include "armadillo_bits/op_repmat_proto.hpp" | | #include "armadillo_bits/op_repmat_proto.hpp" | |
|
| | | #include "armadillo_bits/op_reshape_proto.hpp" | |
| | | #include "armadillo_bits/op_cov_proto.hpp" | |
| | | #include "armadillo_bits/op_cor_proto.hpp" | |
| | | | |
| #include "armadillo_bits/glue_plus_proto.hpp" | | #include "armadillo_bits/glue_plus_proto.hpp" | |
| #include "armadillo_bits/glue_minus_proto.hpp" | | #include "armadillo_bits/glue_minus_proto.hpp" | |
| #include "armadillo_bits/glue_times_proto.hpp" | | #include "armadillo_bits/glue_times_proto.hpp" | |
| #include "armadillo_bits/glue_schur_proto.hpp" | | #include "armadillo_bits/glue_schur_proto.hpp" | |
| #include "armadillo_bits/glue_div_proto.hpp" | | #include "armadillo_bits/glue_div_proto.hpp" | |
| | | | |
|
| | | #include "armadillo_bits/glue_cov_proto.hpp" | |
| | | #include "armadillo_bits/glue_cor_proto.hpp" | |
| | | | |
| #include "armadillo_bits/glue_cube_plus_proto.hpp" | | #include "armadillo_bits/glue_cube_plus_proto.hpp" | |
| #include "armadillo_bits/glue_cube_minus_proto.hpp" | | #include "armadillo_bits/glue_cube_minus_proto.hpp" | |
| #include "armadillo_bits/glue_cube_schur_proto.hpp" | | #include "armadillo_bits/glue_cube_schur_proto.hpp" | |
| #include "armadillo_bits/glue_cube_div_proto.hpp" | | #include "armadillo_bits/glue_cube_div_proto.hpp" | |
| | | | |
| // | | // | |
| // debugging functions | | // debugging functions | |
| | | | |
| #include "armadillo_bits/debug.hpp" | | #include "armadillo_bits/debug.hpp" | |
| | | | |
| | | | |
| skipping to change at line 269 | | skipping to change at line 275 | |
| #include "armadillo_bits/fn_stddev.hpp" | | #include "armadillo_bits/fn_stddev.hpp" | |
| #include "armadillo_bits/fn_var.hpp" | | #include "armadillo_bits/fn_var.hpp" | |
| #include "armadillo_bits/fn_sort.hpp" | | #include "armadillo_bits/fn_sort.hpp" | |
| #include "armadillo_bits/fn_sort_index.hpp" | | #include "armadillo_bits/fn_sort_index.hpp" | |
| #include "armadillo_bits/fn_htrans.hpp" | | #include "armadillo_bits/fn_htrans.hpp" | |
| #include "armadillo_bits/fn_chol.hpp" | | #include "armadillo_bits/fn_chol.hpp" | |
| #include "armadillo_bits/fn_qr.hpp" | | #include "armadillo_bits/fn_qr.hpp" | |
| #include "armadillo_bits/fn_svd.hpp" | | #include "armadillo_bits/fn_svd.hpp" | |
| #include "armadillo_bits/fn_solve.hpp" | | #include "armadillo_bits/fn_solve.hpp" | |
| #include "armadillo_bits/fn_repmat.hpp" | | #include "armadillo_bits/fn_repmat.hpp" | |
|
| | | #include "armadillo_bits/fn_reshape.hpp" | |
| | | #include "armadillo_bits/fn_cov.hpp" | |
| | | #include "armadillo_bits/fn_cor.hpp" | |
| | | | |
| // | | // | |
| // class meat | | // class meat | |
| | | | |
| #include "armadillo_bits/gemm.hpp" | | #include "armadillo_bits/gemm.hpp" | |
| #include "armadillo_bits/gemv.hpp" | | #include "armadillo_bits/gemv.hpp" | |
| #include "armadillo_bits/gemm_mixed.hpp" | | #include "armadillo_bits/gemm_mixed.hpp" | |
| | | | |
| #include "armadillo_bits/podarray_meat.hpp" | | #include "armadillo_bits/podarray_meat.hpp" | |
| #include "armadillo_bits/auxlib_meat.hpp" | | #include "armadillo_bits/auxlib_meat.hpp" | |
| | | | |
| skipping to change at line 316 | | skipping to change at line 325 | |
| #include "armadillo_bits/op_randn_meat.hpp" | | #include "armadillo_bits/op_randn_meat.hpp" | |
| #include "armadillo_bits/op_scalar_misc_meat.hpp" | | #include "armadillo_bits/op_scalar_misc_meat.hpp" | |
| #include "armadillo_bits/op_sort_meat.hpp" | | #include "armadillo_bits/op_sort_meat.hpp" | |
| #include "armadillo_bits/op_sum_meat.hpp" | | #include "armadillo_bits/op_sum_meat.hpp" | |
| #include "armadillo_bits/op_stddev_meat.hpp" | | #include "armadillo_bits/op_stddev_meat.hpp" | |
| #include "armadillo_bits/op_trans_meat.hpp" | | #include "armadillo_bits/op_trans_meat.hpp" | |
| #include "armadillo_bits/op_trig_meat.hpp" | | #include "armadillo_bits/op_trig_meat.hpp" | |
| #include "armadillo_bits/op_var_meat.hpp" | | #include "armadillo_bits/op_var_meat.hpp" | |
| #include "armadillo_bits/op_zeros_meat.hpp" | | #include "armadillo_bits/op_zeros_meat.hpp" | |
| #include "armadillo_bits/op_repmat_meat.hpp" | | #include "armadillo_bits/op_repmat_meat.hpp" | |
|
| | | #include "armadillo_bits/op_reshape_meat.hpp" | |
| | | #include "armadillo_bits/op_cov_meat.hpp" | |
| | | #include "armadillo_bits/op_cor_meat.hpp" | |
| | | | |
| #include "armadillo_bits/glue_plus_meat.hpp" | | #include "armadillo_bits/glue_plus_meat.hpp" | |
| #include "armadillo_bits/glue_minus_meat.hpp" | | #include "armadillo_bits/glue_minus_meat.hpp" | |
| #include "armadillo_bits/glue_times_meat.hpp" | | #include "armadillo_bits/glue_times_meat.hpp" | |
| #include "armadillo_bits/glue_schur_meat.hpp" | | #include "armadillo_bits/glue_schur_meat.hpp" | |
| #include "armadillo_bits/glue_div_meat.hpp" | | #include "armadillo_bits/glue_div_meat.hpp" | |
| | | | |
|
| | | #include "armadillo_bits/glue_cov_meat.hpp" | |
| | | #include "armadillo_bits/glue_cor_meat.hpp" | |
| | | | |
| #include "armadillo_bits/glue_cube_plus_meat.hpp" | | #include "armadillo_bits/glue_cube_plus_meat.hpp" | |
| #include "armadillo_bits/glue_cube_minus_meat.hpp" | | #include "armadillo_bits/glue_cube_minus_meat.hpp" | |
| #include "armadillo_bits/glue_cube_schur_meat.hpp" | | #include "armadillo_bits/glue_cube_schur_meat.hpp" | |
| #include "armadillo_bits/glue_cube_div_meat.hpp" | | #include "armadillo_bits/glue_cube_div_meat.hpp" | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 0 lines changed or deleted | | 15 lines changed or added | |
|
| fn_misc.hpp | | fn_misc.hpp | |
| | | | |
| skipping to change at line 63 | | skipping to change at line 63 | |
| | | | |
| inline | | inline | |
| mat | | mat | |
| linspace(const double start, const double end, const u32 num, const u32 dim
= 0) | | linspace(const double start, const double end, const u32 num, const u32 dim
= 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| return linspace<double>(start, end, num, dim); | | return linspace<double>(start, end, num, dim); | |
| } | | } | |
| | | | |
| // | | // | |
|
| // reshape | | | |
| | | | |
| template<typename T1> | | | |
| inline | | | |
| Mat<typename T1::elem_type> | | | |
| reshape(const Base<typename T1::elem_type,T1>& X, const u32 in_n_rows, cons | | | |
| t u32 in_n_cols, const u32 dim = 0) | | | |
| { | | | |
| arma_extra_debug_sigprint(); | | | |
| | | | |
| typedef typename T1::elem_type eT; | | | |
| | | | |
| const unwrap<T1> A_tmp(X.get_ref()); | | | |
| const Mat<eT>& A = A_tmp.M; | | | |
| | | | |
| const u32 in_n_elem = in_n_rows * in_n_cols; | | | |
| | | | |
| arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen | | | |
| sions"); | | | |
| arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); | | | |
| | | | |
| if(dim == 0) | | | |
| { | | | |
| return Mat<eT>(A.mem, in_n_rows, in_n_cols); | | | |
| } | | | |
| else | | | |
| { | | | |
| Mat<eT> out(in_n_rows, in_n_cols); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| u32 i = 0; | | | |
| | | | |
| for(u32 row=0; row<A.n_rows; ++row) | | | |
| { | | | |
| for(u32 col=0; col<A.n_cols; ++col) | | | |
| { | | | |
| out_mem[i] = A.at(row,col); | | | |
| ++i; | | | |
| } | | | |
| } | | | |
| | | | |
| return out; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename T1> | | | |
| inline | | | |
| Cube<typename T1::elem_type> | | | |
| reshape(const BaseCube<typename T1::elem_type,T1>& X, const u32 in_n_rows, | | | |
| const u32 in_n_cols, const u32 in_n_slices, const u32 dim = 0) | | | |
| { | | | |
| arma_extra_debug_sigprint(); | | | |
| | | | |
| typedef typename T1::elem_type eT; | | | |
| | | | |
| const unwrap_cube<T1> A_tmp(X.get_ref()); | | | |
| const Cube<eT>& A = A_tmp.M; | | | |
| | | | |
| const u32 in_n_elem = in_n_rows * in_n_cols * in_n_slices; | | | |
| | | | |
| arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimen | | | |
| sions"); | | | |
| arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); | | | |
| | | | |
| if(dim == 0) | | | |
| { | | | |
| return Cube<eT>(A.mem, in_n_rows, in_n_cols, in_n_slices); | | | |
| } | | | |
| else | | | |
| { | | | |
| Cube<eT> out(in_n_rows, in_n_cols, in_n_slices); | | | |
| | | | |
| eT* out_mem = out.memptr(); | | | |
| u32 i = 0; | | | |
| | | | |
| for(u32 slice=0; slice<A.n_slices; ++slice) | | | |
| { | | | |
| for(u32 row=0; row<A.n_rows; ++row) | | | |
| { | | | |
| for(u32 col=0; col<A.n_cols; ++col) | | | |
| { | | | |
| out_mem[i] = A.at(row,col,slice); | | | |
| ++i; | | | |
| } | | | |
| } | | | |
| } | | | |
| | | | |
| return out; | | | |
| } | | | |
| } | | | |
| | | | |
| // | | | |
| // real | | // real | |
| | | | |
| template<typename T, typename T1> | | template<typename T, typename T1> | |
| inline | | inline | |
| Mat<T> | | Mat<T> | |
| real(const Base<std::complex<T>, T1>& X) | | real(const Base<std::complex<T>, T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef std::complex<T> eT; | | typedef std::complex<T> eT; | |
| | | | |
End of changes. 1 change blocks. |
| 92 lines changed or deleted | | 0 lines changed or added | |
|
| glue_cube_div_meat.hpp | | glue_cube_div_meat.hpp | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(A, B, "element-wise cube division"); | | arma_debug_assert_same_size(A, B, "element-wise cube division"); | |
| | | | |
| // no aliasing problem | | // no aliasing problem | |
| //out.set_size(A.n_rows, A.n_cols, A.n_slices); | | //out.set_size(A.n_rows, A.n_cols, A.n_slices); | |
| out.copy_size(A); | | out.copy_size(A); | |
| | | | |
| const u32 n_elem = A.n_elem; | | const u32 n_elem = A.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* A_mem = A.mem; | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] = A.mem[i] / B.mem[i]; | | out_mem[i] = A_mem[i] / B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, c
onst Cube<eT>& C) | | glue_cube_div::apply(Cube<eT>& out, const Cube<eT>& A, const Cube<eT>& B, c
onst Cube<eT>& C) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(A, B, "element-wise cube division"); | | arma_debug_assert_same_size(A, B, "element-wise cube division"); | |
| arma_debug_assert_same_size(B, C, "element-wise cube division"); | | arma_debug_assert_same_size(B, C, "element-wise cube division"); | |
| | | | |
| // no aliasing problem | | // no aliasing problem | |
| //out.set_size(A.n_rows, A.n_cols, A.n_slices); | | //out.set_size(A.n_rows, A.n_cols, A.n_slices); | |
| out.copy_size(A); | | out.copy_size(A); | |
| | | | |
| const u32 n_elem = A.n_elem; | | const u32 n_elem = A.n_elem; | |
|
| for(u32 i=0; i != n_elem; ++i) | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const eT* A_mem = A.mem; | |
| | | const eT* B_mem = B.mem; | |
| | | const eT* C_mem = C.mem; | |
| | | | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] = A.mem[i] / B.mem[i] / C.mem[i]; | | out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_c
ube_div>& X) | | glue_cube_div::apply(Cube<eT>& out, const GlueCube<Cube<eT>,Cube<eT>,glue_c
ube_div>& X) | |
| { | | { | |
| glue_cube_div::apply(out, X.A, X.B); | | glue_cube_div::apply(out, X.A, X.B); | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 167 | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply_inplace(Cube<eT>& out, const Cube<eT>& B) | | glue_cube_div::apply_inplace(Cube<eT>& out, const Cube<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(out, B, "element-wise cube division"); | | arma_debug_assert_same_size(out, B, "element-wise cube division"); | |
| | | | |
| const u32 n_elem = out.n_elem; | | const u32 n_elem = out.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] /= B.mem[i]; | | out_mem[i] /= B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename T1, typename op_cube_type> | | template<typename T1, typename op_cube_type> | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const OpCub
e<T1, op_cube_type>& X) | | glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const OpCub
e<T1, op_cube_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Cube<eT> tmp(X); | | const Cube<eT> tmp(X); | |
|
| glue_cube_div::apply(out, out, tmp); | | glue_cube_div::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename glue_cube_type> | | template<typename T1, typename T2, typename glue_cube_type> | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const GlueC
ube<T1, T2, glue_cube_type>& X) | | glue_cube_div::apply_inplace(Cube<typename T1::elem_type>& out, const GlueC
ube<T1, T2, glue_cube_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Cube<eT> tmp(X); | | const Cube<eT> tmp(X); | |
|
| glue_cube_div::apply(out, X, out); | | glue_cube_div::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| // | | // | |
| // element-wise division with different element types | | // element-wise division with different element types | |
| | | | |
| template<typename eT1, typename eT2> | | template<typename eT1, typename eT2> | |
| inline | | inline | |
| void | | void | |
| glue_cube_div::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& ou
t, const Cube<eT1>& X, const Cube<eT2>& Y) | | glue_cube_div::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>& ou
t, const Cube<eT1>& X, const Cube<eT2>& Y) | |
| { | | { | |
| | | | |
End of changes. 8 change blocks. |
| 6 lines changed or deleted | | 19 lines changed or added | |
|
| glue_cube_schur_meat.hpp | | glue_cube_schur_meat.hpp | |
| | | | |
| skipping to change at line 167 | | skipping to change at line 167 | |
| inline | | inline | |
| void | | void | |
| glue_cube_schur::apply_inplace(Cube<eT>& out, const Cube<eT>& B) | | glue_cube_schur::apply_inplace(Cube<eT>& out, const Cube<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(out, B, "cube schur product"); | | arma_debug_assert_same_size(out, B, "cube schur product"); | |
| | | | |
| const u32 n_elem = out.n_elem; | | const u32 n_elem = out.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] *= B.mem[i]; | | out_mem[i] *= B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename T1, typename op_cube_type> | | template<typename T1, typename op_cube_type> | |
| inline | | inline | |
| void | | void | |
| glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const OpC
ube<T1, op_cube_type>& X) | | glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const OpC
ube<T1, op_cube_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Cube<eT> tmp(X); | | const Cube<eT> tmp(X); | |
|
| glue_cube_schur::apply(out, out, tmp); | | glue_cube_schur::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename glue_cube_type> | | template<typename T1, typename T2, typename glue_cube_type> | |
| inline | | inline | |
| void | | void | |
| glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const Glu
eCube<T1, T2, glue_cube_type>& X) | | glue_cube_schur::apply_inplace(Cube<typename T1::elem_type>& out, const Glu
eCube<T1, T2, glue_cube_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // out = X % out; | | // out = X % out; | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Cube<eT> tmp(X); | | const Cube<eT> tmp(X); | |
|
| glue_cube_schur::apply(out, out, tmp); | | glue_cube_schur::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| // | | // | |
| // cube schur product with different element types | | // cube schur product with different element types | |
| | | | |
| template<typename eT1, typename eT2> | | template<typename eT1, typename eT2> | |
| inline | | inline | |
| void | | void | |
| glue_cube_schur::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>&
out, const Cube<eT1>& X, const Cube<eT2>& Y) | | glue_cube_schur::apply_mixed(Cube<typename promote_type<eT1,eT2>::result>&
out, const Cube<eT1>& X, const Cube<eT2>& Y) | |
| { | | { | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 6 lines changed or added | |
|
| glue_div_meat.hpp | | glue_div_meat.hpp | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(A, B, "element-wise matrix division"); | | arma_debug_assert_same_size(A, B, "element-wise matrix division"); | |
| | | | |
| // no aliasing problem | | // no aliasing problem | |
| //out.set_size(A.n_rows, A.n_cols); | | //out.set_size(A.n_rows, A.n_cols); | |
| out.copy_size(A); | | out.copy_size(A); | |
| | | | |
| const u32 n_elem = A.n_elem; | | const u32 n_elem = A.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* A_mem = A.mem; | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] = A.mem[i] / B.mem[i]; | | out_mem[i] = A_mem[i] / B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat
<eT>& C) | | glue_div::apply(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, const Mat
<eT>& C) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(A, B, "element-wise matrix division"); | | arma_debug_assert_same_size(A, B, "element-wise matrix division"); | |
| arma_debug_assert_same_size(B, C, "element-wise matrix division"); | | arma_debug_assert_same_size(B, C, "element-wise matrix division"); | |
| | | | |
| // no aliasing problem | | // no aliasing problem | |
| //out.set_size(A.n_rows, A.n_cols); | | //out.set_size(A.n_rows, A.n_cols); | |
| out.copy_size(A); | | out.copy_size(A); | |
| | | | |
| const u32 n_elem = A.n_elem; | | const u32 n_elem = A.n_elem; | |
|
| for(u32 i=0; i != n_elem; ++i) | | | |
| | | eT* out_mem = out.memptr(); | |
| | | const eT* A_mem = A.mem; | |
| | | const eT* B_mem = B.mem; | |
| | | const eT* C_mem = C.mem; | |
| | | | |
| | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] = A.mem[i] / B.mem[i] / C.mem[i]; | | out_mem[i] = A_mem[i] / B_mem[i] / C_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| glue_div::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_div>& X) | | glue_div::apply(Mat<eT>& out, const Glue<Mat<eT>,Mat<eT>,glue_div>& X) | |
| { | | { | |
| glue_div::apply(out, X.A, X.B); | | glue_div::apply(out, X.A, X.B); | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 167 | |
| inline | | inline | |
| void | | void | |
| glue_div::apply_inplace(Mat<eT>& out, const Mat<eT>& B) | | glue_div::apply_inplace(Mat<eT>& out, const Mat<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(out, B, "element-wise matrix division"); | | arma_debug_assert_same_size(out, B, "element-wise matrix division"); | |
| | | | |
| const u32 n_elem = out.n_elem; | | const u32 n_elem = out.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] /= B.mem[i]; | | out_mem[i] /= B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| void | | void | |
| glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_t
ype>& X) | | glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_t
ype>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Mat<eT> tmp(X); | | const Mat<eT> tmp(X); | |
|
| glue_div::apply(out, out, tmp); | | glue_div::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| void | | void | |
| glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2
, glue_type>& X) | | glue_div::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T2
, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Mat<eT> tmp(X); | | const Mat<eT> tmp(X); | |
|
| glue_div::apply(out, X, out); | | glue_div::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| // | | // | |
| // element-wise division with different element types | | // element-wise division with different element types | |
| | | | |
| template<typename eT1, typename eT2> | | template<typename eT1, typename eT2> | |
| inline | | inline | |
| void | | void | |
| glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con
st Mat<eT1>& X, const Mat<eT2>& Y) | | glue_div::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, con
st Mat<eT1>& X, const Mat<eT2>& Y) | |
| { | | { | |
| | | | |
End of changes. 8 change blocks. |
| 6 lines changed or deleted | | 19 lines changed or added | |
|
| glue_plus_meat.hpp | | glue_plus_meat.hpp | |
| | | | |
| skipping to change at line 349 | | skipping to change at line 349 | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| void | | void | |
| glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
type>& X) | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Mat<eT> tmp(X); | | const Mat<eT> tmp(X); | |
|
| glue_plus::apply(out, out, tmp); | | glue_plus::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
square>& X) | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op_
square>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| skipping to change at line 409 | | skipping to change at line 409 | |
| | | | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| arma_debug_assert_mul_size(A, B, "matrix multiplication"); | | arma_debug_assert_mul_size(A, B, "matrix multiplication"); | |
| arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_rows, B.n_cols, "
matrix addition"); | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_rows, B.n_cols, "
matrix addition"); | |
| | | | |
| gemm<false,false,false,true>::apply(out, A, B, eT(1), eT(1)); | | gemm<false,false,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| } | | } | |
| | | | |
|
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | void | |
| | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1 | |
| | | , op_trans>, T2, glue_times>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap_check<T1> tmp1(X.A.m, out); | |
| | | const unwrap_check<T2> tmp2(X.B, out); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | // we need to remember that A deliberately hasn't been transposed | |
| | | | |
| | | arma_debug_assert_mul_size(A.n_cols, A.n_rows, B.n_rows, B.n_cols, "matri | |
| | | x multiplication"); | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_cols, B.n_cols, " | |
| | | matrix addition"); | |
| | | | |
| | | gemm<true,false,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | void | |
| | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, O | |
| | | p<T2, op_trans>, glue_times>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap_check<T1> tmp1(X.A, out); | |
| | | const unwrap_check<T2> tmp2(X.B.m, out); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | // we need to remember that B deliberately hasn't been transposed | |
| | | | |
| | | arma_debug_assert_mul_size(A.n_rows, A.n_cols, B.n_cols, B.n_rows, "matri | |
| | | x multiplication"); | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_rows, B.n_rows, " | |
| | | matrix addition"); | |
| | | | |
| | | gemm<false,true,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | void | |
| | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1 | |
| | | , op_trans>, Op<T2, op_trans>, glue_times>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap_check<T1> tmp1(X.A.m, out); | |
| | | const unwrap_check<T2> tmp2(X.B.m, out); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | // we need to remember that A and B deliberately haven't been transposed | |
| | | | |
| | | arma_debug_assert_mul_size(A.n_cols, A.n_rows, B.n_cols, B.n_rows, "matri | |
| | | x multiplication"); | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_cols, B.n_rows, " | |
| | | matrix addition"); | |
| | | | |
| | | gemm<true,true,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | void | |
| | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1, T | |
| | | 2, glue_times_vec>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap_check<T1> tmp1(X.A, out); | |
| | | const unwrap_check<T2> tmp2(X.B, out); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | arma_debug_assert_mul_size(A, B, "vector multiplication"); | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_rows, B.n_cols, " | |
| | | matrix addition"); | |
| | | | |
| | | if(A.is_vec() && B.is_vec()) | |
| | | { | |
| | | if(A.n_cols == 1) // column * row (i.e. outer product) | |
| | | { | |
| | | glue_times_vec::mul_col_row_inplace_add(out, A.mem, B.mem); | |
| | | } | |
| | | else // row * column (i.e. inner product) | |
| | | { | |
| | | out[0] += op_dot::direct_dot(A.n_elem, A.mem, B.mem); | |
| | | } | |
| | | } | |
| | | else // one of the arguments is a matrix | |
| | | { | |
| | | if(A.is_vec() == false) // A is a matrix, B is a vector | |
| | | { | |
| | | gemv<false,false,true>::apply(out.memptr(), A, B.mem, eT(1), eT(1)); | |
| | | } | |
| | | else // A is a vector, B is a matrix | |
| | | { | |
| | | gemm<false,false,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| | | } | |
| | | } | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | void | |
| | | glue_plus::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<Op<T1 | |
| | | , op_trans>, T2, glue_times_vec>& X) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap_check<T1> tmp1(X.A.m, out); | |
| | | const unwrap_check<T2> tmp2(X.B, out); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | // we need to remember that A deliberately hasn't been transposed | |
| | | | |
| | | arma_debug_assert_mul_size(A.n_cols, A.n_rows, B.n_rows, B.n_cols, "vecto | |
| | | r multiplication"); | |
| | | | |
| | | arma_debug_assert_same_size(out.n_rows, out.n_cols, A.n_cols, B.n_cols, " | |
| | | matrix addition"); | |
| | | | |
| | | if(A.is_vec() && B.is_vec()) | |
| | | { | |
| | | if(A.n_rows == 1) // trans(row) * row, equivalent to column * row (i. | |
| | | e. outer product) | |
| | | { | |
| | | glue_times_vec::mul_col_row_inplace_add(out, A.mem, B.mem); | |
| | | } | |
| | | else // trans(column) * column, equivalent to row * column (i.e. inn | |
| | | er product) | |
| | | { | |
| | | out[0] += op_dot::direct_dot(A.n_elem, A.mem, B.mem); | |
| | | } | |
| | | } | |
| | | else // one of the arguments is a matrix | |
| | | { | |
| | | if(A.is_vec() == false) // A is a matrix, B is a vector | |
| | | { | |
| | | gemv<true,false,true>::apply(out.memptr(), A, B.mem, eT(1), eT(1)); | |
| | | } | |
| | | else // A is a vector, B is a matrix | |
| | | { | |
| | | gemm<true,false,false,true>::apply(out, A, B, eT(1), eT(1)); | |
| | | } | |
| | | } | |
| | | } | |
| | | | |
| // | | // | |
| // | | // | |
| // | | // | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| glue_plus::apply | | glue_plus::apply | |
| ( | | ( | |
| Mat<typename T1::elem_type>& out, | | Mat<typename T1::elem_type>& out, | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 173 lines changed or added | |
|
| glue_plus_proto.hpp | | glue_plus_proto.hpp | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 66 | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_square>& X); | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Op<T1, op_square>& X); | |
| | | | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_type>& X); | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_type>& X); | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_times>& X); | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const
Glue<T1, T2, glue_times>& X); | |
| | | | |
|
| | | template<typename T1, typename T2> | |
| | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const | |
| | | Glue<Op<T1, op_trans>, T2, glue_times>& X); | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const | |
| | | Glue<T1, Op<T2, op_trans>, glue_times>& X); | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const | |
| | | Glue<Op<T1, op_trans>, Op<T2, op_trans>, glue_times>& X); | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const | |
| | | Glue<T1, T2, glue_times_vec>& X); | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline static void apply_inplace(Mat<typename T1::elem_type>& out, const | |
| | | Glue<Op<T1, op_trans>, T2, glue_times_vec>& X); | |
| | | | |
| | | // TODO:MAT: add handling for: | |
| | | // Glue<T1, Op<T2, op_trans>, glue_times_vec> | |
| | | // Glue<Op<T1,op_trans>. Op<T2, op_trans>, glue_times_Vec> | |
| | | | |
| // mat, special | | // mat, special | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl
ue<T1, Col<typename T1::elem_type>, glue_times_vec>, T2, glue_plus>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl
ue<T1, Col<typename T1::elem_type>, glue_times_vec>, T2, glue_plus>& in); | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl
ue<Row<typename T1::elem_type>, T1, glue_times_vec>, T2, glue_plus>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Gl
ue<Row<typename T1::elem_type>, T1, glue_times_vec>, T2, glue_plus>& in); | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op<
T1, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>& in); | | inline static void apply(Mat<typename T1::elem_type>& out, const Glue<Op<
T1, op_scalar_times>, Op<T2, op_scalar_times>, glue_plus>& in); | |
| | | | |
End of changes. 1 change blocks. |
| 0 lines changed or deleted | | 24 lines changed or added | |
|
| glue_schur_meat.hpp | | glue_schur_meat.hpp | |
| | | | |
| skipping to change at line 167 | | skipping to change at line 167 | |
| inline | | inline | |
| void | | void | |
| glue_schur::apply_inplace(Mat<eT>& out, const Mat<eT>& B) | | glue_schur::apply_inplace(Mat<eT>& out, const Mat<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_assert_same_size(out, B, "matrix schur product"); | | arma_debug_assert_same_size(out, B, "matrix schur product"); | |
| | | | |
| const u32 n_elem = out.n_elem; | | const u32 n_elem = out.n_elem; | |
| | | | |
|
| | | eT* out_mem = out.memptr(); | |
| | | const eT* B_mem = B.mem; | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
|
| out[i] *= B.mem[i]; | | out_mem[i] *= B_mem[i]; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| template<typename T1, typename op_type> | | template<typename T1, typename op_type> | |
| inline | | inline | |
| void | | void | |
| glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op
_type>& X) | | glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Op<T1, op
_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Mat<eT> tmp(X); | | const Mat<eT> tmp(X); | |
|
| glue_schur::apply(out, out, tmp); | | glue_schur::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename glue_type> | | template<typename T1, typename T2, typename glue_type> | |
| inline | | inline | |
| void | | void | |
| glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_type>& X) | | glue_schur::apply_inplace(Mat<typename T1::elem_type>& out, const Glue<T1,
T2, glue_type>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| // out = X % out; | | // out = X % out; | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
| const Mat<eT> tmp(X); | | const Mat<eT> tmp(X); | |
|
| glue_schur::apply(out, out, tmp); | | glue_schur::apply_inplace(out, tmp); | |
| } | | } | |
| | | | |
| // | | // | |
| // matrix schur product with different element types | | // matrix schur product with different element types | |
| | | | |
| template<typename eT1, typename eT2> | | template<typename eT1, typename eT2> | |
| inline | | inline | |
| void | | void | |
| glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c
onst Mat<eT1>& X, const Mat<eT2>& Y) | | glue_schur::apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, c
onst Mat<eT1>& X, const Mat<eT2>& Y) | |
| { | | { | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 6 lines changed or added | |
|
| op_repmat_meat.hpp | | op_repmat_meat.hpp | |
|
| // Copyright (C) 2009 Dimitrios Bouzas | | | |
| // Copyright (C) 2009 NICTA | | // Copyright (C) 2009 NICTA | |
|
| | | // Copyright (C) 2009 Dimitrios Bouzas | |
| // | | // | |
| // Authors: | | // Authors: | |
|
| // - Dimitrios Bouzas (dimitris dot mpouzas at gmail dot com) | | | |
| // - Conrad Sanderson (conradsand at ieee dot org) | | // - Conrad Sanderson (conradsand at ieee dot org) | |
|
| | | // - Dimitrios Bouzas (dimitris dot mpouzas at gmail dot com) | |
| // | | // | |
| // This file is part of the Armadillo C++ library. | | // This file is part of the Armadillo C++ library. | |
| // It is provided without any warranty of fitness | | // It is provided without any warranty of fitness | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // Lesser General Public License (LGPL) as published | | // Lesser General Public License (LGPL) as published | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| //! implementation of the 'repeat matrix' operation, used for constructing
matrices | | //! implementation of the 'repeat matrix' operation, used for constructing
matrices | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>&
in) | | op_repmat::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_repmat>&
in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap<T1> tmp(in.m); | | const unwrap_check<T1> tmp(in.m, out); | |
| | | const Mat<eT>& X = tmp.M; | |
| const Mat<eT>& X = tmp.M; | | | |
| const u32 r = in.aux_u32_a; | | | |
| const u32 c = in.aux_u32_b; | | | |
| | | | |
| arma_debug_check( (X.n_elem == 0), "op_repmat::apply(): given object has
no elements" ); | | arma_debug_check( (X.n_elem == 0), "op_repmat::apply(): given object has
no elements" ); | |
| | | | |
|
| if(X.n_elem == 1) // Element matrix | | const u32 copies_per_row = in.aux_u32_a; | |
| { | | const u32 copies_per_col = in.aux_u32_b; | |
| out.set_size(r,c); | | | |
| out.fill(X[0]); | | | |
| } | | | |
| else | | | |
| { | | | |
| if( X.n_cols == 1 ) // Column vector | | | |
| { | | | |
| Col<eT> Xc_tmp; | | | |
| Xc_tmp.zeros(X.n_rows * r); | | | |
| | | | |
|
| u32 counter = 0; | | out.set_size(X.n_rows * copies_per_row, X.n_cols * copies_per_col); | |
| for(u32 i = 0; i < r * X.n_rows; i += X.n_rows ) | | | |
| { | | | |
| Xc_tmp.rows(i, (X.n_rows*(counter+1))-1) = X; | | | |
| ++counter; | | | |
| } | | | |
| | | | |
|
| out = diagmat(Xc_tmp) * ones< Mat<eT> >(Xc_tmp.n_rows, c); | | for(u32 col = 0; col < out.n_cols; col += X.n_cols) | |
| } | | { | |
| else | | for(u32 row = 0; row < out.n_rows; row += X.n_rows) | |
| { | | { | |
|
| if(X.n_rows == 1) // Row vector | | out.submat(row, col, row+X.n_rows-1, col+X.n_cols-1) = X; | |
| { | | | |
| Row<eT> Xr_tmp; | | | |
| Xr_tmp.zeros(X.n_cols * c); | | | |
| | | | |
| u32 counter = 0; | | | |
| for(u32 i = 0; i < c * X.n_cols; i += X.n_cols) | | | |
| { | | | |
| Xr_tmp.cols(i, (X.n_cols * (counter+1)) - 1) = X; | | | |
| ++counter; | | | |
| } | | | |
| | | | |
| out = ones< Mat<eT> >(r, X.n_cols * c) * diagmat(Xr_tmp); | | | |
| } | | | |
| else // 2D matrix | | | |
| { | | | |
| Mat<eT> mr; | | | |
| mr.zeros(r * X.n_rows, X.n_cols); | | | |
| | | | |
| for(u32 i = 0; i < r; ++i) | | | |
| { | | | |
| mr.rows(i * X.n_rows, ((i+1) * X.n_rows) - 1) = X; | | | |
| } | | | |
| | | | |
| out.zeros(r*X.n_rows, c*X.n_cols); | | | |
| | | | |
| for(u32 i = 0; i < c; ++i) | | | |
| { | | | |
| out.cols(i * X.n_cols, ((i+1) * X.n_cols) - 1) = mr; | | | |
| } | | | |
| } | | | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 9 change blocks. |
| 58 lines changed or deleted | | 11 lines changed or added | |
|
| op_var_meat.hpp | | op_var_meat.hpp | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| eT acc2 = eT(0); | | eT acc2 = eT(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| const eT tmp_val = X[i]; | | const eT tmp_val = X[i]; | |
| acc1 += tmp_val; | | acc1 += tmp_val; | |
| acc2 += tmp_val*tmp_val; | | acc2 += tmp_val*tmp_val; | |
| } | | } | |
| | | | |
|
| const eT norm_val = (norm_type == 0) ? eT(n_elem-1) : eT(n_elem); | | const eT norm_val = (norm_type == 0) ? ( (n_elem > 1) ? eT(n_elem-1) : eT
(1) ) : eT(n_elem); | |
| const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | | const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! find the variance of an array (version for complex numbers) | | //! find the variance of an array (version for complex numbers) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| T | | T | |
| op_var::direct_var(const std::complex<T>* const X, const u32 n_elem, const
u32 norm_type) | | op_var::direct_var(const std::complex<T>* const X, const u32 n_elem, const
u32 norm_type) | |
| | | | |
| skipping to change at line 61 | | skipping to change at line 61 | |
| | | | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| T acc2 = T(0); | | T acc2 = T(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| acc1 += X[i]; | | acc1 += X[i]; | |
| acc2 += std::norm(X[i]); | | acc2 += std::norm(X[i]); | |
| } | | } | |
| | | | |
|
| const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem); | | const T norm_val = (norm_type == 0) ? ( (n_elem > 1) ? T(n_elem-1) : T(1)
) : T(n_elem); | |
| const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | | const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! For each row or for each column, find the variance. | | //! For each row or for each column, find the variance. | |
| //! The result is stored in a dense matrix that has either one column or on
e row. | | //! The result is stored in a dense matrix that has either one column or on
e row. | |
| //! The dimension, for which the variances are found, is set via the var()
function. | | //! The dimension, for which the variances are found, is set via the var()
function. | |
| template<typename eT> | | template<typename eT> | |
| | | | |
| skipping to change at line 101 | | skipping to change at line 101 | |
| out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); | | out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if(dim == 1) | | if(dim == 1) | |
| { | | { | |
| arma_extra_debug_print("op_var::apply(), dim = 1"); | | arma_extra_debug_print("op_var::apply(), dim = 1"); | |
| | | | |
| out.set_size(X.n_rows, 1); | | out.set_size(X.n_rows, 1); | |
| | | | |
|
| const eT norm_val = (norm_type == 0) ? eT(X.n_cols-1) : eT(X.n_cols); | | const eT norm_val = (norm_type == 0) ? ( (X.n_cols > 1) ? eT(X.n_cols-1
) : eT(1) ) : eT(X.n_cols); | |
| | | | |
| for(u32 row=0; row<X.n_rows; ++row) | | for(u32 row=0; row<X.n_rows; ++row) | |
| { | | { | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| eT acc2 = eT(0); | | eT acc2 = eT(0); | |
| | | | |
| for(u32 col=0; col<X.n_cols; ++col) | | for(u32 col=0; col<X.n_cols; ++col) | |
| { | | { | |
| const eT tmp_val = X.at(row,col); | | const eT tmp_val = X.at(row,col); | |
| acc1 += tmp_val; | | acc1 += tmp_val; | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 157 | |
| out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); | | out[col] = op_var::direct_var( X.colptr(col), X.n_rows, norm_type ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if(dim == 1) | | if(dim == 1) | |
| { | | { | |
| arma_extra_debug_print("op_var::apply(), dim = 1"); | | arma_extra_debug_print("op_var::apply(), dim = 1"); | |
| | | | |
| out.set_size(X.n_rows, 1); | | out.set_size(X.n_rows, 1); | |
| | | | |
|
| const T norm_val = (norm_type == 0) ? T(X.n_cols-1) : T(X.n_cols); | | const T norm_val = (norm_type == 0) ? ( (X.n_cols > 1) ? T(X.n_cols-1)
: T(1) ) : T(X.n_cols); | |
| | | | |
| for(u32 row=0; row<X.n_rows; ++row) | | for(u32 row=0; row<X.n_rows; ++row) | |
| { | | { | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| T acc2 = T(0); | | T acc2 = T(0); | |
| | | | |
| for(u32 col=0; col<X.n_cols; ++col) | | for(u32 col=0; col<X.n_cols; ++col) | |
| { | | { | |
| acc1 += X.at(row,col); | | acc1 += X.at(row,col); | |
| acc2 += std::norm(X.at(row,col)); | | acc2 += std::norm(X.at(row,col)); | |
| | | | |
| skipping to change at line 199 | | skipping to change at line 199 | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| eT acc2 = eT(0); | | eT acc2 = eT(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| const eT tmp_val = X[i]; | | const eT tmp_val = X[i]; | |
| acc1 += tmp_val; | | acc1 += tmp_val; | |
| acc2 += tmp_val*tmp_val; | | acc2 += tmp_val*tmp_val; | |
| } | | } | |
| | | | |
|
| const eT norm_val = (norm_type == 0) ? eT(n_elem-1) : eT(n_elem); | | const eT norm_val = (norm_type == 0) ? ( (n_elem > 1) ? eT(n_elem-1) : eT
(1) ) : eT(n_elem); | |
| const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | | const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! find the variance of a subview (version for complex numbers) | | //! find the variance of a subview (version for complex numbers) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| T | | T | |
| op_var::direct_var(const subview< std::complex<T> >& X, const u32 norm_type
) | | op_var::direct_var(const subview< std::complex<T> >& X, const u32 norm_type
) | |
| | | | |
| skipping to change at line 226 | | skipping to change at line 226 | |
| | | | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| T acc2 = T(0); | | T acc2 = T(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| acc1 += X[i]; | | acc1 += X[i]; | |
| acc2 += std::norm(X[i]); | | acc2 += std::norm(X[i]); | |
| } | | } | |
| | | | |
|
| const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem); | | const T norm_val = (norm_type == 0) ? ( (n_elem > 1) ? T(n_elem-1) : T(1)
) : T(n_elem); | |
| const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | | const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! find the variance of a diagview | | //! find the variance of a diagview | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
| op_var::direct_var(const diagview<eT>& X, const u32 norm_type) | | op_var::direct_var(const diagview<eT>& X, const u32 norm_type) | |
| | | | |
| skipping to change at line 252 | | skipping to change at line 252 | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| eT acc2 = eT(0); | | eT acc2 = eT(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| const eT tmp_val = X[i]; | | const eT tmp_val = X[i]; | |
| acc1 += tmp_val; | | acc1 += tmp_val; | |
| acc2 += tmp_val*tmp_val; | | acc2 += tmp_val*tmp_val; | |
| } | | } | |
| | | | |
|
| const eT norm_val = (norm_type == 0) ? eT(n_elem-1) : eT(n_elem); | | const eT norm_val = (norm_type == 0) ? ( (n_elem > 1) ? eT(n_elem-1) : eT
(1) ) : eT(n_elem); | |
| const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | | const eT var_val = (acc2 - acc1*acc1/eT(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! find the variance of a diagview (version for complex numbers) | | //! find the variance of a diagview (version for complex numbers) | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| T | | T | |
| op_var::direct_var(const diagview< std::complex<T> >& X, const u32 norm_typ
e) | | op_var::direct_var(const diagview< std::complex<T> >& X, const u32 norm_typ
e) | |
| | | | |
| skipping to change at line 279 | | skipping to change at line 279 | |
| | | | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| T acc2 = T(0); | | T acc2 = T(0); | |
| | | | |
| for(u32 i=0; i<n_elem; ++i) | | for(u32 i=0; i<n_elem; ++i) | |
| { | | { | |
| acc1 += X[i]; | | acc1 += X[i]; | |
| acc2 += std::norm(X[i]); | | acc2 += std::norm(X[i]); | |
| } | | } | |
| | | | |
|
| const T norm_val = (norm_type == 0) ? T(n_elem-1) : T(n_elem); | | const T norm_val = (norm_type == 0) ? ( (n_elem > 1) ? T(n_elem-1) : T(1)
) : T(n_elem); | |
| const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | | const T var_val = (acc2 - std::norm(acc1)/T(n_elem)) / norm_val; | |
| | | | |
| return var_val; | | return var_val; | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 8 change blocks. |
| 8 lines changed or deleted | | 8 lines changed or added | |
|