| Col_meat.hpp | | Col_meat.hpp | |
| | | | |
| skipping to change at line 23 | | skipping to change at line 23 | |
| //! \addtogroup Col | | //! \addtogroup Col | |
| //! @{ | | //! @{ | |
| | | | |
| //! construct an empty column vector | | //! construct an empty column vector | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Col<eT>::Col() | | Col<eT>::Col() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| | | access::rw(Mat<eT>::n_cols) = 1; | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| } | | } | |
| | | | |
| //! construct a column vector with the specified number of n_elem | | //! construct a column vector with the specified number of n_elem | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Col<eT>::Col(const u32 in_n_elem) | | Col<eT>::Col(const u32 in_n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| | | | |
|
| Mat<eT>::init(in_n_elem, (in_n_elem > 0) ? 1 : 0); | | Mat<eT>::init(in_n_elem, 1); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols) | | Col<eT>::Col(const u32 in_n_rows, const u32 in_n_cols) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| | | | |
| | | | |
| skipping to change at line 160 | | skipping to change at line 161 | |
| | | | |
| Mat<eT>::operator=(X.get_ref()); | | Mat<eT>::operator=(X.get_ref()); | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! construct a column vector from a given auxiliary array of eTs | | //! construct a column vector from a given auxiliary array of eTs | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
nst bool strict) | | Col<eT>::Col(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
nst bool strict) | |
|
| : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0), copy_aux_mem,
strict) | | : Mat<eT>(aux_mem, aux_length, 1, copy_aux_mem, strict) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| } | | } | |
| | | | |
| //! construct a column vector from a given auxiliary array of eTs | | //! construct a column vector from a given auxiliary array of eTs | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Col<eT>::Col(const eT* aux_mem, const u32 aux_length) | | Col<eT>::Col(const eT* aux_mem, const u32 aux_length) | |
|
| : Mat<eT>(aux_mem, aux_length, ((aux_length > 0) ? 1 : 0)) | | : Mat<eT>(aux_mem, aux_length, 1) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| Col<eT>::Col | | Col<eT>::Col | |
| | | | |
| skipping to change at line 487 | | skipping to change at line 488 | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Col<eT>::fixed<fixed_n_elem>::mem_setup() | | Col<eT>::fixed<fixed_n_elem>::mem_setup() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::n_rows) = fixed_n_elem; | | access::rw(Mat<eT>::n_rows) = fixed_n_elem; | |
|
| access::rw(Mat<eT>::n_cols) = (fixed_n_elem > 0) ? 1 : 0; | | access::rw(Mat<eT>::n_cols) = 1; | |
| access::rw(Mat<eT>::n_elem) = fixed_n_elem; | | access::rw(Mat<eT>::n_elem) = fixed_n_elem; | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
| access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local; | | access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Col<eT>::fixed<fixed_n_elem>::change_to_row() | | Col<eT>::fixed<fixed_n_elem>::change_to_row() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::n_cols) = fixed_n_elem; | | access::rw(Mat<eT>::n_cols) = fixed_n_elem; | |
|
| access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0; | | access::rw(Mat<eT>::n_rows) = 1; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| arma_inline | | arma_inline | |
| Col<eT>::fixed<fixed_n_elem>::fixed() | | Col<eT>::fixed<fixed_n_elem>::fixed() | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| mem_setup(); | | mem_setup(); | |
| | | | |
| skipping to change at line 576 | | skipping to change at line 577 | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| inline | | inline | |
| Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) | | Col<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| access::rw(Mat<eT>::n_rows) = fixed_n_elem; | | access::rw(Mat<eT>::n_rows) = fixed_n_elem; | |
|
| access::rw(Mat<eT>::n_cols) = (fixed_n_elem > 0) ? 1 : 0; | | access::rw(Mat<eT>::n_cols) = 1; | |
| access::rw(Mat<eT>::n_elem) = fixed_n_elem; | | access::rw(Mat<eT>::n_elem) = fixed_n_elem; | |
| access::rw(Mat<eT>::vec_state) = 1; | | access::rw(Mat<eT>::vec_state) = 1; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
| | | | |
| if(copy_aux_mem == true) | | if(copy_aux_mem == true) | |
| { | | { | |
| eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | | eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
| | | | |
| access::rw(Mat<eT>::mem) = dest; | | access::rw(Mat<eT>::mem) = dest; | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 6 lines changed or deleted | | 7 lines changed or added | |
|
| Mat_meat.hpp | | Mat_meat.hpp | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 77 | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| init(in_n_rows, in_n_cols); | | init(in_n_rows, in_n_cols); | |
| } | | } | |
| | | | |
| //! internal matrix construction; if the requested size is small enough, me
mory from the stack is used. otherwise memory is allocated via 'new' | | //! internal matrix construction; if the requested size is small enough, me
mory from the stack is used. otherwise memory is allocated via 'new' | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
|
| Mat<eT>::init(const u32 in_n_rows, const u32 in_n_cols) | | Mat<eT>::init(u32 in_n_rows, u32 in_n_cols) | |
| { | | { | |
| arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols
= %d") % in_n_rows % in_n_cols ); | | arma_extra_debug_sigprint( arma_boost::format("in_n_rows = %d, in_n_cols
= %d") % in_n_rows % in_n_cols ); | |
| | | | |
| const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) )
; | | const bool same_size = ( (n_rows == in_n_rows) && (n_cols == in_n_cols) )
; | |
| | | | |
| if(same_size == false) | | if(same_size == false) | |
| { | | { | |
| const u32 t_vec_state = vec_state; | | const u32 t_vec_state = vec_state; | |
| const u32 t_mem_state = mem_state; | | const u32 t_mem_state = mem_state; | |
| | | | |
| | | | |
| skipping to change at line 99 | | skipping to change at line 99 | |
| char* err_msg = 0; | | char* err_msg = 0; | |
| | | | |
| arma_debug_set_error | | arma_debug_set_error | |
| ( | | ( | |
| err_state, | | err_state, | |
| err_msg, | | err_msg, | |
| (t_mem_state == 3), | | (t_mem_state == 3), | |
| "Mat::init(): size is fixed and hence cannot be changed" | | "Mat::init(): size is fixed and hence cannot be changed" | |
| ); | | ); | |
| | | | |
|
| arma_debug_set_error | | if(t_vec_state > 0) | |
| ( | | { | |
| err_state, | | if( (in_n_rows == 0) && (in_n_cols == 0) ) | |
| err_msg, | | { | |
| ( | | if(t_vec_state == 1) | |
| (t_vec_state > 0) && | | { | |
| | | in_n_cols = 1; | |
| | | } | |
| | | else | |
| | | if(t_vec_state == 2) | |
| | | { | |
| | | in_n_rows = 1; | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | arma_debug_set_error | |
| ( | | ( | |
|
| ((t_vec_state == 1) && (in_n_cols > 1)) || | | err_state, | |
| ((t_vec_state == 2) && (in_n_rows > 1)) | | err_msg, | |
| ) | | ( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2) | |
| ), | | && (in_n_rows != 1)) ), | |
| "Mat::init(): object is a vector; requested size is not compatible" | | "Mat::init(): object is a vector; requested size is not compatibl | |
| ); | | e" | |
| | | ); | |
| | | } | |
| | | } | |
| | | | |
| // ensure that n_elem can hold the result of (n_rows * n_cols) | | // ensure that n_elem can hold the result of (n_rows * n_cols) | |
| // (due to a limitation in the C++98 standard: there is no official "lo
ng long" variable type) | | // (due to a limitation in the C++98 standard: there is no official "lo
ng long" variable type) | |
| arma_debug_set_error | | arma_debug_set_error | |
| ( | | ( | |
| err_state, | | err_state, | |
| err_msg, | | err_msg, | |
| (double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF), | | (double(in_n_rows) * double(in_n_cols)) > double(0xFFFFFFFF), | |
| "Mat::init(): requested size is too large" | | "Mat::init(): requested size is too large" | |
| ); | | ); | |
| | | | |
| skipping to change at line 503 | | skipping to change at line 515 | |
| const u32 t_vec_state = vec_state; | | const u32 t_vec_state = vec_state; | |
| | | | |
| bool layout_ok = false; | | bool layout_ok = false; | |
| | | | |
| if(t_vec_state == x_vec_state) | | if(t_vec_state == x_vec_state) | |
| { | | { | |
| layout_ok = true; | | layout_ok = true; | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| if( (t_vec_state == 1) && ( x_n_cols <= 1) ) | | if( (t_vec_state == 1) && ( x_n_cols == 1) ) | |
| { | | { | |
| layout_ok = true; | | layout_ok = true; | |
| } | | } | |
| | | | |
|
| if( (t_vec_state == 2) && ( x_n_rows <= 1) ) | | if( (t_vec_state == 2) && ( x_n_rows == 1) ) | |
| { | | { | |
| layout_ok = true; | | layout_ok = true; | |
| } | | } | |
| } | | } | |
| | | | |
| if( (x_mem_state == 0) && (x_n_elem > arma_config::mat_prealloc) && (la
yout_ok == true) ) | | if( (x_mem_state == 0) && (x_n_elem > arma_config::mat_prealloc) && (la
yout_ok == true) ) | |
| { | | { | |
| reset(); | | reset(); | |
| | | | |
| access::rw(n_rows) = x_n_rows; | | access::rw(n_rows) = x_n_rows; | |
| | | | |
| skipping to change at line 1924 | | skipping to change at line 1936 | |
| // } | | // } | |
| | | | |
| //! creation of diagview (diagonal) | | //! creation of diagview (diagonal) | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| diagview<eT> | | diagview<eT> | |
| Mat<eT>::diag(const s32 in_id) | | Mat<eT>::diag(const s32 in_id) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| if(n_elem > 0) | | const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; | |
| { | | const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; | |
| const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; | | | |
| const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; | | | |
| | | | |
|
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (row_offset >= n_rows) || (col_offset >= n_cols), | | ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c | |
| "Mat::diag(): requested diagonal out of bounds" | | ol_offset >= n_cols)), | |
| ); | | "Mat::diag(): requested diagonal out of bounds" | |
| | | ); | |
| | | | |
|
| const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | | const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | |
| | | | |
|
| return diagview<eT>(*this, row_offset, col_offset, len); | | return diagview<eT>(*this, row_offset, col_offset, len); | |
| } | | | |
| else | | | |
| { | | | |
| return diagview<eT>(*this, 0, 0, 0); | | | |
| } | | | |
| } | | } | |
| | | | |
| //! creation of diagview (diagonal) | | //! creation of diagview (diagonal) | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| const diagview<eT> | | const diagview<eT> | |
| Mat<eT>::diag(const s32 in_id) const | | Mat<eT>::diag(const s32 in_id) const | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| if(n_elem > 0) | | const u32 row_offset = (in_id < 0) ? -in_id : 0; | |
| { | | const u32 col_offset = (in_id > 0) ? in_id : 0; | |
| const u32 row_offset = (in_id < 0) ? -in_id : 0; | | | |
| const u32 col_offset = (in_id > 0) ? in_id : 0; | | | |
| | | | |
|
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (row_offset >= n_rows) || (col_offset >= n_cols), | | ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c | |
| "Mat::diag(): requested diagonal out of bounds" | | ol_offset >= n_cols)), | |
| ); | | "Mat::diag(): requested diagonal out of bounds" | |
| | | ); | |
| | | | |
|
| const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | | const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | |
| | | | |
|
| return diagview<eT>(*this, row_offset, col_offset, len); | | return diagview<eT>(*this, row_offset, col_offset, len); | |
| } | | | |
| else | | | |
| { | | | |
| return diagview<eT>(*this, 0, 0, 0); | | | |
| } | | | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2) | | Mat<eT>::swap_rows(const u32 in_row1, const u32 in_row2) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check | | arma_debug_check | |
| | | | |
| skipping to change at line 2013 | | skipping to change at line 2011 | |
| Mat<eT>::swap_cols(const u32 in_col1, const u32 in_col2) | | Mat<eT>::swap_cols(const u32 in_col1, const u32 in_col2) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (in_col1 >= n_cols) || (in_col2 >= n_cols), | | (in_col1 >= n_cols) || (in_col2 >= n_cols), | |
| "Mat::swap_cols(): out of bounds" | | "Mat::swap_cols(): out of bounds" | |
| ); | | ); | |
| | | | |
|
| eT* ptr1 = colptr(in_col1); | | if(n_elem > 0) | |
| eT* ptr2 = colptr(in_col2); | | | |
| | | | |
| for(u32 row=0; row<n_rows; ++row) | | | |
| { | | { | |
|
| const eT tmp = ptr1[row]; | | eT* ptr1 = colptr(in_col1); | |
| ptr1[row] = ptr2[row]; | | eT* ptr2 = colptr(in_col2); | |
| ptr2[row] = tmp; | | | |
| } | | | |
| | | | |
|
| | | for(u32 row=0; row<n_rows; ++row) | |
| | | { | |
| | | const eT tmp = ptr1[row]; | |
| | | ptr1[row] = ptr2[row]; | |
| | | ptr2[row] = tmp; | |
| | | } | |
| | | } | |
| } | | } | |
| | | | |
| //! remove specified row | | //! remove specified row | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::shed_row(const u32 row_num) | | Mat<eT>::shed_row(const u32 row_num) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
| skipping to change at line 3145 | | skipping to change at line 3145 | |
| return (n_elem == 0); | | return (n_elem == 0); | |
| } | | } | |
| | | | |
| //! returns true if the object can be interpreted as a column or row vector | | //! returns true if the object can be interpreted as a column or row vector | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| bool | | bool | |
| Mat<eT>::is_vec() const | | Mat<eT>::is_vec() const | |
| { | | { | |
|
| const u32 t_n_rows = n_rows; | | return ( (n_rows == 1) || (n_cols == 1) ); | |
| const u32 t_n_cols = n_cols; | | | |
| | | | |
| return ( (t_n_rows == 1) || (t_n_cols == 1) || ( (t_n_rows == 0) && (t_n_ | | | |
| cols == 0) ) ); | | | |
| } | | } | |
| | | | |
| //! returns true if the object has the same number of non-zero rows and col
umnns | | //! returns true if the object has the same number of non-zero rows and col
umnns | |
| template<typename eT> | | template<typename eT> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| bool | | bool | |
| Mat<eT>::is_square() const | | Mat<eT>::is_square() const | |
| { | | { | |
| return (n_rows == n_cols); | | return (n_rows == n_cols); | |
| | | | |
| skipping to change at line 3487 | | skipping to change at line 3484 | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::set_size(const u32 in_elem) | | Mat<eT>::set_size(const u32 in_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| switch(vec_state) | | switch(vec_state) | |
| { | | { | |
| case 0: | | case 0: | |
| case 1: | | case 1: | |
|
| init(in_elem, (in_elem > 0) ? 1 : 0); | | init(in_elem, 1); | |
| break; | | break; | |
| | | | |
| case 2: | | case 2: | |
|
| init((in_elem > 0) ? 1 : 0, in_elem); | | init(1, in_elem); | |
| break; | | break; | |
| | | | |
| default: | | default: | |
| ; | | ; | |
| } | | } | |
| } | | } | |
| | | | |
| //! change the matrix to have user specified dimensions (data is not preser
ved) | | //! change the matrix to have user specified dimensions (data is not preser
ved) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 3745 | | skipping to change at line 3742 | |
| return (*this).eye(); | | return (*this).eye(); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::reset() | | Mat<eT>::reset() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| init(0,0); | | switch(vec_state) | |
| | | { | |
| | | default: | |
| | | init(0, 0); | |
| | | break; | |
| | | | |
| | | case 1: | |
| | | init(0, 1); | |
| | | break; | |
| | | | |
| | | case 2: | |
| | | init(1, 0); | |
| | | break; | |
| | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::set_real(const Base<typename Mat<eT>::pod_type,T1>& X) | | Mat<eT>::set_real(const Base<typename Mat<eT>::pod_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| | | | |
End of changes. 20 change blocks. |
| 63 lines changed or deleted | | 76 lines changed or added | |
|
| Row_meat.hpp | | Row_meat.hpp | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| | | | |
| //! \addtogroup Row | | //! \addtogroup Row | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Row<eT>::Row() | | Row<eT>::Row() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| | | access::rw(Mat<eT>::n_rows) = 1; | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Row<eT>::Row(const u32 in_n_elem) | | Row<eT>::Row(const u32 in_n_elem) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| | | | |
|
| Mat<eT>::init((in_n_elem > 0) ? 1 : 0, in_n_elem); | | Mat<eT>::init(1, in_n_elem); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols) | | Row<eT>::Row(const u32 in_n_rows, const u32 in_n_cols) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| | | | |
| | | | |
| skipping to change at line 134 | | skipping to change at line 135 | |
| | | | |
| Mat<eT>::operator=(X.get_ref()); | | Mat<eT>::operator=(X.get_ref()); | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| //! construct a row vector from a given auxiliary array | | //! construct a row vector from a given auxiliary array | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
nst bool strict) | | Row<eT>::Row(eT* aux_mem, const u32 aux_length, const bool copy_aux_mem, co
nst bool strict) | |
|
| : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length, copy_aux_mem,
strict) | | : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| } | | } | |
| | | | |
| //! construct a row vector from a given auxiliary array | | //! construct a row vector from a given auxiliary array | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Row<eT>::Row(const eT* aux_mem, const u32 aux_length) | | Row<eT>::Row(const eT* aux_mem, const u32 aux_length) | |
|
| : Mat<eT>(aux_mem, ((aux_length > 0) ? 1 : 0), aux_length) | | : Mat<eT>(aux_mem, 1, aux_length) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| Row<eT>::Row | | Row<eT>::Row | |
| | | | |
| skipping to change at line 460 | | skipping to change at line 461 | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| arma_inline | | arma_inline | |
| void | | void | |
| Row<eT>::fixed<fixed_n_elem>::mem_setup() | | Row<eT>::fixed<fixed_n_elem>::mem_setup() | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0; | | access::rw(Mat<eT>::n_rows) = 1; | |
| access::rw(Mat<eT>::n_cols) = fixed_n_elem; | | access::rw(Mat<eT>::n_cols) = fixed_n_elem; | |
| access::rw(Mat<eT>::n_elem) = fixed_n_elem; | | access::rw(Mat<eT>::n_elem) = fixed_n_elem; | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
| access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local; | | access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>:
:mem_local; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| inline | | inline | |
| | | | |
| skipping to change at line 537 | | skipping to change at line 538 | |
| Row<eT>::init(A,B); | | Row<eT>::init(A,B); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<u32 fixed_n_elem> | | template<u32 fixed_n_elem> | |
| inline | | inline | |
| Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) | | Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem) | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
|
| access::rw(Mat<eT>::n_rows) = (fixed_n_elem > 0) ? 1 : 0; | | access::rw(Mat<eT>::n_rows) = 1; | |
| access::rw(Mat<eT>::n_cols) = fixed_n_elem; | | access::rw(Mat<eT>::n_cols) = fixed_n_elem; | |
| access::rw(Mat<eT>::n_elem) = fixed_n_elem; | | access::rw(Mat<eT>::n_elem) = fixed_n_elem; | |
| access::rw(Mat<eT>::vec_state) = 2; | | access::rw(Mat<eT>::vec_state) = 2; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
| | | | |
| if(copy_aux_mem == true) | | if(copy_aux_mem == true) | |
| { | | { | |
| eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | | eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local; | |
| | | | |
| access::rw(Mat<eT>::mem) = dest; | | access::rw(Mat<eT>::mem) = dest; | |
| | | | |
End of changes. 6 change blocks. |
| 5 lines changed or deleted | | 6 lines changed or added | |
|
| diskio_meat.hpp | | diskio_meat.hpp | |
| | | | |
| skipping to change at line 60 | | skipping to change at line 60 | |
| else | | else | |
| if(is_u32<eT>::value == true) | | if(is_u32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_TXT_IU004"); | | return std::string("ARMA_MAT_TXT_IU004"); | |
| } | | } | |
| else | | else | |
| if(is_s32<eT>::value == true) | | if(is_s32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_TXT_IS004"); | | return std::string("ARMA_MAT_TXT_IS004"); | |
| } | | } | |
|
| else | | // else | |
| if(is_u64<eT>::value == true) | | // if(is_u64<eT>::value == true) | |
| { | | // { | |
| return std::string("ARMA_MAT_TXT_IU008"); | | // return std::string("ARMA_MAT_TXT_IU008"); | |
| } | | // } | |
| else | | else | |
| if(is_float<eT>::value == true) | | if(is_float<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_TXT_FN004"); | | return std::string("ARMA_MAT_TXT_FN004"); | |
| } | | } | |
| else | | else | |
| if(is_double<eT>::value == true) | | if(is_double<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_TXT_FN008"); | | return std::string("ARMA_MAT_TXT_FN008"); | |
| } | | } | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 135 | |
| else | | else | |
| if(is_u32<eT>::value == true) | | if(is_u32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_BIN_IU004"); | | return std::string("ARMA_MAT_BIN_IU004"); | |
| } | | } | |
| else | | else | |
| if(is_s32<eT>::value == true) | | if(is_s32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_BIN_IS004"); | | return std::string("ARMA_MAT_BIN_IS004"); | |
| } | | } | |
|
| else | | // else | |
| if(is_u64<eT>::value == true) | | // if(is_u64<eT>::value == true) | |
| { | | // { | |
| return std::string("ARMA_MAT_BIN_IU008"); | | // return std::string("ARMA_MAT_BIN_IU008"); | |
| } | | // } | |
| else | | else | |
| if(is_float<eT>::value == true) | | if(is_float<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_BIN_FN004"); | | return std::string("ARMA_MAT_BIN_FN004"); | |
| } | | } | |
| else | | else | |
| if(is_double<eT>::value == true) | | if(is_double<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_MAT_BIN_FN008"); | | return std::string("ARMA_MAT_BIN_FN008"); | |
| } | | } | |
| | | | |
| skipping to change at line 210 | | skipping to change at line 210 | |
| else | | else | |
| if(is_u32<eT>::value == true) | | if(is_u32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_TXT_IU004"); | | return std::string("ARMA_CUB_TXT_IU004"); | |
| } | | } | |
| else | | else | |
| if(is_s32<eT>::value == true) | | if(is_s32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_TXT_IS004"); | | return std::string("ARMA_CUB_TXT_IS004"); | |
| } | | } | |
|
| else | | // else | |
| if(is_u64<eT>::value == true) | | // if(is_u64<eT>::value == true) | |
| { | | // { | |
| return std::string("ARMA_CUB_TXT_IU008"); | | // return std::string("ARMA_CUB_TXT_IU008"); | |
| } | | // } | |
| else | | else | |
| if(is_float<eT>::value == true) | | if(is_float<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_TXT_FN004"); | | return std::string("ARMA_CUB_TXT_FN004"); | |
| } | | } | |
| else | | else | |
| if(is_double<eT>::value == true) | | if(is_double<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_TXT_FN008"); | | return std::string("ARMA_CUB_TXT_FN008"); | |
| } | | } | |
| | | | |
| skipping to change at line 285 | | skipping to change at line 285 | |
| else | | else | |
| if(is_u32<eT>::value == true) | | if(is_u32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_BIN_IU004"); | | return std::string("ARMA_CUB_BIN_IU004"); | |
| } | | } | |
| else | | else | |
| if(is_s32<eT>::value == true) | | if(is_s32<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_BIN_IS004"); | | return std::string("ARMA_CUB_BIN_IS004"); | |
| } | | } | |
|
| else | | // else | |
| if(is_u64<eT>::value == true) | | // if(is_u64<eT>::value == true) | |
| { | | // { | |
| return std::string("ARMA_CUB_BIN_IU008"); | | // return std::string("ARMA_CUB_BIN_IU008"); | |
| } | | // } | |
| else | | else | |
| if(is_float<eT>::value == true) | | if(is_float<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_BIN_FN004"); | | return std::string("ARMA_CUB_BIN_FN004"); | |
| } | | } | |
| else | | else | |
| if(is_double<eT>::value == true) | | if(is_double<eT>::value == true) | |
| { | | { | |
| return std::string("ARMA_CUB_BIN_FN008"); | | return std::string("ARMA_CUB_BIN_FN008"); | |
| } | | } | |
| | | | |
End of changes. 4 change blocks. |
| 20 lines changed or deleted | | 20 lines changed or added | |
|
| fn_accu.hpp | | fn_accu.hpp | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| typename T1::elem_type | | typename T1::elem_type | |
| accu(const Base<typename T1::elem_type,T1>& X) | | accu(const Base<typename T1::elem_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename Proxy<T1>::ea_type ea_type; | | typedef typename Proxy<T1>::ea_type ea_type; | |
| | | | |
| const Proxy<T1> A(X.get_ref()); | | const Proxy<T1> A(X.get_ref()); | |
| | | | |
|
| ea_type P = A.get_ea(); | | if(Proxy<T1>::prefer_at_accessor == false) | |
| const u32 n_elem = A.get_n_elem(); | | { | |
| | | ea_type P = A.get_ea(); | |
| | | const u32 n_elem = A.get_n_elem(); | |
| | | | |
|
| eT val1 = eT(0); | | eT val1 = eT(0); | |
| eT val2 = eT(0); | | eT val2 = eT(0); | |
| | | | |
|
| u32 i,j; | | u32 i,j; | |
| | | | |
|
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| { | | { | |
| val1 += P[i]; | | val1 += P[i]; | |
| val2 += P[j]; | | val2 += P[j]; | |
| } | | } | |
| | | | |
|
| if(i < n_elem) | | if(i < n_elem) | |
| { | | { | |
| val1 += P[i]; | | val1 += P[i]; | |
| | | } | |
| | | | |
| | | return val1 + val2; | |
| } | | } | |
|
| | | else | |
| | | { | |
| | | const u32 n_rows = A.get_n_rows(); | |
| | | const u32 n_cols = A.get_n_cols(); | |
| | | | |
|
| return val1 + val2; | | eT val = eT(0); | |
| | | | |
| | | for(u32 col=0; col<n_cols; ++col) | |
| | | { | |
| | | for(u32 row=0; row<n_rows; ++row) | |
| | | { | |
| | | val += A.at(row,col); | |
| | | } | |
| | | } | |
| | | | |
| | | return val; | |
| | | } | |
| } | | } | |
| | | | |
| //! explicit handling of Hamming norm (also known as zero norm) | | //! explicit handling of Hamming norm (also known as zero norm) | |
| template<typename T1> | | template<typename T1> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| u32 | | u32 | |
| accu(const mtOp<u32,T1,op_rel_noteq>& X) | | accu(const mtOp<u32,T1,op_rel_noteq>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| skipping to change at line 95 | | skipping to change at line 115 | |
| typename T1::elem_type | | typename T1::elem_type | |
| accu(const BaseCube<typename T1::elem_type,T1>& X) | | accu(const BaseCube<typename T1::elem_type,T1>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename ProxyCube<T1>::ea_type ea_type; | | typedef typename ProxyCube<T1>::ea_type ea_type; | |
| | | | |
| const ProxyCube<T1> A(X.get_ref()); | | const ProxyCube<T1> A(X.get_ref()); | |
| | | | |
|
| ea_type P = A.get_ea(); | | if(ProxyCube<T1>::prefer_at_accessor == false) | |
| const u32 n_elem = A.get_n_elem(); | | { | |
| | | | |
|
| eT val1 = eT(0); | | ea_type P = A.get_ea(); | |
| eT val2 = eT(0); | | const u32 n_elem = A.get_n_elem(); | |
| | | | |
|
| u32 i,j; | | eT val1 = eT(0); | |
| | | eT val2 = eT(0); | |
| | | | |
|
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | u32 i,j; | |
| { | | | |
| val1 += P[i]; | | | |
| val2 += P[j]; | | | |
| } | | | |
| | | | |
|
| if(i < n_elem) | | for(i=0, j=1; j<n_elem; i+=2, j+=2) | |
| { | | { | |
| val1 += P[i]; | | val1 += P[i]; | |
| | | val2 += P[j]; | |
| | | } | |
| | | | |
| | | if(i < n_elem) | |
| | | { | |
| | | val1 += P[i]; | |
| | | } | |
| | | | |
| | | return val1 + val2; | |
| } | | } | |
|
| | | else | |
| | | { | |
| | | const u32 n_rows = A.get_n_rows(); | |
| | | const u32 n_cols = A.get_n_cols(); | |
| | | const u32 n_slices = A.get_n_slices(); | |
| | | | |
| | | eT val = eT(0); | |
| | | | |
|
| return val1 + val2; | | for(u32 slice=0; slice<n_slices; ++slice) | |
| | | { | |
| | | for(u32 col=0; col<n_cols; ++col) | |
| | | { | |
| | | for(u32 row=0; row<n_rows; ++row) | |
| | | { | |
| | | val += A.at(row,col,slice); | |
| | | } | |
| | | } | |
| | | } | |
| | | | |
| | | return val; | |
| | | } | |
| } | | } | |
| | | | |
| //! accumulate the elements of a diagview | | //! accumulate the elements of a diagview | |
| template<typename eT> | | template<typename eT> | |
| arma_pure | | arma_pure | |
| arma_warn_unused | | arma_warn_unused | |
| inline | | inline | |
| eT | | eT | |
| accu(const diagview<eT>& X) | | accu(const diagview<eT>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 149 | | skipping to change at line 194 | |
| //! accumulate the elements of a subview (submatrix) | | //! accumulate the elements of a subview (submatrix) | |
| template<typename eT> | | template<typename eT> | |
| arma_pure | | arma_pure | |
| arma_warn_unused | | arma_warn_unused | |
| inline | | inline | |
| eT | | eT | |
| accu(const subview<eT>& S) | | accu(const subview<eT>& S) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| if(S.n_elem > 0) | | const u32 S_n_rows = S.n_rows; | |
| { | | const u32 S_n_cols = S.n_cols; | |
| const u32 S_n_rows = S.n_rows; | | const u32 S_n_elem = S.n_elem; | |
| const u32 S_n_cols = S.n_cols; | | | |
| | | | |
|
| eT val = eT(0); | | eT val = eT(0); | |
| | | | |
|
| | | if(S_n_elem > 0) | |
| | | { | |
| for(u32 col=0; col<S_n_cols; ++col) | | for(u32 col=0; col<S_n_cols; ++col) | |
| { | | { | |
| val += arrayops::accumulate( S.colptr(col), S_n_rows ); | | val += arrayops::accumulate( S.colptr(col), S_n_rows ); | |
| } | | } | |
|
| | | | |
| return val; | | | |
| } | | | |
| else | | | |
| { | | | |
| return eT(0); | | | |
| } | | } | |
|
| | | | |
| | | return val; | |
| } | | } | |
| | | | |
| //! accumulate the elements of a subview_row | | //! accumulate the elements of a subview_row | |
| template<typename eT> | | template<typename eT> | |
| arma_pure | | arma_pure | |
| arma_warn_unused | | arma_warn_unused | |
| inline | | inline | |
| eT | | eT | |
| accu(const subview_row<eT>& S) | | accu(const subview_row<eT>& S) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const Mat<eT>& X = S.m; | | const Mat<eT>& X = S.m; | |
| | | | |
|
| const u32 row = S.aux_row1; | | const u32 n_elem = S.n_elem; | |
| const u32 start_col = S.aux_col1; | | const u32 row = S.aux_row1; | |
| const u32 end_col_plus_1 = start_col + S.n_cols; | | const u32 start_col = S.aux_col1; | |
| | | const u32 end_col_p1 = start_col + S.n_cols; | |
| // S.n_cols might be equal to zero, | | | |
| // hence the loop below has a "less than" condition | | | |
| | | | |
| eT val = eT(0); | | eT val = eT(0); | |
| | | | |
|
| u32 i,j; | | if(n_elem > 0) | |
| | | | |
| for(i=start_col, j=start_col+1; j < end_col_plus_1; i+=2, j+=2) | | | |
| { | | { | |
|
| val += X.at(row,i); | | u32 i,j; | |
| val += X.at(row,j); | | | |
| } | | | |
| | | | |
|
| if(i < end_col_plus_1) | | for(i=start_col, j=start_col+1; j < end_col_p1; i+=2, j+=2) | |
| { | | { | |
| val += X.at(row,i); | | val += X.at(row,i); | |
| | | val += X.at(row,j); | |
| | | } | |
| | | | |
| | | if(i < end_col_p1) | |
| | | { | |
| | | val += X.at(row,i); | |
| | | } | |
| } | | } | |
| | | | |
| return val; | | return val; | |
| } | | } | |
| | | | |
| //! accumulate the elements of a subview_col | | //! accumulate the elements of a subview_col | |
| template<typename eT> | | template<typename eT> | |
| arma_pure | | arma_pure | |
| arma_warn_unused | | arma_warn_unused | |
| inline | | inline | |
| eT | | eT | |
| accu(const subview_col<eT>& S) | | accu(const subview_col<eT>& S) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return arrayops::accumulate( S.colptr(0), S.n_rows ); | | return (S.n_elem > 0) ? arrayops::accumulate( S.colptr(0), S.n_rows ) : e
T(0); | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 24 change blocks. |
| 55 lines changed or deleted | | 98 lines changed or added | |
|
| fn_prod.hpp | | fn_prod.hpp | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<T1, op_prod>(X.get_ref(), dim, 0); | | return Op<T1, op_prod>(X.get_ref(), dim, 0); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'product of all values' operation for a row vector | | //! Immediate 'product of all values' operation for a row vector | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| prod(const Row<eT>& X) | | prod(const Row<eT>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return arrayops::product(X.memptr(), X.n_elem); | | return arrayops::product(X.memptr(), X.n_elem); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'product of all values' operation for a column vector | | //! Immediate 'product of all values' operation for a column vector | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| prod(const Col<eT>& X) | | prod(const Col<eT>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return arrayops::product(X.memptr(), X.n_elem); | | return arrayops::product(X.memptr(), X.n_elem); | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! Immediate 'product of all values' operation, | | //! Immediate 'product of all values' operation, | |
| | | | |
| skipping to change at line 91 | | skipping to change at line 93 | |
| prod(const Op<T1, op_prod>& in, const u32 dim) | | prod(const Op<T1, op_prod>& in, const u32 dim) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); | | return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); | |
| } | | } | |
| | | | |
| //! product of all values of a subview_row | | //! product of all values of a subview_row | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| prod(const subview_row<eT>& S) | | prod(const subview_row<eT>& S) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const Mat<eT>& X = S.m; | | const Mat<eT>& X = S.m; | |
| | | | |
|
| | | const u32 n_elem = S.n_elem; | |
| const u32 row = S.aux_row1; | | const u32 row = S.aux_row1; | |
| const u32 start_col = S.aux_col1; | | const u32 start_col = S.aux_col1; | |
| const u32 end_col_plus_1 = start_col + S.n_cols; | | const u32 end_col_plus_1 = start_col + S.n_cols; | |
| | | | |
| eT val = eT(1); | | eT val = eT(1); | |
| | | | |
|
| for(u32 col=start_col; col<end_col_plus_1; ++col) | | if(n_elem > 0) | |
| { | | { | |
|
| val *= X.at(row,col); | | for(u32 col=start_col; col<end_col_plus_1; ++col) | |
| | | { | |
| | | val *= X.at(row,col); | |
| | | } | |
| } | | } | |
| | | | |
| return val; | | return val; | |
| } | | } | |
| | | | |
| //! product of all values of a subview_col | | //! product of all values of a subview_col | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
|
| | | arma_warn_unused | |
| eT | | eT | |
| prod(const subview_col<eT>& S) | | prod(const subview_col<eT>& S) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| return arrayops::product( S.colptr(0), S.n_rows ); | | return (S.n_elem > 0) ? arrayops::product( S.colptr(0), S.n_rows ) : eT(1
); | |
| } | | } | |
| | | | |
| //! product of all values of a diagview | | //! product of all values of a diagview | |
| template<typename eT> | | template<typename eT> | |
|
| | | arma_warn_unused | |
| inline | | inline | |
| eT | | eT | |
| prod(const diagview<eT>& X) | | prod(const diagview<eT>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 X_n_elem = X.n_elem; | | const u32 X_n_elem = X.n_elem; | |
| | | | |
| eT val = eT(1); | | eT val = eT(1); | |
| | | | |
| | | | |
End of changes. 9 change blocks. |
| 3 lines changed or deleted | | 12 lines changed or added | |
|
| op_dot_meat.hpp | | op_dot_meat.hpp | |
|
| // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2008-2010 Conrad Sanderson | | // Copyright (C) 2008-2011 Conrad Sanderson | |
| // | | // | |
| // 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 192 | | skipping to change at line 192 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename Proxy<T1>::ea_type ea_type1; | | typedef typename Proxy<T1>::ea_type ea_type1; | |
| typedef typename Proxy<T2>::ea_type ea_type2; | | typedef typename Proxy<T2>::ea_type ea_type2; | |
| | | | |
| const Proxy<T1> A(X.get_ref()); | | const Proxy<T1> A(X.get_ref()); | |
| const Proxy<T2> B(Y.get_ref()); | | const Proxy<T2> B(Y.get_ref()); | |
| | | | |
|
| arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects mus
t have the same number of elements" ); | | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) && (Proxy
<T2>::prefer_at_accessor); | |
| | | | |
|
| const u32 N = A.get_n_elem(); | | if(prefer_at_accessor == false) | |
| ea_type1 PA = A.get_ea(); | | { | |
| ea_type2 PB = B.get_ea(); | | arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "dot(): objects m | |
| | | ust have the same number of elements" ); | |
| | | | |
|
| eT val1 = eT(0); | | const u32 N = A.get_n_elem(); | |
| eT val2 = eT(0); | | ea_type1 PA = A.get_ea(); | |
| | | ea_type2 PB = B.get_ea(); | |
| | | | |
|
| u32 i,j; | | eT val1 = eT(0); | |
| | | eT val2 = eT(0); | |
| | | | |
|
| for(i=0, j=1; j<N; i+=2, j+=2) | | u32 i,j; | |
| { | | | |
| val1 += PA[i] * PB[i]; | | | |
| val2 += PA[j] * PB[j]; | | | |
| } | | | |
| | | | |
|
| if(i < N) | | for(i=0, j=1; j<N; i+=2, j+=2) | |
| | | { | |
| | | val1 += PA[i] * PB[i]; | |
| | | val2 += PA[j] * PB[j]; | |
| | | } | |
| | | | |
| | | if(i < N) | |
| | | { | |
| | | val1 += PA[i] * PB[i]; | |
| | | } | |
| | | | |
| | | return val1 + val2; | |
| | | } | |
| | | else | |
| { | | { | |
|
| val1 += PA[i] * PB[i]; | | return op_dot::apply_unwrap(A.Q, B.Q); | |
| } | | } | |
|
| | | | |
| return val1 + val2; | | | |
| } | | } | |
| | | | |
| // | | // | |
| // op_norm_dot | | // op_norm_dot | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot | | arma_hot | |
|
| arma_inline | | inline | |
| typename T1::elem_type | | typename T1::elem_type | |
| op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ
ename T1::elem_type,T2>& Y) | | op_norm_dot::apply(const Base<typename T1::elem_type,T1>& X, const Base<typ
ename T1::elem_type,T2>& Y) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| typedef typename Proxy<T1>::ea_type ea_type1; | | typedef typename Proxy<T1>::ea_type ea_type1; | |
| typedef typename Proxy<T2>::ea_type ea_type2; | | typedef typename Proxy<T2>::ea_type ea_type2; | |
| | | | |
|
| const Proxy<T1> A(X.get_ref()); | | const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor) && (Proxy | |
| const Proxy<T2> B(Y.get_ref()); | | <T2>::prefer_at_accessor); | |
| | | | |
| | | if(prefer_at_accessor == false) | |
| | | { | |
| | | const Proxy<T1> A(X.get_ref()); | |
| | | const Proxy<T2> B(Y.get_ref()); | |
| | | | |
| | | arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): obje | |
| | | cts must have the same number of elements" ); | |
| | | | |
| | | const u32 N = A.get_n_elem(); | |
| | | ea_type1 PA = A.get_ea(); | |
| | | ea_type2 PB = B.get_ea(); | |
| | | | |
| | | eT acc1 = eT(0); | |
| | | eT acc2 = eT(0); | |
| | | eT acc3 = eT(0); | |
| | | | |
| | | for(u32 i=0; i<N; ++i) | |
| | | { | |
| | | const eT tmpA = PA[i]; | |
| | | const eT tmpB = PB[i]; | |
| | | | |
| | | acc1 += tmpA * tmpA; | |
| | | acc2 += tmpB * tmpB; | |
| | | acc3 += tmpA * tmpB; | |
| | | } | |
| | | | |
| | | return acc3 / ( std::sqrt(acc1 * acc2) ); | |
| | | } | |
| | | else | |
| | | { | |
| | | return op_norm_dot::apply_unwrap(X, Y); | |
| | | } | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | arma_hot | |
| | | inline | |
| | | typename T1::elem_type | |
| | | op_norm_dot::apply_unwrap(const Base<typename T1::elem_type,T1>& X, const B | |
| | | ase<typename T1::elem_type,T2>& Y) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | typedef typename T1::elem_type eT; | |
| | | | |
| | | const unwrap<T1> tmp1(X.get_ref()); | |
| | | const unwrap<T2> tmp2(Y.get_ref()); | |
| | | | |
| | | const Mat<eT>& A = tmp1.M; | |
| | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| | | arma_debug_check( (A.n_elem != B.n_elem), "norm_dot(): objects must have | |
| | | the same number of elements" ); | |
| | | | |
|
| arma_debug_check( (A.get_n_elem() != B.get_n_elem()), "norm_dot(): object
s must have the same number of elements" ); | | const u32 N = A.n_elem; | |
| | | | |
|
| const u32 N = A.get_n_elem(); | | const eT* A_mem = A.memptr(); | |
| ea_type1 PA = A.get_ea(); | | const eT* B_mem = B.memptr(); | |
| ea_type2 PB = B.get_ea(); | | | |
| | | | |
| eT acc1 = eT(0); | | eT acc1 = eT(0); | |
| eT acc2 = eT(0); | | eT acc2 = eT(0); | |
| eT acc3 = eT(0); | | eT acc3 = eT(0); | |
| | | | |
| for(u32 i=0; i<N; ++i) | | for(u32 i=0; i<N; ++i) | |
| { | | { | |
|
| const eT tmpA = PA[i]; | | const eT tmpA = A_mem[i]; | |
| const eT tmpB = PB[i]; | | const eT tmpB = B_mem[i]; | |
| | | | |
| acc1 += tmpA * tmpA; | | acc1 += tmpA * tmpA; | |
| acc2 += tmpB * tmpB; | | acc2 += tmpB * tmpB; | |
| acc3 += tmpA * tmpB; | | acc3 += tmpA * tmpB; | |
| } | | } | |
| | | | |
| return acc3 / ( std::sqrt(acc1 * acc2) ); | | return acc3 / ( std::sqrt(acc1 * acc2) ); | |
| } | | } | |
| | | | |
| // | | // | |
| | | | |
End of changes. 14 change blocks. |
| 27 lines changed or deleted | | 90 lines changed or added | |
|
| promote_type.hpp | | promote_type.hpp | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| arma_inline static void check() {} | | arma_inline static void check() {} | |
| }; | | }; | |
| | | | |
| template<typename T> struct promote_type<T, T> : public promo
te_type_ok { typedef T result; }; | | template<typename T> struct promote_type<T, T> : public promo
te_type_ok { typedef T result; }; | |
| template<typename T> struct promote_type<std::complex<T>, T> : public promo
te_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, T> : public promo
te_type_ok { typedef std::complex<T> result; }; | |
| | | | |
| template<> struct promote_type<std::complex<double>, std::complex<float> >
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<std::complex<double>, std::complex<float> >
: public promote_type_ok { typedef std::complex<double> result; }; | |
| template<> struct promote_type<std::complex<double>, float>
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<std::complex<double>, float>
: public promote_type_ok { typedef std::complex<double> result; }; | |
| template<> struct promote_type<std::complex<float>, double>
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<std::complex<float>, double>
: public promote_type_ok { typedef std::complex<double> result; }; | |
| | | | |
|
| template<typename T> struct promote_type<std::complex<T>, u64> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | // template<typename T> struct promote_type<std::complex<T>, u64> : public
promote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, s32> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, s32> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, u32> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, u32> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, s16> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, s16> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, u16> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, u16> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, s8> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, s8> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<std::complex<T>, u8> : public pro
mote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<std::complex<T>, u8> : public pro
mote_type_ok { typedef std::complex<T> result; }; | |
| | | | |
| template<> struct promote_type<double, float> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, float> : public promote_type_ok { ty
pedef double result; }; | |
|
| template<> struct promote_type<double, u64 > : public promote_type_ok { ty
pedef double result; }; | | // template<> struct promote_type<double, u64 > : public promote_type_ok {
typedef double result; }; | |
| template<> struct promote_type<double, s32 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, s32 > : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<double, u32 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, u32 > : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<double, s16 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, s16 > : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<double, u16 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, u16 > : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<double, s8 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, s8 > : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<double, u8 > : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<double, u8 > : public promote_type_ok { ty
pedef double result; }; | |
| | | | |
|
| template<> struct promote_type<float, u64> : public promote_type_ok { typed
ef float result; }; | | // template<> struct promote_type<float, u64> : public promote_type_ok { ty
pedef float result; }; | |
| template<> struct promote_type<float, s32> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, s32> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<float, u32> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, u32> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<float, s16> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, s16> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<float, u16> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, u16> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<float, s8 > : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, s8 > : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<float, u8 > : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<float, u8 > : public promote_type_ok { typed
ef float result; }; | |
| | | | |
|
| template<> struct promote_type<u64, u32> : public promote_type_ok { typedef | | // template<> struct promote_type<u64, u32> : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| template<> struct promote_type<u64, u16> : public promote_type_ok { typedef | | // template<> struct promote_type<u64, u16> : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| template<> struct promote_type<u64, u8 > : public promote_type_ok { typedef | | // template<> struct promote_type<u64, u8 > : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| | | | |
| template<> struct promote_type<s32, u32> : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<s32, u32> : public promote_type_ok { typedef
s32 result; }; // float ? | |
| template<> struct promote_type<s32, s16> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s32, s16> : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<s32, u16> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s32, u16> : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<s32, s8 > : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s32, s8 > : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<s32, u8 > : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s32, u8 > : public promote_type_ok { typedef
s32 result; }; | |
| | | | |
| template<> struct promote_type<u32, s16> : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<u32, s16> : public promote_type_ok { typedef
s32 result; }; // float ? | |
| template<> struct promote_type<u32, u16> : public promote_type_ok { typedef
u32 result; }; | | template<> struct promote_type<u32, u16> : public promote_type_ok { typedef
u32 result; }; | |
| template<> struct promote_type<u32, s8 > : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<u32, s8 > : public promote_type_ok { typedef
s32 result; }; // float ? | |
| | | | |
| skipping to change at line 98 | | skipping to change at line 98 | |
| | | | |
| // | | // | |
| // mirrored versions | | // mirrored versions | |
| | | | |
| template<typename T> struct promote_type<T, std::complex<T> > : public prom
ote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<T, std::complex<T> > : public prom
ote_type_ok { typedef std::complex<T> result; }; | |
| | | | |
| template<> struct promote_type<std::complex<float>, std::complex<double> >
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<std::complex<float>, std::complex<double> >
: public promote_type_ok { typedef std::complex<double> result; }; | |
| template<> struct promote_type<float, std::complex<double> >
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<float, std::complex<double> >
: public promote_type_ok { typedef std::complex<double> result; }; | |
| template<> struct promote_type<double, std::complex<float> >
: public promote_type_ok { typedef std::complex<double> result; }; | | template<> struct promote_type<double, std::complex<float> >
: public promote_type_ok { typedef std::complex<double> result; }; | |
| | | | |
|
| template<typename T> struct promote_type<u64, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | // template<typename T> struct promote_type<u64, std::complex<T> > : public
promote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<s32, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<s32, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<u32, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<u32, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<s16, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<s16, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<u16, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<u16, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<s8, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<s8, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| template<typename T> struct promote_type<u8, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | | template<typename T> struct promote_type<u8, std::complex<T> > : public pr
omote_type_ok { typedef std::complex<T> result; }; | |
| | | | |
| template<> struct promote_type<float, double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<float, double> : public promote_type_ok { ty
pedef double result; }; | |
|
| template<> struct promote_type<u64 , double> : public promote_type_ok { ty
pedef double result; }; | | // template<> struct promote_type<u64 , double> : public promote_type_ok {
typedef double result; }; | |
| template<> struct promote_type<s32 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<s32 , double> : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<u32 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<u32 , double> : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<s16 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<s16 , double> : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<u16 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<u16 , double> : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<s8 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<s8 , double> : public promote_type_ok { ty
pedef double result; }; | |
| template<> struct promote_type<u8 , double> : public promote_type_ok { ty
pedef double result; }; | | template<> struct promote_type<u8 , double> : public promote_type_ok { ty
pedef double result; }; | |
| | | | |
|
| template<> struct promote_type<u64, float> : public promote_type_ok { typed
ef float result; }; | | // template<> struct promote_type<u64, float> : public promote_type_ok { ty
pedef float result; }; | |
| template<> struct promote_type<s32, float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<s32, float> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<u32, float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<u32, float> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<s16, float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<s16, float> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<u16, float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<u16, float> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<s8 , float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<s8 , float> : public promote_type_ok { typed
ef float result; }; | |
| template<> struct promote_type<u8 , float> : public promote_type_ok { typed
ef float result; }; | | template<> struct promote_type<u8 , float> : public promote_type_ok { typed
ef float result; }; | |
| | | | |
|
| template<> struct promote_type<u32, u64> : public promote_type_ok { typedef | | // template<> struct promote_type<u32, u64> : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| template<> struct promote_type<u16, u64> : public promote_type_ok { typedef | | // template<> struct promote_type<u16, u64> : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| template<> struct promote_type<u8, u64> : public promote_type_ok { typedef | | // template<> struct promote_type<u8, u64> : public promote_type_ok { type | |
| u64 result; }; | | def u64 result; }; | |
| | | | |
| template<> struct promote_type<u32, s32> : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<u32, s32> : public promote_type_ok { typedef
s32 result; }; // float ? | |
| template<> struct promote_type<s16, s32> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s16, s32> : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<u16, s32> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<u16, s32> : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<s8 , s32> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<s8 , s32> : public promote_type_ok { typedef
s32 result; }; | |
| template<> struct promote_type<u8 , s32> : public promote_type_ok { typedef
s32 result; }; | | template<> struct promote_type<u8 , s32> : public promote_type_ok { typedef
s32 result; }; | |
| | | | |
| template<> struct promote_type<s16, u32> : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<s16, u32> : public promote_type_ok { typedef
s32 result; }; // float ? | |
| template<> struct promote_type<u16, u32> : public promote_type_ok { typedef
u32 result; }; | | template<> struct promote_type<u16, u32> : public promote_type_ok { typedef
u32 result; }; | |
| template<> struct promote_type<s8 , u32> : public promote_type_ok { typedef
s32 result; }; // float ? | | template<> struct promote_type<s8 , u32> : public promote_type_ok { typedef
s32 result; }; // float ? | |
| | | | |
End of changes. 8 change blocks. |
| 18 lines changed or deleted | | 18 lines changed or added | |
|
| running_stat_meat.hpp | | running_stat_meat.hpp | |
|
| // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2009-2010 Conrad Sanderson | | // Copyright (C) 2009-2011 Conrad Sanderson | |
| // | | // | |
| // 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 46 | | skipping to change at line 46 | |
| { | | { | |
| const u32 max_val = 0xffffffff; | | const u32 max_val = 0xffffffff; | |
| | | | |
| if(i_count < max_val) | | if(i_count < max_val) | |
| { | | { | |
| i_count++; | | i_count++; | |
| } | | } | |
| else | | else | |
| { | | { | |
| d_count += eT(max_val); | | d_count += eT(max_val); | |
|
| i_count = 1; | | i_count = 0; | |
| } | | } | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| arma_counter<eT>::operator++(int) | | arma_counter<eT>::operator++(int) | |
| { | | { | |
| | | | |
| skipping to change at line 72 | | skipping to change at line 72 | |
| void | | void | |
| arma_counter<eT>::reset() | | arma_counter<eT>::reset() | |
| { | | { | |
| d_count = eT(0); | | d_count = eT(0); | |
| i_count = u32(0); | | i_count = u32(0); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| arma_counter<eT>::value() | | arma_counter<eT>::value() const | |
| const | | | |
| { | | { | |
| return d_count + eT(i_count); | | return d_count + eT(i_count); | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| arma_counter<eT>::value_plus_1() | | arma_counter<eT>::value_plus_1() const | |
| const | | | |
| { | | { | |
| const u32 max_val = 0xffffffff; | | const u32 max_val = 0xffffffff; | |
| | | | |
| if(i_count < max_val) | | if(i_count < max_val) | |
| { | | { | |
| return d_count + eT(i_count + 1); | | return d_count + eT(i_count + 1); | |
| } | | } | |
| else | | else | |
| { | | { | |
| return d_count + eT(max_val) + eT(1); | | return d_count + eT(max_val) + eT(1); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| arma_counter<eT>::value_minus_1() | | arma_counter<eT>::value_minus_1() const | |
| const | | | |
| { | | { | |
| if(i_count > 0) | | if(i_count > 0) | |
| { | | { | |
| return d_count + eT(i_count - 1); | | return d_count + eT(i_count - 1); | |
| } | | } | |
| else | | else | |
| { | | { | |
| return d_count - eT(1); | | return d_count - eT(1); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 191 | |
| max_val = eT(0); | | max_val = eT(0); | |
| | | | |
| min_val_norm = T(0); | | min_val_norm = T(0); | |
| max_val_norm = T(0); | | max_val_norm = T(0); | |
| } | | } | |
| | | | |
| //! mean or average value | | //! mean or average value | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| running_stat<eT>::mean() | | running_stat<eT>::mean() const | |
| const | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return r_mean; | | return r_mean; | |
| } | | } | |
| | | | |
| //! variance | | //! variance | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| typename running_stat<eT>::T | | typename running_stat<eT>::T | |
|
| running_stat<eT>::var(const u32 norm_type) | | running_stat<eT>::var(const u32 norm_type) const | |
| const | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const T N = counter.value(); | | const T N = counter.value(); | |
| | | | |
| if(N > T(1)) | | if(N > T(1)) | |
| { | | { | |
| if(norm_type == 0) | | if(norm_type == 0) | |
| { | | { | |
| return r_var; | | return r_var; | |
| | | | |
| skipping to change at line 235 | | skipping to change at line 230 | |
| else | | else | |
| { | | { | |
| return T(0); | | return T(0); | |
| } | | } | |
| } | | } | |
| | | | |
| //! standard deviation | | //! standard deviation | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| typename running_stat<eT>::T | | typename running_stat<eT>::T | |
|
| running_stat<eT>::stddev(const u32 norm_type) | | running_stat<eT>::stddev(const u32 norm_type) const | |
| const | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return std::sqrt( (*this).var(norm_type) ); | | return std::sqrt( (*this).var(norm_type) ); | |
| } | | } | |
| | | | |
| //! minimum value | | //! minimum value | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| running_stat<eT>::min() | | running_stat<eT>::min() const | |
| const | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return min_val; | | return min_val; | |
| } | | } | |
| | | | |
| //! maximum value | | //! maximum value | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| eT | | eT | |
|
| running_stat<eT>::max() | | running_stat<eT>::max() const | |
| const | | | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return max_val; | | return max_val; | |
| } | | } | |
| | | | |
|
| | | //! number of samples so far | |
| | | template<typename eT> | |
| | | inline | |
| | | typename get_pod_type<eT>::result | |
| | | running_stat<eT>::count() const | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | return counter.value(); | |
| | | } | |
| | | | |
| //! update statistics to reflect new sample | | //! update statistics to reflect new sample | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| running_stat_aux::update_stats(running_stat<eT>& x, const eT sample) | | running_stat_aux::update_stats(running_stat<eT>& x, const eT sample) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename running_stat<eT>::T T; | | typedef typename running_stat<eT>::T T; | |
| | | | |
| | | | |
End of changes. 11 change blocks. |
| 19 lines changed or deleted | | 22 lines changed or added | |
|
| subview_meat.hpp | | subview_meat.hpp | |
| | | | |
| skipping to change at line 1995 | | skipping to change at line 1995 | |
| diagview<eT> | | diagview<eT> | |
| subview<eT>::diag(const s32 in_id) | | subview<eT>::diag(const s32 in_id) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; | | const u32 row_offset = (in_id < 0) ? u32(-in_id) : 0; | |
| const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; | | const u32 col_offset = (in_id > 0) ? u32( in_id) : 0; | |
| | | | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
|
| (row_offset >= n_rows) || (col_offset >= n_cols), | | ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c
ol_offset >= n_cols)), | |
| "subview::diag(): requested diagonal out of bounds" | | "subview::diag(): requested diagonal out of bounds" | |
| ); | | ); | |
| | | | |
| const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | | const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | |
| | | | |
| const u32 base_row_offset = aux_row1 + row_offset; | | const u32 base_row_offset = aux_row1 + row_offset; | |
| const u32 base_col_offset = aux_col1 + col_offset; | | const u32 base_col_offset = aux_col1 + col_offset; | |
| | | | |
| return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len); | | return diagview<eT>(*m_ptr, base_row_offset, base_col_offset, len); | |
| } | | } | |
| | | | |
| skipping to change at line 2020 | | skipping to change at line 2020 | |
| const diagview<eT> | | const diagview<eT> | |
| subview<eT>::diag(const s32 in_id) const | | subview<eT>::diag(const s32 in_id) const | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const u32 row_offset = (in_id < 0) ? -in_id : 0; | | const u32 row_offset = (in_id < 0) ? -in_id : 0; | |
| const u32 col_offset = (in_id > 0) ? in_id : 0; | | const u32 col_offset = (in_id > 0) ? in_id : 0; | |
| | | | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
|
| (row_offset >= n_rows) || (col_offset >= n_cols), | | ((row_offset > 0) && (row_offset >= n_rows)) || ((col_offset > 0) && (c
ol_offset >= n_cols)), | |
| "subview::diag(): requested diagonal out of bounds" | | "subview::diag(): requested diagonal out of bounds" | |
| ); | | ); | |
| | | | |
| const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | | const u32 len = (std::min)(n_rows - row_offset, n_cols - col_offset); | |
| | | | |
| const u32 base_row_offset = aux_row1 + row_offset; | | const u32 base_row_offset = aux_row1 + row_offset; | |
| const u32 base_col_offset = aux_col1 + col_offset; | | const u32 base_col_offset = aux_col1 + col_offset; | |
| | | | |
| return diagview<eT>(m, base_row_offset, base_col_offset, len); | | return diagview<eT>(m, base_row_offset, base_col_offset, len); | |
| } | | } | |
| | | | |
| skipping to change at line 2072 | | skipping to change at line 2072 | |
| subview<eT>::swap_cols(const u32 in_col1, const u32 in_col2) | | subview<eT>::swap_cols(const u32 in_col1, const u32 in_col2) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (in_col1 >= n_cols) || (in_col2 >= n_cols), | | (in_col1 >= n_cols) || (in_col2 >= n_cols), | |
| "subview::swap_cols(): out of bounds" | | "subview::swap_cols(): out of bounds" | |
| ); | | ); | |
| | | | |
|
| eT* ptr1 = colptr(in_col1); | | if(n_elem > 0) | |
| eT* ptr2 = colptr(in_col2); | | | |
| | | | |
| for(u32 row=0; row<n_rows; ++row) | | | |
| { | | { | |
|
| const eT tmp = ptr1[row]; | | eT* ptr1 = colptr(in_col1); | |
| ptr1[row] = ptr2[row]; | | eT* ptr2 = colptr(in_col2); | |
| ptr2[row] = tmp; | | | |
| } | | | |
| | | | |
|
| | | for(u32 row=0; row<n_rows; ++row) | |
| | | { | |
| | | const eT tmp = ptr1[row]; | |
| | | ptr1[row] = ptr2[row]; | |
| | | ptr2[row] = tmp; | |
| | | } | |
| | | } | |
| } | | } | |
| | | | |
| // template<typename eT> | | // template<typename eT> | |
| // inline | | // inline | |
| // subview<eT>::iter::iter(const subview<eT>& S) | | // subview<eT>::iter::iter(const subview<eT>& S) | |
| // : mem (S.m.mem) | | // : mem (S.m.mem) | |
| // , n_rows (S.m.n_rows) | | // , n_rows (S.m.n_rows) | |
| // , row_start (S.aux_row1) | | // , row_start (S.aux_row1) | |
| // , row_end_p1(row_start + S.n_rows) | | // , row_end_p1(row_start + S.n_rows) | |
| // , row (row_start) | | // , row (row_start) | |
| | | | |
End of changes. 5 change blocks. |
| 10 lines changed or deleted | | 12 lines changed or added | |
|