Col_bones.hpp   Col_bones.hpp 
skipping to change at line 75 skipping to change at line 75
inline Col(const subview_cube<eT>& X); inline Col(const subview_cube<eT>& X);
inline const Col& operator=(const subview_cube<eT>& X); inline const Col& operator=(const subview_cube<eT>& X);
inline mat_injector<Col> operator<<(const eT val); inline mat_injector<Col> operator<<(const eT val);
arma_inline const Op<Col<eT>,op_htrans> t() const; arma_inline const Op<Col<eT>,op_htrans> t() const;
arma_inline const Op<Col<eT>,op_htrans> ht() const; arma_inline const Op<Col<eT>,op_htrans> ht() const;
arma_inline const Op<Col<eT>,op_strans> st() const; arma_inline const Op<Col<eT>,op_strans> st() const;
arma_inline eT& row(const uword row_num); // TODO: inconsistent; arma_inline subview_col<eT> row(const uword row_num);
should return a subview_row; change API for 4.0 ? arma_inline const subview_col<eT> row(const uword row_num) const;
arma_inline eT row(const uword row_num) const;
using Mat<eT>::rows; using Mat<eT>::rows;
using Mat<eT>::operator(); using Mat<eT>::operator();
arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2); arma_inline subview_col<eT> rows(const uword in_row1, const uword i n_row2);
arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const; arma_inline const subview_col<eT> rows(const uword in_row1, const uword i n_row2) const;
arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2); arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2);
arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const; arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
 End of changes. 1 change blocks. 
3 lines changed or deleted 2 lines changed or added


 Col_meat.hpp   Col_meat.hpp 
skipping to change at line 227 skipping to change at line 227
access::rw(Mat<eT>::n_rows) = X.n_rows; access::rw(Mat<eT>::n_rows) = X.n_rows;
access::rw(Mat<eT>::n_cols) = 1; access::rw(Mat<eT>::n_cols) = 1;
access::rw(Mat<eT>::n_elem) = X.n_elem; access::rw(Mat<eT>::n_elem) = X.n_elem;
if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || ( X.mem_state == 1) || (X.mem_state == 2) ) if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || ( X.mem_state == 1) || (X.mem_state == 2) )
{ {
access::rw(Mat<eT>::mem_state) = X.mem_state; access::rw(Mat<eT>::mem_state) = X.mem_state;
access::rw(Mat<eT>::mem) = X.mem; access::rw(Mat<eT>::mem) = X.mem;
access::rw(X.n_rows) = 0; access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0; access::rw(X.n_cols) = 1;
access::rw(X.n_elem) = 0; access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0; access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0; access::rw(X.mem) = 0;
} }
else else
{ {
(*this).init_cold(); (*this).init_cold();
arrayops::copy( (*this).memptr(), X.mem, X.n_elem ); arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 1;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
} }
} }
template<typename eT> template<typename eT>
inline inline
const Col<eT>& const Col<eT>&
Col<eT>::operator=(Col<eT>&& X) Col<eT>::operator=(Col<eT>&& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).steal_mem(X); (*this).steal_mem(X);
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 1;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
inline inline
Col<eT>::Col(const SpCol<eT>& X) Col<eT>::Col(const SpCol<eT>& X)
: Mat<eT>(arma_vec_indicator(), X.n_elem, 1, 1) : Mat<eT>(arma_vec_indicator(), X.n_elem, 1, 1)
{ {
skipping to change at line 437 skipping to change at line 453
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Col<eT>,op_strans> const Op<Col<eT>,op_strans>
Col<eT>::st() const Col<eT>::st() const
{ {
return Op<Col<eT>,op_strans>(*this); return Op<Col<eT>,op_strans>(*this);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& subview_col<eT>
Col<eT>::row(const uword row_num) Col<eT>::row(const uword in_row1)
{ {
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): index out of arma_extra_debug_sigprint();
bounds" );
arma_debug_check( (in_row1 >= Mat<eT>::n_rows), "Col::row(): indices out
of bounds or incorrectly used");
return access::rw(Mat<eT>::mem[row_num]); return subview_col<eT>(*this, 0, in_row1, 1);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT const subview_col<eT>
Col<eT>::row(const uword row_num) const Col<eT>::row(const uword in_row1) const
{ {
arma_debug_check( (row_num >= Mat<eT>::n_rows), "Col::row(): index out of arma_extra_debug_sigprint();
bounds" );
arma_debug_check( (in_row1 >= Mat<eT>::n_rows), "Col::row(): indices out
of bounds or incorrectly used");
return Mat<eT>::mem[row_num]; return subview_col<eT>(*this, 0, in_row1, 1);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_col<eT> subview_col<eT>
Col<eT>::rows(const uword in_row1, const uword in_row2) Col<eT>::rows(const uword in_row1, const uword in_row2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_row1 > in_row2) || (in_row2 >= Mat<eT>::n_rows) ) , "Col::rows(): indices out of bounds or incorrectly used");
 End of changes. 9 change blocks. 
11 lines changed or deleted 31 lines changed or added


 Cube_bones.hpp   Cube_bones.hpp 
skipping to change at line 120 skipping to change at line 120
arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const SizeMat& s); arma_inline subview_cube<eT> tube(const uword in_row1, const uword in_col1, const SizeMat& s);
arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const SizeMat& s) const; arma_inline const subview_cube<eT> tube(const uword in_row1, const uword in_col1, const SizeMat& s) const;
inline subview_cube<eT> tube(const span& row_span, const span& col_span); inline subview_cube<eT> tube(const span& row_span, const span& col_span);
inline const subview_cube<eT> tube(const span& row_span, const span& col_span) const; inline const subview_cube<eT> tube(const span& row_span, const span& col_span) const;
template<typename T1> arma_inline subview_elem1<eT,T1> elem(const B
ase<uword,T1>& a);
template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const B
ase<uword,T1>& a) const;
template<typename T1> arma_inline subview_elem1<eT,T1> operator()(c
onst Base<uword,T1>& a);
template<typename T1> arma_inline const subview_elem1<eT,T1> operator()(c
onst Base<uword,T1>& a) const;
inline void shed_slice(const uword slice_num); inline void shed_slice(const uword slice_num);
inline void shed_slices(const uword in_slice1, const uword in_slice2); inline void shed_slices(const uword in_slice1, const uword in_slice2);
inline void insert_slices(const uword slice_num, const uword N, const boo l set_to_zero = true); inline void insert_slices(const uword slice_num, const uword N, const boo l set_to_zero = true);
template<typename T1> template<typename T1>
inline void insert_slices(const uword row_num, const BaseCube<eT,T1>& X); inline void insert_slices(const uword row_num, const BaseCube<eT,T1>& X);
template<typename gen_type> inline Cube(const GenCube<e T, gen_type>& X); template<typename gen_type> inline Cube(const GenCube<e T, gen_type>& X);
 End of changes. 1 change blocks. 
0 lines changed or deleted 10 lines changed or added


 Cube_meat.hpp   Cube_meat.hpp 
skipping to change at line 1207 skipping to change at line 1207
( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) ) ( row_all ? false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
|| ||
( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ) ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
, ,
"Cube::tube(): indices out of bounds or incorrectly used" "Cube::tube(): indices out of bounds or incorrectly used"
); );
return subview_cube<eT>(*this, in_row1, in_col1, 0, subcube_n_rows, subcu be_n_cols, n_slices); return subview_cube<eT>(*this, in_row1, in_col1, 0, subcube_n_rows, subcu be_n_cols, n_slices);
} }
template<typename eT>
template<typename T1>
arma_inline
subview_elem1<eT,T1>
Cube<eT>::elem(const Base<uword,T1>& a)
{
arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a);
}
template<typename eT>
template<typename T1>
arma_inline
const subview_elem1<eT,T1>
Cube<eT>::elem(const Base<uword,T1>& a) const
{
arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a);
}
template<typename eT>
template<typename T1>
arma_inline
subview_elem1<eT,T1>
Cube<eT>::operator()(const Base<uword,T1>& a)
{
arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a);
}
template<typename eT>
template<typename T1>
arma_inline
const subview_elem1<eT,T1>
Cube<eT>::operator()(const Base<uword,T1>& a) const
{
arma_extra_debug_sigprint();
return subview_elem1<eT,T1>(*this, a);
}
//! remove specified slice //! remove specified slice
template<typename eT> template<typename eT>
inline inline
void void
Cube<eT>::shed_slice(const uword slice_num) Cube<eT>::shed_slice(const uword slice_num)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( slice_num >= n_slices, "Cube::shed_slice(): index out o f bounds"); arma_debug_check( slice_num >= n_slices, "Cube::shed_slice(): index out o f bounds");
 End of changes. 1 change blocks. 
0 lines changed or deleted 44 lines changed or added


 Mat_meat.hpp   Mat_meat.hpp 
skipping to change at line 556 skipping to change at line 556
access::rw(X.n_cols) = 0; access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0; access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0; access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0; access::rw(X.mem) = 0;
} }
else else
{ {
init_cold(); init_cold();
arrayops::copy( memptr(), X.mem, X.n_elem ); arrayops::copy( memptr(), X.mem, X.n_elem );
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
} }
} }
template<typename eT> template<typename eT>
inline inline
const Mat<eT>& const Mat<eT>&
Mat<eT>::operator=(Mat<eT>&& X) Mat<eT>::operator=(Mat<eT>&& X)
{ {
arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th is % &X); arma_extra_debug_sigprint(arma_boost::format("this = %x X = %x") % th is % &X);
(*this).steal_mem(X); (*this).steal_mem(X);
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 0;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
return *this; return *this;
} }
#endif #endif
//! Set the matrix to be equal to the specified scalar. //! Set the matrix to be equal to the specified scalar.
//! NOTE: the size of the matrix will be 1x1 //! NOTE: the size of the matrix will be 1x1
template<typename eT> template<typename eT>
arma_inline arma_inline
const Mat<eT>& const Mat<eT>&
 End of changes. 2 change blocks. 
0 lines changed or deleted 16 lines changed or added


 Row_bones.hpp   Row_bones.hpp 
skipping to change at line 75 skipping to change at line 75
inline Row(const subview_cube<eT>& X); inline Row(const subview_cube<eT>& X);
inline const Row& operator=(const subview_cube<eT>& X); inline const Row& operator=(const subview_cube<eT>& X);
inline mat_injector<Row> operator<<(const eT val); inline mat_injector<Row> operator<<(const eT val);
arma_inline const Op<Row<eT>,op_htrans> t() const; arma_inline const Op<Row<eT>,op_htrans> t() const;
arma_inline const Op<Row<eT>,op_htrans> ht() const; arma_inline const Op<Row<eT>,op_htrans> ht() const;
arma_inline const Op<Row<eT>,op_strans> st() const; arma_inline const Op<Row<eT>,op_strans> st() const;
arma_inline eT& col(const uword col_num); // TODO: inconsistent; arma_inline subview_row<eT> col(const uword col_num);
should return a subview_col; change API for 4.0 ? arma_inline const subview_row<eT> col(const uword col_num) const;
arma_inline eT col(const uword col_num) const;
using Mat<eT>::cols; using Mat<eT>::cols;
using Mat<eT>::operator(); using Mat<eT>::operator();
arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2); arma_inline subview_row<eT> cols(const uword in_col1, const uword i n_col2);
arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const; arma_inline const subview_row<eT> cols(const uword in_col1, const uword i n_col2) const;
arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2); arma_inline subview_row<eT> subvec(const uword in_col1, const uword in_col2);
arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const; arma_inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
 End of changes. 1 change blocks. 
3 lines changed or deleted 2 lines changed or added


 Row_meat.hpp   Row_meat.hpp 
skipping to change at line 192 skipping to change at line 192
access::rw(Mat<eT>::n_rows) = 1; access::rw(Mat<eT>::n_rows) = 1;
access::rw(Mat<eT>::n_cols) = X.n_cols; access::rw(Mat<eT>::n_cols) = X.n_cols;
access::rw(Mat<eT>::n_elem) = X.n_elem; access::rw(Mat<eT>::n_elem) = X.n_elem;
if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || ( X.mem_state == 1) || (X.mem_state == 2) ) if( ((X.mem_state == 0) && (X.n_elem > arma_config::mat_prealloc)) || ( X.mem_state == 1) || (X.mem_state == 2) )
{ {
access::rw(Mat<eT>::mem_state) = X.mem_state; access::rw(Mat<eT>::mem_state) = X.mem_state;
access::rw(Mat<eT>::mem) = X.mem; access::rw(Mat<eT>::mem) = X.mem;
access::rw(X.n_rows) = 0; access::rw(X.n_rows) = 1;
access::rw(X.n_cols) = 0; access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0; access::rw(X.n_elem) = 0;
access::rw(X.mem_state) = 0; access::rw(X.mem_state) = 0;
access::rw(X.mem) = 0; access::rw(X.mem) = 0;
} }
else else
{ {
(*this).init_cold(); (*this).init_cold();
arrayops::copy( (*this).memptr(), X.mem, X.n_elem ); arrayops::copy( (*this).memptr(), X.mem, X.n_elem );
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 1;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
} }
} }
template<typename eT> template<typename eT>
inline inline
const Row<eT>& const Row<eT>&
Row<eT>::operator=(Row<eT>&& X) Row<eT>::operator=(Row<eT>&& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
(*this).steal_mem(X); (*this).steal_mem(X);
if( (X.mem_state == 0) && (X.n_elem <= arma_config::mat_prealloc) )
{
access::rw(X.n_rows) = 1;
access::rw(X.n_cols) = 0;
access::rw(X.n_elem) = 0;
access::rw(X.mem) = 0;
}
return *this; return *this;
} }
#endif #endif
template<typename eT> template<typename eT>
inline inline
Row<eT>::Row(const SpRow<eT>& X) Row<eT>::Row(const SpRow<eT>& X)
: Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 1) : Mat<eT>(arma_vec_indicator(), 1, X.n_elem, 1)
{ {
skipping to change at line 403 skipping to change at line 419
template<typename eT> template<typename eT>
arma_inline arma_inline
const Op<Row<eT>,op_strans> const Op<Row<eT>,op_strans>
Row<eT>::st() const Row<eT>::st() const
{ {
return Op<Row<eT>,op_strans>(*this); return Op<Row<eT>,op_strans>(*this);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT& subview_row<eT>
Row<eT>::col(const uword col_num) Row<eT>::col(const uword in_col1)
{ {
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): index out of arma_extra_debug_sigprint();
bounds" );
arma_debug_check( (in_col1 >= Mat<eT>::n_cols), "Row::col(): indices out
of bounds or incorrectly used");
return access::rw(Mat<eT>::mem[col_num]); return subview_row<eT>(*this, 0, in_col1, 1);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT const subview_row<eT>
Row<eT>::col(const uword col_num) const Row<eT>::col(const uword in_col1) const
{ {
arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): index out of arma_extra_debug_sigprint();
bounds" );
arma_debug_check( (in_col1 >= Mat<eT>::n_cols), "Row::col(): indices out
of bounds or incorrectly used");
return Mat<eT>::mem[col_num]; return subview_row<eT>(*this, 0, in_col1, 1);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
subview_row<eT> subview_row<eT>
Row<eT>::cols(const uword in_col1, const uword in_col2) Row<eT>::cols(const uword in_col1, const uword in_col2)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used"); arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ) , "Row::cols(): indices out of bounds or incorrectly used");
 End of changes. 9 change blocks. 
11 lines changed or deleted 31 lines changed or added


 SpMat_bones.hpp   SpMat_bones.hpp 
skipping to change at line 270 skipping to change at line 270
inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const; inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const;
inline void impl_print_dense(const std::string& extra_text) const; inline void impl_print_dense(const std::string& extra_text) const;
inline void impl_print_dense(std::ostream& user_stream, const std::string & extra_text) const; inline void impl_print_dense(std::ostream& user_stream, const std::string & extra_text) const;
inline void impl_raw_print_dense(const std::string& extra_text) const; inline void impl_raw_print_dense(const std::string& extra_text) const;
inline void impl_raw_print_dense(std::ostream& user_stream, const std::st ring& extra_text) const; inline void impl_raw_print_dense(std::ostream& user_stream, const std::st ring& extra_text) const;
//! Copy the size of another matrix. //! Copy the size of another matrix.
template<typename eT2> inline void copy_size(const SpMat<eT2>& m); template<typename eT2> inline void copy_size(const SpMat<eT2>& m);
template<typename eT2> inline void copy_size(const Mat<eT2>& m); template<typename eT2> inline void copy_size(const Mat<eT2>& m);
/** /**
* Resize the matrix to a given size. The matrix will be resized to be a column vector (i.e. in_elem columns, 1 row). * Set the size of the matrix; the matrix will be sized as a column vecto r
* *
* @param in_elem Number of elements to allow. * @param in_elem Number of elements to allow.
*/ */
inline void set_size(const uword in_elem); inline void set_size(const uword in_elem);
/** /**
* Resize the matrix to a given size. * Set the size of the matrix
* *
* @param in_rows Number of rows to allow. * @param in_rows Number of rows to allow.
* @param in_cols Number of columns to allow. * @param in_cols Number of columns to allow.
*/ */
inline void set_size(const uword in_rows, const uword in_cols); inline void set_size(const uword in_rows, const uword in_cols);
inline void reshape(const uword in_rows, const uword in_cols, const uwor d dim = 0); inline void reshape(const uword in_rows, const uword in_cols, const uwor d dim = 0);
inline const SpMat& zeros(); inline const SpMat& zeros();
inline const SpMat& zeros(const uword in_elem); inline const SpMat& zeros(const uword in_elem);
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 SpMat_meat.hpp   SpMat_meat.hpp 
skipping to change at line 2894 skipping to change at line 2894
inline inline
void void
SpMat<eT>::copy_size(const Mat<eT2>& m) SpMat<eT>::copy_size(const Mat<eT2>& m)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init(m.n_rows, m.n_cols); init(m.n_rows, m.n_cols);
} }
/** /**
* Resize the matrix to a given size. The matrix will be resized to be a c olumn vector (i.e. in_elem columns, 1 row). * Set the size of the matrix; the matrix will be sized as a column vector
* *
* @param in_elem Number of elements to allow. * @param in_elem Number of elements to allow.
*/ */
template<typename eT> template<typename eT>
inline inline
void void
SpMat<eT>::set_size(const uword in_elem) SpMat<eT>::set_size(const uword in_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
skipping to change at line 2917 skipping to change at line 2917
{ {
init(1, in_elem); init(1, in_elem);
} }
else else
{ {
init(in_elem, 1); init(in_elem, 1);
} }
} }
/** /**
* Resize the matrix to a given size. * Set the size of the matrix
* *
* @param in_rows Number of rows to allow. * @param in_rows Number of rows to allow.
* @param in_cols Number of columns to allow. * @param in_cols Number of columns to allow.
*/ */
template<typename eT> template<typename eT>
inline inline
void void
SpMat<eT>::set_size(const uword in_rows, const uword in_cols) SpMat<eT>::set_size(const uword in_rows, const uword in_cols)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 arma_config.hpp   arma_config.hpp 
skipping to change at line 43 skipping to change at line 43
#else #else
static const bool lapack = false; static const bool lapack = false;
#endif #endif
#if defined(ARMA_USE_BLAS) #if defined(ARMA_USE_BLAS)
static const bool blas = true; static const bool blas = true;
#else #else
static const bool blas = false; static const bool blas = false;
#endif #endif
#if defined(ARMA_USE_HDF5) #if defined(ARMA_USE_ARPACK)
static const bool hdf5 = true; static const bool arpack = true;
#else #else
static const bool hdf5 = false; static const bool arpack = false;
#endif #endif
#if defined(ARMA_USE_BOOST) #if defined(ARMA_USE_HDF5)
static const bool boost = true; static const bool hdf5 = true;
#else
static const bool boost = false;
#endif
#if defined(ARMA_USE_BOOST_DATE)
static const bool boost_date = true;
#else #else
static const bool boost_date = false; static const bool hdf5 = false;
#endif #endif
#if defined(ARMA_NO_DEBUG) #if defined(ARMA_NO_DEBUG)
static const bool debug = false; static const bool debug = false;
#else #else
static const bool debug = true; static const bool debug = true;
#endif #endif
#if defined(ARMA_EXTRA_DEBUG) #if defined(ARMA_EXTRA_DEBUG)
static const bool extra_debug = true; static const bool extra_debug = true;
 End of changes. 4 change blocks. 
12 lines changed or deleted 6 lines changed or added


 arma_static_check.hpp   arma_static_check.hpp 
skipping to change at line 35 skipping to change at line 35
struct arma_type_check_cxx1998<false> struct arma_type_check_cxx1998<false>
{ {
arma_inline arma_inline
static static
void void
apply() apply()
{ {
} }
}; };
#if !defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
#define arma_static_check(condition, message) static const char message[ (condition) ? -1 : +1 ] #define arma_static_check(condition, message) static_assert( !(condition ), #message )
#define arma_type_check(condition) arma_type_check_cxx1998<condition>::a pply() #define arma_type_check(condition) static_assert( !(condition), "error: incorrect or unsupported type" )
#else #else
#define arma_static_check(condition, message) static_assert( !(condition ), #message ) #define arma_static_check(condition, message) static const char message[ (condition) ? -1 : +1 ]
#define arma_type_check(condition) static_assert( !(condition), "error: incorrect or unsupported type" ) #define arma_type_check(condition) arma_type_check_cxx1998<condition>::a pply()
#endif #endif
//! @} //! @}
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 arma_version.hpp   arma_version.hpp 
// Copyright (C) 2009-2013 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2013 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup arma_version //! \addtogroup arma_version
//! @{ //! @{
#define ARMA_VERSION_MAJOR 3 #define ARMA_VERSION_MAJOR 4
#define ARMA_VERSION_MINOR 930 #define ARMA_VERSION_MINOR 000
#define ARMA_VERSION_PATCH 4 #define ARMA_VERSION_PATCH 0
#define ARMA_VERSION_NAME "Dragon's Back" #define ARMA_VERSION_NAME "Feral Steamroller"
struct arma_version struct arma_version
{ {
static const unsigned int major = ARMA_VERSION_MAJOR; static const unsigned int major = ARMA_VERSION_MAJOR;
static const unsigned int minor = ARMA_VERSION_MINOR; static const unsigned int minor = ARMA_VERSION_MINOR;
static const unsigned int patch = ARMA_VERSION_PATCH; static const unsigned int patch = ARMA_VERSION_PATCH;
static static
inline inline
std::string std::string
 End of changes. 1 change blocks. 
4 lines changed or deleted 4 lines changed or added


 armadillo   armadillo 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2014 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2014 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef ARMA_INCLUDES #ifndef ARMA_INCLUDES
#define ARMA_INCLUDES #define ARMA_INCLUDES
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
#include <ctime> #include <ctime>
#include <cstdio>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <new>
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include <complex> #include <complex>
#include <vector> #include <vector>
#if ( defined(__unix__) || defined(__unix) || defined(_POSIX_C_SOURCE) ) && !defined(_WIN32) #if ( defined(__unix__) || defined(__unix) || defined(_POSIX_C_SOURCE) || ( defined(__APPLE__) && defined(__MACH__)) ) && !defined(_WIN32)
#include <unistd.h> #include <unistd.h>
#endif #endif
#if (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L))
#include <sys/time.h>
#endif
#include "armadillo_bits/config.hpp" #include "armadillo_bits/config.hpp"
#include "armadillo_bits/compiler_setup.hpp" #include "armadillo_bits/compiler_setup.hpp"
#include "armadillo_bits/undefine_conflicts.hpp"
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
#include <initializer_list> #include <initializer_list>
#include <cstdint> #include <cstdint>
#include <chrono> #include <chrono>
#include <random> #include <random>
#undef ARMA_USE_BOOST_DATE
#endif
#if defined(ARMA_HAVE_GETTIMEOFDAY)
#include <sys/time.h>
#undef ARMA_USE_BOOST_DATE
#endif
#if defined(ARMA_USE_BOOST_DATE)
#include <boost/date_time/posix_time/posix_time.hpp>
#endif #endif
#if defined(ARMA_USE_TBB_ALLOC) #if defined(ARMA_USE_TBB_ALLOC)
#include <tbb/scalable_allocator.h> #include <tbb/scalable_allocator.h>
#endif #endif
#if defined(ARMA_USE_MKL_ALLOC) #if defined(ARMA_USE_MKL_ALLOC)
#include <mkl_service.h> #include <mkl_service.h>
#endif #endif
#if !defined(ARMA_USE_CXX11) #if !defined(ARMA_USE_CXX11)
#if defined(ARMA_HAVE_STD_TR1) #if defined(ARMA_HAVE_TR1)
#include <tr1/cmath> #include <tr1/cmath>
#include <tr1/complex> #include <tr1/complex>
#elif defined(ARMA_USE_BOOST)
#include <boost/math/complex.hpp>
#include <boost/math/special_functions/acosh.hpp>
#include <boost/math/special_functions/asinh.hpp>
#include <boost/math/special_functions/atanh.hpp>
#endif
#endif
#if defined(ARMA_EXTRA_DEBUG)
#if !defined(ARMA_HAVE_STD_SNPRINTF)
#if defined(ARMA_USE_CXX11)
#include <cstdio>
#define ARMA_HAVE_STD_SNPRINTF
#elif defined(ARMA_USE_BOOST)
#include <boost/format.hpp>
#define ARMA_USE_BOOST_FORMAT
#endif
#endif #endif
#endif #endif
#include "armadillo_bits/include_atlas.hpp" #include "armadillo_bits/include_atlas.hpp"
#if defined(ARMA_USE_HDF5) #if defined(ARMA_USE_HDF5)
#include <hdf5.h> #include <hdf5.h>
#endif #endif
//! \namespace arma namespace for Armadillo classes and functions //! \namespace arma namespace for Armadillo classes and functions
namespace arma namespace arma
{ {
// preliminaries // preliminaries
#include "armadillo_bits/forward_bones.hpp" #include "armadillo_bits/forward_bones.hpp"
#include "armadillo_bits/arma_static_check.hpp" #include "armadillo_bits/arma_static_check.hpp"
#include "armadillo_bits/typedef_elem.hpp" #include "armadillo_bits/typedef_elem.hpp"
#include "armadillo_bits/typedef_elem_check.hpp" #include "armadillo_bits/typedef_elem_check.hpp"
#include "armadillo_bits/typedef_mat.hpp" #include "armadillo_bits/typedef_mat.hpp"
#include "armadillo_bits/format_wrap.hpp" #include "armadillo_bits/arma_boost.hpp"
#include "armadillo_bits/arma_version.hpp" #include "armadillo_bits/arma_version.hpp"
#include "armadillo_bits/arma_config.hpp" #include "armadillo_bits/arma_config.hpp"
#include "armadillo_bits/traits.hpp" #include "armadillo_bits/traits.hpp"
#include "armadillo_bits/promote_type.hpp" #include "armadillo_bits/promote_type.hpp"
#include "armadillo_bits/upgrade_val.hpp" #include "armadillo_bits/upgrade_val.hpp"
#include "armadillo_bits/restrictors.hpp" #include "armadillo_bits/restrictors.hpp"
#include "armadillo_bits/access.hpp" #include "armadillo_bits/access.hpp"
#include "armadillo_bits/span.hpp" #include "armadillo_bits/span.hpp"
#include "armadillo_bits/distr_param.hpp" #include "armadillo_bits/distr_param.hpp"
#include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants.hpp"
skipping to change at line 132 skipping to change at line 109
// //
// class prototypes // class prototypes
#include "armadillo_bits/Base_bones.hpp" #include "armadillo_bits/Base_bones.hpp"
#include "armadillo_bits/BaseCube_bones.hpp" #include "armadillo_bits/BaseCube_bones.hpp"
#include "armadillo_bits/SpBase_bones.hpp" #include "armadillo_bits/SpBase_bones.hpp"
#include "armadillo_bits/blas_bones.hpp" #include "armadillo_bits/blas_bones.hpp"
#include "armadillo_bits/lapack_bones.hpp" #include "armadillo_bits/lapack_bones.hpp"
#include "armadillo_bits/atlas_bones.hpp" #include "armadillo_bits/atlas_bones.hpp"
#include "armadillo_bits/arpack_bones.hpp"
#include "armadillo_bits/blas_wrapper.hpp" #include "armadillo_bits/blas_wrapper.hpp"
#include "armadillo_bits/lapack_wrapper.hpp" #include "armadillo_bits/lapack_wrapper.hpp"
#include "armadillo_bits/atlas_wrapper.hpp" #include "armadillo_bits/atlas_wrapper.hpp"
#include "armadillo_bits/arpack_wrapper.hpp"
#include "armadillo_bits/cond_rel_bones.hpp" #include "armadillo_bits/cond_rel_bones.hpp"
#include "armadillo_bits/arrayops_bones.hpp" #include "armadillo_bits/arrayops_bones.hpp"
#include "armadillo_bits/podarray_bones.hpp" #include "armadillo_bits/podarray_bones.hpp"
#include "armadillo_bits/auxlib_bones.hpp" #include "armadillo_bits/auxlib_bones.hpp"
#include "armadillo_bits/sp_auxlib_bones.hpp"
#include "armadillo_bits/injector_bones.hpp" #include "armadillo_bits/injector_bones.hpp"
#include "armadillo_bits/Mat_bones.hpp" #include "armadillo_bits/Mat_bones.hpp"
#include "armadillo_bits/Col_bones.hpp" #include "armadillo_bits/Col_bones.hpp"
#include "armadillo_bits/Row_bones.hpp" #include "armadillo_bits/Row_bones.hpp"
#include "armadillo_bits/Cube_bones.hpp" #include "armadillo_bits/Cube_bones.hpp"
#include "armadillo_bits/xvec_htrans_bones.hpp" #include "armadillo_bits/xvec_htrans_bones.hpp"
#include "armadillo_bits/SizeMat_bones.hpp" #include "armadillo_bits/SizeMat_bones.hpp"
#include "armadillo_bits/SizeCube_bones.hpp" #include "armadillo_bits/SizeCube_bones.hpp"
skipping to change at line 279 skipping to change at line 259
// //
// low-level debugging and memory handling functions // low-level debugging and memory handling functions
#include "armadillo_bits/debug.hpp" #include "armadillo_bits/debug.hpp"
#include "armadillo_bits/memory.hpp" #include "armadillo_bits/memory.hpp"
// //
// //
#include "armadillo_bits/cmath_wrap.hpp" #include "armadillo_bits/arma_cmath.hpp"
// //
// classes that underlay metaprogramming // classes that underlay metaprogramming
#include "armadillo_bits/unwrap.hpp" #include "armadillo_bits/unwrap.hpp"
#include "armadillo_bits/unwrap_cube.hpp" #include "armadillo_bits/unwrap_cube.hpp"
#include "armadillo_bits/unwrap_spmat.hpp" #include "armadillo_bits/unwrap_spmat.hpp"
#include "armadillo_bits/Proxy.hpp" #include "armadillo_bits/Proxy.hpp"
#include "armadillo_bits/ProxyCube.hpp" #include "armadillo_bits/ProxyCube.hpp"
skipping to change at line 374 skipping to change at line 354
#include "armadillo_bits/fn_max.hpp" #include "armadillo_bits/fn_max.hpp"
#include "armadillo_bits/fn_accu.hpp" #include "armadillo_bits/fn_accu.hpp"
#include "armadillo_bits/fn_sum.hpp" #include "armadillo_bits/fn_sum.hpp"
#include "armadillo_bits/fn_diagmat.hpp" #include "armadillo_bits/fn_diagmat.hpp"
#include "armadillo_bits/fn_diagvec.hpp" #include "armadillo_bits/fn_diagvec.hpp"
#include "armadillo_bits/fn_inv.hpp" #include "armadillo_bits/fn_inv.hpp"
#include "armadillo_bits/fn_trace.hpp" #include "armadillo_bits/fn_trace.hpp"
#include "armadillo_bits/fn_trans.hpp" #include "armadillo_bits/fn_trans.hpp"
#include "armadillo_bits/fn_det.hpp" #include "armadillo_bits/fn_det.hpp"
#include "armadillo_bits/fn_log_det.hpp" #include "armadillo_bits/fn_log_det.hpp"
#include "armadillo_bits/fn_eig.hpp" #include "armadillo_bits/fn_eig_sym.hpp"
#include "armadillo_bits/fn_eig_gen.hpp"
#include "armadillo_bits/fn_eig_pair.hpp"
#include "armadillo_bits/fn_lu.hpp" #include "armadillo_bits/fn_lu.hpp"
#include "armadillo_bits/fn_zeros.hpp" #include "armadillo_bits/fn_zeros.hpp"
#include "armadillo_bits/fn_ones.hpp" #include "armadillo_bits/fn_ones.hpp"
#include "armadillo_bits/fn_eye.hpp" #include "armadillo_bits/fn_eye.hpp"
#include "armadillo_bits/fn_misc.hpp" #include "armadillo_bits/fn_misc.hpp"
#include "armadillo_bits/fn_find.hpp"
#include "armadillo_bits/fn_elem.hpp" #include "armadillo_bits/fn_elem.hpp"
#include "armadillo_bits/fn_norm.hpp" #include "armadillo_bits/fn_norm.hpp"
#include "armadillo_bits/fn_dot.hpp" #include "armadillo_bits/fn_dot.hpp"
#include "armadillo_bits/fn_randu.hpp" #include "armadillo_bits/fn_randu.hpp"
#include "armadillo_bits/fn_randn.hpp" #include "armadillo_bits/fn_randn.hpp"
#include "armadillo_bits/fn_trig.hpp" #include "armadillo_bits/fn_trig.hpp"
#include "armadillo_bits/fn_mean.hpp" #include "armadillo_bits/fn_mean.hpp"
#include "armadillo_bits/fn_median.hpp" #include "armadillo_bits/fn_median.hpp"
#include "armadillo_bits/fn_stddev.hpp" #include "armadillo_bits/fn_stddev.hpp"
#include "armadillo_bits/fn_var.hpp" #include "armadillo_bits/fn_var.hpp"
skipping to change at line 434 skipping to change at line 417
#include "armadillo_bits/fn_unique.hpp" #include "armadillo_bits/fn_unique.hpp"
#include "armadillo_bits/fn_fft.hpp" #include "armadillo_bits/fn_fft.hpp"
#include "armadillo_bits/fn_fft2.hpp" #include "armadillo_bits/fn_fft2.hpp"
#include "armadillo_bits/fn_any.hpp" #include "armadillo_bits/fn_any.hpp"
#include "armadillo_bits/fn_all.hpp" #include "armadillo_bits/fn_all.hpp"
#include "armadillo_bits/fn_size.hpp" #include "armadillo_bits/fn_size.hpp"
#include "armadillo_bits/fn_numel.hpp" #include "armadillo_bits/fn_numel.hpp"
#include "armadillo_bits/fn_inplace_strans.hpp" #include "armadillo_bits/fn_inplace_strans.hpp"
#include "armadillo_bits/fn_inplace_trans.hpp" #include "armadillo_bits/fn_inplace_trans.hpp"
#include "armadillo_bits/fn_randi.hpp" #include "armadillo_bits/fn_randi.hpp"
#include "armadillo_bits/fn_cond.hpp"
#include "armadillo_bits/fn_speye.hpp" #include "armadillo_bits/fn_speye.hpp"
#include "armadillo_bits/fn_spones.hpp" #include "armadillo_bits/fn_spones.hpp"
#include "armadillo_bits/fn_sprandn.hpp" #include "armadillo_bits/fn_sprandn.hpp"
#include "armadillo_bits/fn_sprandu.hpp" #include "armadillo_bits/fn_sprandu.hpp"
#include "armadillo_bits/fn_eigs_sym.hpp"
#include "armadillo_bits/fn_eigs_gen.hpp"
// misc stuff // misc stuff
#include "armadillo_bits/hdf5_misc.hpp" #include "armadillo_bits/hdf5_misc.hpp"
#include "armadillo_bits/fft_engine.hpp" #include "armadillo_bits/fft_engine.hpp"
// //
// classes implementing various forms of dense matrix multiplication // classes implementing various forms of dense matrix multiplication
#include "armadillo_bits/mul_gemv.hpp" #include "armadillo_bits/mul_gemv.hpp"
skipping to change at line 464 skipping to change at line 450
// //
// class meat // class meat
#include "armadillo_bits/eop_core_meat.hpp" #include "armadillo_bits/eop_core_meat.hpp"
#include "armadillo_bits/eglue_core_meat.hpp" #include "armadillo_bits/eglue_core_meat.hpp"
#include "armadillo_bits/cond_rel_meat.hpp" #include "armadillo_bits/cond_rel_meat.hpp"
#include "armadillo_bits/arrayops_meat.hpp" #include "armadillo_bits/arrayops_meat.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"
#include "armadillo_bits/sp_auxlib_meat.hpp"
#include "armadillo_bits/injector_meat.hpp" #include "armadillo_bits/injector_meat.hpp"
#include "armadillo_bits/Mat_meat.hpp" #include "armadillo_bits/Mat_meat.hpp"
#include "armadillo_bits/Col_meat.hpp" #include "armadillo_bits/Col_meat.hpp"
#include "armadillo_bits/Row_meat.hpp" #include "armadillo_bits/Row_meat.hpp"
#include "armadillo_bits/Cube_meat.hpp" #include "armadillo_bits/Cube_meat.hpp"
#include "armadillo_bits/xvec_htrans_meat.hpp" #include "armadillo_bits/xvec_htrans_meat.hpp"
#include "armadillo_bits/SizeMat_meat.hpp" #include "armadillo_bits/SizeMat_meat.hpp"
#include "armadillo_bits/SizeCube_meat.hpp" #include "armadillo_bits/SizeCube_meat.hpp"
 End of changes. 19 change blocks. 
36 lines changed or deleted 23 lines changed or added


 arrayops_bones.hpp   arrayops_bones.hpp 
skipping to change at line 109 skipping to change at line 109
inplace_div_base(eT* dest, const eT* src, const uword n_elem); inplace_div_base(eT* dest, const eT* src, const uword n_elem);
// //
// array op= scalar // array op= scalar
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_set(eT* dest, const eT val, const uword n_elem); inplace_set(eT* dest, const eT val, const uword n_elem);
template<typename eT>
arma_hot inline static
void
inplace_set_small(eT* dest, const eT val, const uword n_elem);
template<typename eT, const uword n_elem> template<typename eT, const uword n_elem>
arma_hot inline static arma_hot inline static
void void
inplace_set_fixed(eT* dest, const eT val); inplace_set_fixed(eT* dest, const eT val);
template<typename eT> template<typename eT>
arma_hot inline static arma_hot inline static
void void
inplace_plus(eT* dest, const eT val, const uword n_elem); inplace_plus(eT* dest, const eT val, const uword n_elem);
 End of changes. 1 change blocks. 
0 lines changed or deleted 5 lines changed or added


 arrayops_meat.hpp   arrayops_meat.hpp 
skipping to change at line 144 skipping to change at line 144
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::fill_zeros(eT* dest, const uword n_elem) arrayops::fill_zeros(eT* dest, const uword n_elem)
{ {
typedef typename get_pod_type<eT>::result pod_type; typedef typename get_pod_type<eT>::result pod_type;
if( (n_elem >= 8) && (std::numeric_limits<eT>::is_integer || (std::numeri c_limits<pod_type>::is_iec559 && is_real<pod_type>::value)) ) if( (n_elem >= 16) && (std::numeric_limits<eT>::is_integer || (std::numer ic_limits<pod_type>::is_iec559 && is_real<pod_type>::value)) )
{ {
std::memset(dest, 0, sizeof(eT)*n_elem); std::memset(dest, 0, sizeof(eT)*n_elem);
} }
else else
{ {
arrayops::inplace_set(dest, eT(0), n_elem); arrayops::inplace_set(dest, eT(0), n_elem);
} }
} }
template<typename out_eT, typename in_eT> template<typename out_eT, typename in_eT>
skipping to change at line 502 skipping to change at line 502
dest[i] /= src[i]; dest[i] /= src[i];
} }
} }
template<typename eT> template<typename eT>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_set(eT* dest, const eT val, const uword n_elem) arrayops::inplace_set(eT* dest, const eT val, const uword n_elem)
{ {
if(memory::is_aligned(dest)) if(n_elem <= 16)
{ {
memory::mark_as_aligned(dest); arrayops::inplace_set_small(dest, val, n_elem);
uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
dest[i] = val;
dest[j] = val;
}
if(i < n_elem)
{
dest[i] = val;
}
} }
else else
{ {
uword i,j; if(memory::is_aligned(dest))
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{ {
dest[i] = val; memory::mark_as_aligned(dest);
dest[j] = val;
} uword i,j;
if(i < n_elem) for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
dest[i] = val;
dest[j] = val;
}
if(i < n_elem)
{
dest[i] = val;
}
}
else
{ {
dest[i] = val; uword i,j;
for(i=0, j=1; j<n_elem; i+=2, j+=2)
{
dest[i] = val;
dest[j] = val;
}
if(i < n_elem)
{
dest[i] = val;
}
} }
} }
} }
template<typename eT>
arma_hot
inline
void
arrayops::inplace_set_small(eT* dest, const eT val, const uword n_elem)
{
switch(n_elem)
{
case 16: dest[15] = val;
case 15: dest[14] = val;
case 14: dest[13] = val;
case 13: dest[12] = val;
case 12: dest[11] = val;
case 11: dest[10] = val;
case 10: dest[ 9] = val;
case 9: dest[ 8] = val;
case 8: dest[ 7] = val;
case 7: dest[ 6] = val;
case 6: dest[ 5] = val;
case 5: dest[ 4] = val;
case 4: dest[ 3] = val;
case 3: dest[ 2] = val;
case 2: dest[ 1] = val;
case 1: dest[ 0] = val;
default:;
}
}
template<typename eT, const uword n_elem> template<typename eT, const uword n_elem>
arma_hot arma_hot
inline inline
void void
arrayops::inplace_set_fixed(eT* dest, const eT val) arrayops::inplace_set_fixed(eT* dest, const eT val)
{ {
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
dest[i] = val; dest[i] = val;
} }
 End of changes. 8 change blocks. 
24 lines changed or deleted 59 lines changed or added


 auxlib_bones.hpp   auxlib_bones.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2014 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2014 NICTA (www.nicta.com.au)
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2012 Eric Jon Sundstrom // Copyright (C) 2012 Eric Jon Sundstrom
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup auxlib //! \addtogroup auxlib
//! @{ //! @{
skipping to change at line 40 skipping to change at line 40
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slo w = false); inline static bool inv(Mat<eT>& out, const Base<eT,T1>& X, const bool slo w = false);
template<typename eT> template<typename eT>
inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false); inline static bool inv(Mat<eT>& out, const Mat<eT>& A, const bool slow = false);
template<typename eT> template<typename eT>
inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, co nst uword N); inline static bool inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, co nst uword N);
template<typename eT> template<typename eT>
inline static bool inv_inplace_tinymat(Mat<eT>& out, const uword N);
template<typename eT>
inline static bool inv_inplace_lapack(Mat<eT>& out); inline static bool inv_inplace_lapack(Mat<eT>& out);
// //
// inv_tr // inv_tr
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout); inline static bool inv_tr(Mat<eT>& out, const Base<eT,T1>& X, const uword layout);
// //
// inv_sym // inv_sym
skipping to change at line 94 skipping to change at line 91
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, c onst Base<eT,T1>& X); inline static bool lu(Mat<eT>& L, Mat<eT>& U, podarray<blas_int>& ipiv, c onst Base<eT,T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T 1>& X); inline static bool lu(Mat<eT>& L, Mat<eT>& U, Mat<eT>& P, const Base<eT,T 1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X); inline static bool lu(Mat<eT>& L, Mat<eT>& U, const Base<eT,T1>& X);
// //
// eig // eig_sym
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool eig_sym(Col<eT>& eigval, const Base<eT,T1>& X); inline static bool eig_sym(Col<eT>& eigval, const Base<eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1> & X); inline static bool eig_sym(Col<T>& eigval, const Base<std::complex<T>,T1> & X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<e T,T1>& X); inline static bool eig_sym(Col<eT>& eigval, Mat<eT>& eigvec, const Base<e T,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec , const Base<std::complex<T>,T1>& X); inline static bool eig_sym(Col<T>& eigval, Mat< std::complex<T> >& eigvec , const Base<std::complex<T>,T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool eig_sym_dc(Col<eT>& eigval, Mat<eT>& eigvec, const Bas e<eT,T1>& X); inline static bool eig_sym_dc(Col<eT>& eigval, Mat<eT>& eigvec, const Bas e<eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_sym_dc(Col<T>& eigval, Mat< std::complex<T> >& eig vec, const Base<std::complex<T>,T1>& X); inline static bool eig_sym_dc(Col<T>& eigval, Mat< std::complex<T> >& eig vec, const Base<std::complex<T>,T1>& X);
//
// eig_gen
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat<T>& l_eigv ec, Mat<T>& r_eigvec, const Base<T,T1>& X, const char side); inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat<T>& l_eigv ec, Mat<T>& r_eigvec, const Base<T,T1>& X, const char side);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat< std::comp lex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::comp lex<T>, T1 >& X, const char side); inline static bool eig_gen(Col< std::complex<T> >& eigval, Mat< std::comp lex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::comp lex<T>, T1 >& X, const char side);
// //
// eig_pair
template<typename T, typename T1, typename T2>
inline static bool eig_pair(Col< std::complex<T> >& eigval, Mat<T>& l_eig
vec, Mat<T>& r_eigvec, const Base<T,T1>& X, const Base<T,T2>& Y, const char
side);
template<typename T, typename T1, typename T2>
inline static bool eig_pair(Col< std::complex<T> >& eigval, Mat< std::com
plex<T> >& l_eigvec, Mat< std::complex<T> >& r_eigvec, const Base< std::com
plex<T>, T1 >& X, const Base< std::complex<T>, T2 >& Y, const char side);
//
// chol // chol
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X); inline static bool chol(Mat<eT>& out, const Base<eT,T1>& X);
// //
// qr // qr
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X); inline static bool qr(Mat<eT>& Q, Mat<eT>& R, const Base<eT,T1>& X);
skipping to change at line 162 skipping to change at line 171
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X); inline static bool svd(Mat< std::complex<T> >& U, Col<T>& S, Mat< std::co mplex<T> >& V, const Base< std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode); inline static bool svd_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Bas e<eT,T1>& X, const char mode);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode); inline static bool svd_econ(Mat< std::complex<T> >& U, Col<T>& S, Mat< st d::complex<T> >& V, const Base< std::complex<T>, T1>& X, const char mode);
// EXPERIMENTAL
template<typename eT, typename T1>
inline static bool svd_dc(Col<eT>& S, const Base<eT,T1>& X, uword& n_rows
, uword& n_cols);
// EXPERIMENTAL
template<typename T, typename T1>
inline static bool svd_dc(Col<T>& S, const Base<std::complex<T>, T1>& X,
uword& n_rows, uword& n_cols);
// EXPERIMENTAL
template<typename eT, typename T1>
inline static bool svd_dc(Col<eT>& S, const Base<eT,T1>& X);
// EXPERIMENTAL
template<typename T, typename T1>
inline static bool svd_dc(Col<T>& S, const Base<std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base< eT,T1>& X); inline static bool svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base< eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
inline static bool svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std: :complex<T> >& V, const Base< std::complex<T>, T1>& X); inline static bool svd_dc(Mat< std::complex<T> >& U, Col<T>& S, Mat< std: :complex<T> >& V, const Base< std::complex<T>, T1>& X);
template<typename eT, typename T1> template<typename eT, typename T1>
inline static bool svd_dc_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X); inline static bool svd_dc_econ(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X);
template<typename T, typename T1> template<typename T, typename T1>
 End of changes. 6 change blocks. 
6 lines changed or deleted 37 lines changed or added


 auxlib_meat.hpp   auxlib_meat.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2014 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2014 NICTA (www.nicta.com.au)
// Copyright (C) 2009 Edmund Highcock // Copyright (C) 2009 Edmund Highcock
// Copyright (C) 2011 James Sanders // Copyright (C) 2011 James Sanders
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// Copyright (C) 2012 Eric Jon Sundstrom // Copyright (C) 2012 Eric Jon Sundstrom
// Copyright (C) 2012 Michael McNeil Forbes // Copyright (C) 2012 Michael McNeil Forbes
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
skipping to change at line 34 skipping to change at line 34
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" );
bool status = false; bool status = false;
const uword N = out.n_rows; const uword N = out.n_rows;
if( (N <= 4) && (slow == false) ) if( (N <= 4) && (slow == false) )
{ {
status = auxlib::inv_inplace_tinymat(out, N); Mat<eT> tmp(N,N);
status = auxlib::inv_noalias_tinymat(tmp, out, N);
if(status == true)
{
arrayops::copy( out.memptr(), tmp.memptr(), tmp.n_elem );
}
} }
if( (N > 4) || (status == false) ) if( (N > 4) || (status == false) )
{ {
status = auxlib::inv_inplace_lapack(out); status = auxlib::inv_inplace_lapack(out);
} }
return status; return status;
} }
skipping to change at line 60 skipping to change at line 67
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" ); arma_debug_check( (X.is_square() == false), "inv(): given matrix is not s quare" );
bool status = false; bool status = false;
const uword N = X.n_rows; const uword N = X.n_rows;
if( (N <= 4) && (slow == false) ) if( (N <= 4) && (slow == false) )
{ {
status = (&out != &X) ? auxlib::inv_noalias_tinymat(out, X, N) : auxlib if(&out != &X)
::inv_inplace_tinymat(out, N); {
out.set_size(N,N);
status = auxlib::inv_noalias_tinymat(out, X, N);
}
else
{
Mat<eT> tmp(N,N);
status = auxlib::inv_noalias_tinymat(tmp, X, N);
if(status == true)
{
arrayops::copy( out.memptr(), tmp.memptr(), tmp.n_elem );
}
}
} }
if( (N > 4) || (status == false) ) if( (N > 4) || (status == false) )
{ {
out = X; out = X;
status = auxlib::inv_inplace_lapack(out); status = auxlib::inv_inplace_lapack(out);
} }
return status; return status;
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const uword N) auxlib::inv_noalias_tinymat(Mat<eT>& out, const Mat<eT>& X, const uword N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool det_ok = true; typedef typename get_pod_type<eT>::result T;
out.set_size(N,N); const T det_min = (is_float<T>::value) ? T(1e-19) : T(1e-154);
bool calc_ok = true;
const eT* Xm = X.memptr();
eT* outm = out.memptr(); // NOTE: the output matrix is assumed to
have the correct size
switch(N) switch(N)
{ {
case 1: case 1:
{ {
out[0] = eT(1) / X[0]; outm[0] = eT(1) / Xm[0];
}; };
break; break;
case 2: case 2:
{ {
const eT* Xm = X.memptr();
const eT a = Xm[pos<0,0>::n2]; const eT a = Xm[pos<0,0>::n2];
const eT b = Xm[pos<0,1>::n2]; const eT b = Xm[pos<0,1>::n2];
const eT c = Xm[pos<1,0>::n2]; const eT c = Xm[pos<1,0>::n2];
const eT d = Xm[pos<1,1>::n2]; const eT d = Xm[pos<1,1>::n2];
const eT tmp_det = (a*d - b*c); const eT det_val = (a*d - b*c);
if(tmp_det != eT(0)) if(std::abs(det_val) >= det_min)
{ {
eT* outm = out.memptr(); outm[pos<0,0>::n2] = d / det_val;
outm[pos<0,1>::n2] = -b / det_val;
outm[pos<0,0>::n2] = d / tmp_det; outm[pos<1,0>::n2] = -c / det_val;
outm[pos<0,1>::n2] = -b / tmp_det; outm[pos<1,1>::n2] = a / det_val;
outm[pos<1,0>::n2] = -c / tmp_det;
outm[pos<1,1>::n2] = a / tmp_det;
} }
else else
{ {
det_ok = false; calc_ok = false;
} }
}; };
break; break;
case 3: case 3:
{ {
const eT* X_col0 = X.colptr(0); const eT det_val = auxlib::det_tinymat(X,3);
const eT a11 = X_col0[0];
const eT a21 = X_col0[1];
const eT a31 = X_col0[2];
const eT* X_col1 = X.colptr(1);
const eT a12 = X_col1[0];
const eT a22 = X_col1[1];
const eT a32 = X_col1[2];
const eT* X_col2 = X.colptr(2);
const eT a13 = X_col2[0];
const eT a23 = X_col2[1];
const eT a33 = X_col2[2];
const eT tmp_det = a11*(a33*a22 - a32*a23) - a21*(a33*a12-a32*a13) +
a31*(a23*a12 - a22*a13);
if(tmp_det != eT(0))
{
eT* out_col0 = out.colptr(0);
out_col0[0] = (a33*a22 - a32*a23) / tmp_det;
out_col0[1] = -(a33*a21 - a31*a23) / tmp_det;
out_col0[2] = (a32*a21 - a31*a22) / tmp_det;
eT* out_col1 = out.colptr(1);
out_col1[0] = -(a33*a12 - a32*a13) / tmp_det;
out_col1[1] = (a33*a11 - a31*a13) / tmp_det;
out_col1[2] = -(a32*a11 - a31*a12) / tmp_det;
eT* out_col2 = out.colptr(2);
out_col2[0] = (a23*a12 - a22*a13) / tmp_det;
out_col2[1] = -(a23*a11 - a21*a13) / tmp_det;
out_col2[2] = (a22*a11 - a21*a12) / tmp_det;
}
else
{
det_ok = false;
}
};
break;
case 4: if(std::abs(det_val) >= det_min)
{
const eT tmp_det = det(X);
if(tmp_det != eT(0))
{ {
const eT* Xm = X.memptr(); outm[pos<0,0>::n3] = (Xm[pos<2,2>::n3]*Xm[pos<1,1>::n3] - Xm[pos<2
eT* outm = out.memptr(); ,1>::n3]*Xm[pos<1,2>::n3]) / det_val;
outm[pos<1,0>::n3] = -(Xm[pos<2,2>::n3]*Xm[pos<1,0>::n3] - Xm[pos<2
,0>::n3]*Xm[pos<1,2>::n3]) / det_val;
outm[pos<2,0>::n3] = (Xm[pos<2,1>::n3]*Xm[pos<1,0>::n3] - Xm[pos<2
,0>::n3]*Xm[pos<1,1>::n3]) / det_val;
outm[pos<0,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1 outm[pos<0,1>::n3] = -(Xm[pos<2,2>::n3]*Xm[pos<0,1>::n3] - Xm[pos<2
>::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,3>:: ,1>::n3]*Xm[pos<0,2>::n3]) / det_val;
n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*X outm[pos<1,1>::n3] = (Xm[pos<2,2>::n3]*Xm[pos<0,0>::n3] - Xm[pos<2
m[pos<3,2>::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] + Xm[p ,0>::n3]*Xm[pos<0,2>::n3]) / det_val;
os<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det; outm[pos<2,1>::n3] = -(Xm[pos<2,1>::n3]*Xm[pos<0,0>::n3] - Xm[pos<2
outm[pos<1,0>::n4] = ( Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0 ,0>::n3]*Xm[pos<0,1>::n3]) / det_val;
>::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,3>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,2>::n4] + Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
os<1,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<2,0>::n4] = ( Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<1,3>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,1>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<3,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,2>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4]*X
m[pos<3,1>::n4] + Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
outm[pos<0,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] - Xm[p
os<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<1,1>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<2,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<3,1>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,2>::
n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,2>::n4]*X
m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
outm[pos<0,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,1
>::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,3>::
n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<1,2>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<2,2>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] ) / tmp_det;
outm[pos<3,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0
>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,2>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] ) / tmp_det;
outm[pos<0,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,1
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] - Xm[p
os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<1,3>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<2,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0>::n4] - Xm[pos<0,3>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
m[pos<2,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] - Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] ) / tmp_det;
outm[pos<3,3>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0
>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,2>::
n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
m[pos<2,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] + Xm[p
os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] ) / tmp_det;
}
else
{
det_ok = false;
}
};
break;
default:
;
}
return det_ok;
}
template<typename eT>
inline
bool
auxlib::inv_inplace_tinymat(Mat<eT>& X, const uword N)
{
arma_extra_debug_sigprint();
bool det_ok = true; outm[pos<0,2>::n3] = (Xm[pos<1,2>::n3]*Xm[pos<0,1>::n3] - Xm[pos<1
,1>::n3]*Xm[pos<0,2>::n3]) / det_val;
outm[pos<1,2>::n3] = -(Xm[pos<1,2>::n3]*Xm[pos<0,0>::n3] - Xm[pos<1
,0>::n3]*Xm[pos<0,2>::n3]) / det_val;
outm[pos<2,2>::n3] = (Xm[pos<1,1>::n3]*Xm[pos<0,0>::n3] - Xm[pos<1
,0>::n3]*Xm[pos<0,1>::n3]) / det_val;
// for more info, see: const eT check_val = Xm[pos<0,0>::n3]*outm[pos<0,0>::n3] + Xm[pos<0
// http://www.dr-lex.34sp.com/random/matrix_inv.html ,1>::n3]*outm[pos<1,0>::n3] + Xm[pos<0,2>::n3]*outm[pos<2,0>::n3];
// http://www.cvl.iis.u-tokyo.ac.jp/~miyazaki/tech/teche23.html
// http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/f
ourD/index.htm
// http://www.geometrictools.com//LibFoundation/Mathematics/Wm4Matrix4.in
l
switch(N) const T max_diff = (is_float<T>::value) ? T(1e-4) : T(1e-10);
{
case 1:
{
X[0] = eT(1) / X[0];
};
break;
case 2: if(std::abs(T(1) - check_val) > max_diff)
{ {
const eT a = X[pos<0,0>::n2]; calc_ok = false;
const eT b = X[pos<0,1>::n2]; }
const eT c = X[pos<1,0>::n2];
const eT d = X[pos<1,1>::n2];
const eT tmp_det = (a*d - b*c);
if(tmp_det != eT(0))
{
X[pos<0,0>::n2] = d / tmp_det;
X[pos<0,1>::n2] = -b / tmp_det;
X[pos<1,0>::n2] = -c / tmp_det;
X[pos<1,1>::n2] = a / tmp_det;
} }
else else
{ {
det_ok = false; calc_ok = false;
}
};
break;
case 3:
{
eT* X_col0 = X.colptr(0);
eT* X_col1 = X.colptr(1);
eT* X_col2 = X.colptr(2);
const eT a11 = X_col0[0];
const eT a21 = X_col0[1];
const eT a31 = X_col0[2];
const eT a12 = X_col1[0];
const eT a22 = X_col1[1];
const eT a32 = X_col1[2];
const eT a13 = X_col2[0];
const eT a23 = X_col2[1];
const eT a33 = X_col2[2];
const eT tmp_det = a11*(a33*a22 - a32*a23) - a21*(a33*a12-a32*a13) +
a31*(a23*a12 - a22*a13);
if(tmp_det != eT(0))
{
X_col0[0] = (a33*a22 - a32*a23) / tmp_det;
X_col0[1] = -(a33*a21 - a31*a23) / tmp_det;
X_col0[2] = (a32*a21 - a31*a22) / tmp_det;
X_col1[0] = -(a33*a12 - a32*a13) / tmp_det;
X_col1[1] = (a33*a11 - a31*a13) / tmp_det;
X_col1[2] = -(a32*a11 - a31*a12) / tmp_det;
X_col2[0] = (a23*a12 - a22*a13) / tmp_det;
X_col2[1] = -(a23*a11 - a21*a13) / tmp_det;
X_col2[2] = (a22*a11 - a21*a12) / tmp_det;
}
else
{
det_ok = false;
} }
}; };
break; break;
case 4: case 4:
{ {
const eT tmp_det = det(X); const eT det_val = auxlib::det_tinymat(X,4);
if(tmp_det != eT(0)) if(std::abs(det_val) >= det_min)
{ {
const Mat<eT> A(X); outm[pos<0,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1
>::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,3>::
const eT* Am = A.memptr(); n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*X
eT* Xm = X.memptr(); m[pos<3,2>::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<0,0>::n4] = ( Am[pos<1,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,1>: outm[pos<1,0>::n4] = ( Xm[pos<1,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0
:n4] - Am[pos<1,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,1>::n4] + Am[pos<1,3>::n4 >::n4] - Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,3>::
]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] - Am[pos<1,1>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
pos<3,2>::n4] - Am[pos<1,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] + Am[pos m[pos<3,2>::n4] + Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
<1,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<1,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<1,0>::n4] = ( Am[pos<1,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>: outm[pos<2,0>::n4] = ( Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
:n4] - Am[pos<1,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>::n4] - Am[pos<1,3>::n4 >::n4] - Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<1,3>::
]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] + Am[pos<1,0>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4]*X
pos<3,2>::n4] + Am[pos<1,2>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] - Am[pos m[pos<3,1>::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
<1,0>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<2,0>::n4] = ( Am[pos<1,1>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>: outm[pos<3,0>::n4] = ( Xm[pos<1,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
:n4] - Am[pos<1,3>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>::n4] + Am[pos<1,3>::n4 >::n4] - Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<1,2>::
]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] - Am[pos<1,0>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4]*X
pos<3,1>::n4] - Am[pos<1,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] + Am[pos m[pos<3,1>::n4] + Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
<1,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<1,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / det_val;
Xm[pos<3,0>::n4] = ( Am[pos<1,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>:
:n4] - Am[pos<1,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>::n4] - Am[pos<1,2>::n4 outm[pos<0,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,1
]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] + Am[pos<1,0>::n4]*Am[pos<2,2>::n4]*Am[ >::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,3>::
pos<3,1>::n4] + Am[pos<1,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] - Am[pos n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*X
<1,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det; m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] - Xm[p
os<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<0,1>::n4] = ( Am[pos<0,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,1>: outm[pos<1,1>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,1>::n4] - Am[pos<0,3>::n4 >::n4] - Xm[pos<0,3>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] + Am[pos<0,1>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
pos<3,2>::n4] + Am[pos<0,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] - Am[pos m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
<0,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<1,1>::n4] = ( Am[pos<0,2>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>: outm[pos<2,1>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,3>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>::n4] + Am[pos<0,3>::n4 >::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] - Am[pos<0,0>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<2,3>::n4]*X
pos<3,2>::n4] - Am[pos<0,2>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] + Am[pos m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
<0,0>::n4]*Am[pos<2,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<2,1>::n4] = ( Am[pos<0,3>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>: outm[pos<3,1>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<2,2>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,1>::n4]*Am[pos<2,3>::n4]*Am[pos<3,0>::n4] - Am[pos<0,3>::n4 >::n4] - Xm[pos<0,2>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,2>::
]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] + Am[pos<0,0>::n4]*Am[pos<2,3>::n4]*Am[ n4]*Xm[pos<2,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<2,2>::n4]*X
pos<3,1>::n4] + Am[pos<0,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,3>::n4] - Am[pos m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<2,0>::n4]*Xm[pos<3,2>::n4] + Xm[p
<0,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<2,1>::n4]*Xm[pos<3,2>::n4] ) / det_val;
Xm[pos<3,1>::n4] = ( Am[pos<0,1>::n4]*Am[pos<2,2>::n4]*Am[pos<3,0>:
:n4] - Am[pos<0,2>::n4]*Am[pos<2,1>::n4]*Am[pos<3,0>::n4] + Am[pos<0,2>::n4 outm[pos<0,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,1
]*Am[pos<2,0>::n4]*Am[pos<3,1>::n4] - Am[pos<0,0>::n4]*Am[pos<2,2>::n4]*Am[ >::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,3>::
pos<3,1>::n4] - Am[pos<0,1>::n4]*Am[pos<2,0>::n4]*Am[pos<3,2>::n4] + Am[pos n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
<0,0>::n4]*Am[pos<2,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det; m[pos<3,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] + Xm[p
os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<0,2>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<3,1>: outm[pos<1,2>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<3,1>::n4] + Am[pos<0,3>::n4 >::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,3>::
]*Am[pos<1,1>::n4]*Am[pos<3,2>::n4] - Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
pos<3,2>::n4] - Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<3,3>::n4] + Am[pos m[pos<3,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] - Xm[p
<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<1,2>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<3,0>: outm[pos<2,2>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<3,0>::n4] - Am[pos<0,3>::n4 >::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0>::n4] + Xm[pos<0,3>::
]*Am[pos<1,0>::n4]*Am[pos<3,2>::n4] + Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
pos<3,2>::n4] + Am[pos<0,2>::n4]*Am[pos<1,0>::n4]*Am[pos<3,3>::n4] - Am[pos m[pos<3,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,3>::n4] + Xm[p
<0,0>::n4]*Am[pos<1,2>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,3>::n4] ) / det_val;
Xm[pos<2,2>::n4] = ( Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[pos<3,0>: outm[pos<3,2>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,0
:n4] - Am[pos<0,3>::n4]*Am[pos<1,1>::n4]*Am[pos<3,0>::n4] + Am[pos<0,3>::n4 >::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<3,0>::n4] - Xm[pos<0,2>::
]*Am[pos<1,0>::n4]*Am[pos<3,1>::n4] - Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<3,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
pos<3,1>::n4] - Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<3,3>::n4] + Am[pos m[pos<3,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<3,2>::n4] - Xm[p
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<3,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<3,2>::n4] ) / det_val;
Xm[pos<3,2>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<3,0>:
:n4] - Am[pos<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<3,0>::n4] - Am[pos<0,2>::n4 outm[pos<0,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,1
]*Am[pos<1,0>::n4]*Am[pos<3,1>::n4] + Am[pos<0,0>::n4]*Am[pos<1,2>::n4]*Am[ >::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,3>::
pos<3,1>::n4] + Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<3,2>::n4] - Am[pos n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*X
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<3,2>::n4] ) / tmp_det; m[pos<2,2>::n4] + Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] - Xm[p
os<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / det_val;
Xm[pos<0,3>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<2,1>: outm[pos<1,3>::n4] = ( Xm[pos<0,2>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0
:n4] - Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<2,1>::n4] - Am[pos<0,3>::n4 >::n4] - Xm[pos<0,3>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,3>::
]*Am[pos<1,1>::n4]*Am[pos<2,2>::n4] + Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
pos<2,2>::n4] + Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<2,3>::n4] - Am[pos m[pos<2,2>::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] + Xm[p
<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<2,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,3>::n4] ) / det_val;
Xm[pos<1,3>::n4] = ( Am[pos<0,2>::n4]*Am[pos<1,3>::n4]*Am[pos<2,0>: outm[pos<2,3>::n4] = ( Xm[pos<0,3>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0
:n4] - Am[pos<0,3>::n4]*Am[pos<1,2>::n4]*Am[pos<2,0>::n4] + Am[pos<0,3>::n4 >::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,3>::n4]*Xm[pos<2,0>::n4] - Xm[pos<0,3>::
]*Am[pos<1,0>::n4]*Am[pos<2,2>::n4] - Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] + Xm[pos<0,0>::n4]*Xm[pos<1,3>::n4]*X
pos<2,2>::n4] - Am[pos<0,2>::n4]*Am[pos<1,0>::n4]*Am[pos<2,3>::n4] + Am[pos m[pos<2,1>::n4] + Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,3>::n4] - Xm[p
<0,0>::n4]*Am[pos<1,2>::n4]*Am[pos<2,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,3>::n4] ) / det_val;
Xm[pos<2,3>::n4] = ( Am[pos<0,3>::n4]*Am[pos<1,1>::n4]*Am[pos<2,0>: outm[pos<3,3>::n4] = ( Xm[pos<0,1>::n4]*Xm[pos<1,2>::n4]*Xm[pos<2,0
:n4] - Am[pos<0,1>::n4]*Am[pos<1,3>::n4]*Am[pos<2,0>::n4] - Am[pos<0,3>::n4 >::n4] - Xm[pos<0,2>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,0>::n4] + Xm[pos<0,2>::
]*Am[pos<1,0>::n4]*Am[pos<2,1>::n4] + Am[pos<0,0>::n4]*Am[pos<1,3>::n4]*Am[ n4]*Xm[pos<1,0>::n4]*Xm[pos<2,1>::n4] - Xm[pos<0,0>::n4]*Xm[pos<1,2>::n4]*X
pos<2,1>::n4] + Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<2,3>::n4] - Am[pos m[pos<2,1>::n4] - Xm[pos<0,1>::n4]*Xm[pos<1,0>::n4]*Xm[pos<2,2>::n4] + Xm[p
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<2,3>::n4] ) / tmp_det; os<0,0>::n4]*Xm[pos<1,1>::n4]*Xm[pos<2,2>::n4] ) / det_val;
Xm[pos<3,3>::n4] = ( Am[pos<0,1>::n4]*Am[pos<1,2>::n4]*Am[pos<2,0>:
:n4] - Am[pos<0,2>::n4]*Am[pos<1,1>::n4]*Am[pos<2,0>::n4] + Am[pos<0,2>::n4 const eT check_val = Xm[pos<0,0>::n4]*outm[pos<0,0>::n4] + Xm[pos<0
]*Am[pos<1,0>::n4]*Am[pos<2,1>::n4] - Am[pos<0,0>::n4]*Am[pos<1,2>::n4]*Am[ ,1>::n4]*outm[pos<1,0>::n4] + Xm[pos<0,2>::n4]*outm[pos<2,0>::n4] + Xm[pos<
pos<2,1>::n4] - Am[pos<0,1>::n4]*Am[pos<1,0>::n4]*Am[pos<2,2>::n4] + Am[pos 0,3>::n4]*outm[pos<3,0>::n4];
<0,0>::n4]*Am[pos<1,1>::n4]*Am[pos<2,2>::n4] ) / tmp_det;
const T max_diff = (is_float<T>::value) ? T(1e-4) : T(1e-10);
if(std::abs(T(1) - check_val) > max_diff)
{
calc_ok = false;
}
} }
else else
{ {
det_ok = false; calc_ok = false;
} }
}; };
break; break;
default: default:
; ;
} }
return det_ok; return calc_ok;
} }
template<typename eT> template<typename eT>
inline inline
bool bool
auxlib::inv_inplace_lapack(Mat<eT>& out) auxlib::inv_inplace_lapack(Mat<eT>& out)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
if(out.is_empty()) if(out.is_empty())
skipping to change at line 363 skipping to change at line 252
if(info == 0) if(info == 0)
{ {
info = atlas::clapack_getri(atlas::CblasColMajor, out.n_rows, out.mem ptr(), out.n_rows, ipiv.memptr()); info = atlas::clapack_getri(atlas::CblasColMajor, out.n_rows, out.mem ptr(), out.n_rows, ipiv.memptr());
} }
return (info == 0); return (info == 0);
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
blas_int n_rows = out.n_rows; blas_int n_rows = out.n_rows;
blas_int n_cols = out.n_cols; blas_int lwork = (std::max)(blas_int(podarray_prealloc_n_elem::val), n
blas_int lwork = 0; _rows);
blas_int lwork_min = (std::max)(blas_int(1), n_rows); blas_int info = 0;
blas_int info = 0;
podarray<blas_int> ipiv(out.n_rows); podarray<blas_int> ipiv(out.n_rows);
eT work_query[2]; if(n_rows > 16)
blas_int lwork_query = -1; {
eT work_query[2];
blas_int lwork_query = -1;
lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), &work_quer y[0], &lwork_query, &info); lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), &work_qu ery[0], &lwork_query, &info);
if(info == 0) if(info == 0)
{ {
const blas_int lwork_proposed = static_cast<blas_int>( access::tmp_re const blas_int lwork_proposed = static_cast<blas_int>( access::tmp_
al(work_query[0]) ); real(work_query[0]) );
lwork = (lwork_proposed > lwork_min) ? lwork_proposed : lwork_min; if(lwork_proposed > lwork)
} {
else lwork = lwork_proposed;
{ }
return false; }
else
{
return false;
}
} }
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
lapack::getrf(&n_rows, &n_cols, out.memptr(), &n_rows, ipiv.memptr(), & info); lapack::getrf(&n_rows, &n_rows, out.memptr(), &n_rows, ipiv.memptr(), & info);
if(info == 0) if(info == 0)
{ {
lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &lwork, &info); lapack::getri(&n_rows, out.memptr(), &n_rows, ipiv.memptr(), work.mem ptr(), &lwork, &info);
} }
return (info == 0); return (info == 0);
} }
#else #else
{ {
skipping to change at line 482 skipping to change at line 375
{ {
return true; return true;
} }
bool status; bool status;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
char uplo = (layout == 0) ? 'U' : 'L'; char uplo = (layout == 0) ? 'U' : 'L';
blas_int n = blas_int(out.n_rows); blas_int n = blas_int(out.n_rows);
blas_int lwork = 3 * (n*n); // TODO: use lwork = -1 to determine optima l size blas_int lwork = (std::max)(blas_int(podarray_prealloc_n_elem::val), 2* n);
blas_int info = 0; blas_int info = 0;
podarray<blas_int> ipiv; podarray<blas_int> ipiv;
ipiv.set_size(out.n_rows); ipiv.set_size(out.n_rows);
podarray<eT> work; podarray<eT> work;
work.set_size( uword(lwork) ); work.set_size( uword(lwork) );
lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info); lapack::sytrf(&uplo, &n, out.memptr(), &n, ipiv.memptr(), work.memptr() , &lwork, &info);
skipping to change at line 524 skipping to change at line 417
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uword layout) auxlib::inv_sympd(Mat<eT>& out, const Base<eT,T1>& X, const uword layout)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
out = X.get_ref(); out = X.get_ref();
arma_debug_check( (out.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (out.is_square() == false), "inv_sympd(): given matrix is not square" );
if(out.is_empty()) if(out.is_empty())
{ {
return true; return true;
} }
bool status; bool status;
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
skipping to change at line 555 skipping to change at line 448
lapack::potri(&uplo, &n, out.memptr(), &n, &info); lapack::potri(&uplo, &n, out.memptr(), &n, &info);
out = (layout == 0) ? symmatu(out) : symmatl(out); out = (layout == 0) ? symmatu(out) : symmatl(out);
status = (info == 0); status = (info == 0);
} }
} }
#else #else
{ {
arma_ignore(layout); arma_ignore(layout);
arma_stop("inv(): use of LAPACK needs to be enabled"); arma_stop("inv_sympd(): use of LAPACK needs to be enabled");
status = false; status = false;
} }
#endif #endif
return status; return status;
} }
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
eT eT
auxlib::det(const Base<eT,T1>& X, const bool slow) auxlib::det(const Base<eT,T1>& X, const bool slow)
{ {
arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T;
const bool make_copy = (is_Mat<T1>::value == true) ? true : false;
const unwrap<T1> tmp(X.get_ref()); const unwrap<T1> tmp(X.get_ref());
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
arma_debug_check( (A.is_square() == false), "det(): matrix is not square" ); arma_debug_check( (A.is_square() == false), "det(): matrix is not square" );
const bool make_copy = (is_Mat<T1>::value == true) ? true : false; const uword N = A.n_rows;
if(slow == false) if( (N <= 4) && (slow == false) )
{ {
const uword N = A.n_rows; const T det_min = (is_float<T>::value) ? T(1e-19) : T(1e-154);
const eT det_val = auxlib::det_tinymat(A, N);
switch(N)
{
case 0:
case 1:
case 2:
return auxlib::det_tinymat(A, N);
break;
case 3:
case 4:
{
const eT tmp_det = auxlib::det_tinymat(A, N);
return (tmp_det != eT(0)) ? tmp_det : auxlib::det_lapack(A, make_co
py);
}
break;
default: return (std::abs(det_val) >= det_min) ? det_val : auxlib::det_lapack(A,
return auxlib::det_lapack(A, make_copy); make_copy);
} }
else
{
return auxlib::det_lapack(A, make_copy);
} }
return auxlib::det_lapack(A, make_copy);
} }
template<typename eT> template<typename eT>
inline inline
eT eT
auxlib::det_tinymat(const Mat<eT>& X, const uword N) auxlib::det_tinymat(const Mat<eT>& X, const uword N)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
switch(N) switch(N)
skipping to change at line 638 skipping to change at line 522
case 3: case 3:
{ {
// const double tmp1 = X.at(0,0) * X.at(1,1) * X.at(2,2); // const double tmp1 = X.at(0,0) * X.at(1,1) * X.at(2,2);
// const double tmp2 = X.at(0,1) * X.at(1,2) * X.at(2,0); // const double tmp2 = X.at(0,1) * X.at(1,2) * X.at(2,0);
// const double tmp3 = X.at(0,2) * X.at(1,0) * X.at(2,1); // const double tmp3 = X.at(0,2) * X.at(1,0) * X.at(2,1);
// const double tmp4 = X.at(2,0) * X.at(1,1) * X.at(0,2); // const double tmp4 = X.at(2,0) * X.at(1,1) * X.at(0,2);
// const double tmp5 = X.at(2,1) * X.at(1,2) * X.at(0,0); // const double tmp5 = X.at(2,1) * X.at(1,2) * X.at(0,0);
// const double tmp6 = X.at(2,2) * X.at(1,0) * X.at(0,1); // const double tmp6 = X.at(2,2) * X.at(1,0) * X.at(0,1);
// return (tmp1+tmp2+tmp3) - (tmp4+tmp5+tmp6); // return (tmp1+tmp2+tmp3) - (tmp4+tmp5+tmp6);
const eT* a_col0 = X.colptr(0); const eT* Xm = X.memptr();
const eT a11 = a_col0[0];
const eT a21 = a_col0[1];
const eT a31 = a_col0[2];
const eT* a_col1 = X.colptr(1);
const eT a12 = a_col1[0];
const eT a22 = a_col1[1];
const eT a32 = a_col1[2];
const eT* a_col2 = X.colptr(2);
const eT a13 = a_col2[0];
const eT a23 = a_col2[1];
const eT a33 = a_col2[2];
return ( a11*(a33*a22 - a32*a23) - a21*(a33*a12-a32*a13) + a31*(a23*a const eT val1 = Xm[pos<0,0>::n3]*(Xm[pos<2,2>::n3]*Xm[pos<1,1>::n3] -
12 - a22*a13) ); Xm[pos<2,1>::n3]*Xm[pos<1,2>::n3]);
const eT val2 = Xm[pos<1,0>::n3]*(Xm[pos<2,2>::n3]*Xm[pos<0,1>::n3] -
Xm[pos<2,1>::n3]*Xm[pos<0,2>::n3]);
const eT val3 = Xm[pos<2,0>::n3]*(Xm[pos<1,2>::n3]*Xm[pos<0,1>::n3] -
Xm[pos<1,1>::n3]*Xm[pos<0,2>::n3]);
return ( val1 - val2 + val3 );
} }
break; break;
case 4: case 4:
{ {
const eT* Xm = X.memptr(); const eT* Xm = X.memptr();
const eT val = \ const eT val = \
Xm[pos<0,3>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3 ,0>::n4] \ Xm[pos<0,3>::n4] * Xm[pos<1,2>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3 ,0>::n4] \
- Xm[pos<0,2>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3 ,0>::n4] \ - Xm[pos<0,2>::n4] * Xm[pos<1,3>::n4] * Xm[pos<2,1>::n4] * Xm[pos<3 ,0>::n4] \
skipping to change at line 1317 skipping to change at line 1192
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 3 * (1 + 6*N + 2*(N*N)); blas_int lwork = 2 * (1 + 6*N + 2*(N*N));
blas_int liwork = 3 * (3 + 5*N + 2); blas_int liwork = 3 * (3 + 5*N);
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>( lwork) ); podarray<eT> work( static_cast<uword>( lwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) ); podarray<blas_int> iwork( static_cast<uword>(liwork) );
arma_extra_debug_print("lapack::syevd()"); arma_extra_debug_print("lapack::syevd()");
lapack::syevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, iwork.memptr(), &liwork, &info); lapack::syevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, iwork.memptr(), &liwork, &info);
return (info == 0); return (info == 0);
} }
skipping to change at line 1369 skipping to change at line 1244
eigvec.reset(); eigvec.reset();
return true; return true;
} }
eigval.set_size(eigvec.n_rows); eigval.set_size(eigvec.n_rows);
char jobz = 'V'; char jobz = 'V';
char uplo = 'U'; char uplo = 'U';
blas_int N = blas_int(eigvec.n_rows); blas_int N = blas_int(eigvec.n_rows);
blas_int lwork = 3 * (2*N + N*N); blas_int lwork = 2 * (2*N + N*N);
blas_int lrwork = 3 * (1 + 5*N + 2*(N*N)); blas_int lrwork = 2 * (1 + 5*N + 2*(N*N));
blas_int liwork = 3 * (3 + 5*N); blas_int liwork = 3 * (3 + 5*N);
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(lrwork) ); podarray<T> rwork( static_cast<uword>(lrwork) );
podarray<blas_int> iwork( static_cast<uword>(liwork) ); podarray<blas_int> iwork( static_cast<uword>(liwork) );
arma_extra_debug_print("lapack::heevd()"); arma_extra_debug_print("lapack::heevd()");
lapack::heevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, rwork.memptr(), &lrwork, iwork.memptr(), &liwork, &in fo); lapack::heevd(&jobz, &uplo, &N, eigvec.memptr(), &N, eigval.memptr(), w ork.memptr(), &lwork, rwork.memptr(), &lrwork, iwork.memptr(), &liwork, &in fo);
skipping to change at line 1458 skipping to change at line 1333
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size( ((jobvl == 'V') ? A_n_rows : 1), A_n_rows );
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size( ((jobvr == 'V') ? A_n_rows : 1), A_n_rows );
blas_int N = blas_int(A_n_rows); blas_int N = blas_int(A_n_rows);
blas_int ldvl = blas_int(l_eigvec.n_rows);
blas_int ldvr = blas_int(r_eigvec.n_rows);
blas_int lwork = 3 * ( (std::max)(blas_int(1), 4*N) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), 4*N) );
blas_int info = 0; blas_int info = 0;
podarray<T> work( static_cast<uword>(lwork) ); podarray<T> work( static_cast<uword>(lwork) );
podarray<T> wr(A_n_rows); podarray<T> wr(A_n_rows);
podarray<T> wi(A_n_rows); podarray<T> wi(A_n_rows);
arma_extra_debug_print("lapack::geev()"); arma_extra_debug_print("lapack::geev()");
lapack::geev(&jobvl, &jobvr, &N, A.memptr(), &N, wr.memptr(), wi.memptr (), l_eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, &i nfo); lapack::geev(&jobvl, &jobvr, &N, A.memptr(), &N, wr.memptr(), wi.memptr (), l_eigvec.memptr(), &ldvl, r_eigvec.memptr(), &ldvr, work.memptr(), &lwo rk, &info);
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
for(uword i=0; i<A_n_rows; ++i) for(uword i=0; i<A_n_rows; ++i)
{ {
eigval[i] = std::complex<T>(wr[i], wi[i]); eigval[i] = std::complex<T>(wr[i], wi[i]);
} }
return (info == 0); return (info == 0);
} }
#else #else
skipping to change at line 1560 skipping to change at line 1437
eigval.reset(); eigval.reset();
l_eigvec.reset(); l_eigvec.reset();
r_eigvec.reset(); r_eigvec.reset();
return true; return true;
} }
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
eigval.set_size(A_n_rows); eigval.set_size(A_n_rows);
l_eigvec.set_size(A_n_rows, A_n_rows); l_eigvec.set_size( ((jobvl == 'V') ? A_n_rows : 1), A_n_rows );
r_eigvec.set_size(A_n_rows, A_n_rows); r_eigvec.set_size( ((jobvr == 'V') ? A_n_rows : 1), A_n_rows );
blas_int N = blas_int(A_n_rows); blas_int N = blas_int(A_n_rows);
blas_int ldvl = blas_int(l_eigvec.n_rows);
blas_int ldvr = blas_int(r_eigvec.n_rows);
blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*N) ); blas_int lwork = 3 * ( (std::max)(blas_int(1), 2*N) );
blas_int info = 0; blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) ); podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(2*N) ); podarray<T> rwork( static_cast<uword>(2*N) );
arma_extra_debug_print("lapack::cx_geev()"); arma_extra_debug_print("lapack::cx_geev()");
lapack::cx_geev(&jobvl, &jobvr, &N, A.memptr(), &N, eigval.memptr(), l_ eigvec.memptr(), &N, r_eigvec.memptr(), &N, work.memptr(), &lwork, rwork.me mptr(), &info); lapack::cx_geev(&jobvl, &jobvr, &N, A.memptr(), &N, eigval.memptr(), l_ eigvec.memptr(), &ldvl, r_eigvec.memptr(), &ldvr, work.memptr(), &lwork, rw ork.memptr(), &info);
return (info == 0); return (info == 0);
} }
#else #else
{ {
arma_ignore(eigval); arma_ignore(eigval);
arma_ignore(l_eigvec); arma_ignore(l_eigvec);
arma_ignore(r_eigvec); arma_ignore(r_eigvec);
arma_ignore(X); arma_ignore(X);
arma_ignore(side); arma_ignore(side);
arma_stop("eig_gen(): use of LAPACK needs to be enabled"); arma_stop("eig_gen(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
//! Eigenvalues and eigenvectors of general square real matrix pair.
//! The argument 'side' specifies which eigenvectors should be calculated.
template<typename T, typename T1, typename T2>
inline
bool
auxlib::eig_pair
(
Col< std::complex<T> >& eigval,
Mat<T>& l_eigvec,
Mat<T>& r_eigvec,
const Base<T,T1>& X,
const Base<T,T2>& Y,
const char side
)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
char jobvl;
char jobvr;
switch(side)
{
case 'l': // left
jobvl = 'V';
jobvr = 'N';
break;
case 'r': // right
jobvl = 'N';
jobvr = 'V';
break;
case 'b': // both
jobvl = 'V';
jobvr = 'V';
break;
case 'n': // neither
jobvl = 'N';
jobvr = 'N';
break;
default:
arma_stop("eig_pair(): parameter 'side' is invalid");
return false;
}
Mat<T> A(X.get_ref());
Mat<T> B(Y.get_ref());
arma_debug_check( ((A.is_square() == false) || (B.is_square() == false)
), "eig_pair(): given matrix is not square" );
arma_debug_check( (A.n_rows != B.n_rows), "eig_pair(): given matrices m
ust have the same size" );
if(A.is_empty())
{
eigval.reset();
l_eigvec.reset();
r_eigvec.reset();
return true;
}
const uword A_n_rows = A.n_rows;
eigval.set_size(A_n_rows);
l_eigvec.set_size( ((jobvl == 'V') ? A_n_rows : 1), A_n_rows );
r_eigvec.set_size( ((jobvr == 'V') ? A_n_rows : 1), A_n_rows );
blas_int N = blas_int(A_n_rows);
blas_int ldvl = blas_int(l_eigvec.n_rows);
blas_int ldvr = blas_int(r_eigvec.n_rows);
blas_int lwork = 3 * ( (std::max)(blas_int(1), 8*N) );
blas_int info = 0;
podarray<T> work( static_cast<uword>(lwork) );
podarray<T> alphar(A_n_rows);
podarray<T> alphai(A_n_rows);
podarray<T> beta(A_n_rows);
arma_extra_debug_print("lapack::ggev()");
lapack::ggev
(
&jobvl, &jobvr, &N,
A.memptr(), &N, B.memptr(), &N,
alphar.memptr(), alphai.memptr(), beta.memptr(),
l_eigvec.memptr(), &ldvl, r_eigvec.memptr(), &ldvr,
work.memptr(), &lwork,
&info
);
if(info == 0)
{
// from LAPACK docs:
// If ALPHAI(j) is zero, then the j-th eigenvalue is real;
// if positive, then the j-th and (j+1)-st eigenvalues are a complex
conjugate pair,
// with ALPHAI(j+1) negative.
eigval.set_size(A_n_rows);
const T* alphar_mem = alphar.memptr();
const T* alphai_mem = alphai.memptr();
const T* beta_mem = beta.memptr();
bool beta_has_zero = false;
for(uword j=0; j<A_n_rows; ++j)
{
const T alphai_val = alphai_mem[j];
const T beta_val = beta_mem[j];
if(beta_val == T(0)) { beta_has_zero = true; }
const T re = alphar_mem[j] / beta_val;
const T im = alphai_val / beta_val;
eigval[j] = std::complex<T>(re, im);
if( (alphai_val > T(0)) && (j < (A_n_rows-1)) )
{
// ensure we have exact conjugate
++j;
eigval[j] = std::complex<T>(re,-im);
}
}
arma_debug_warn(beta_has_zero, "eig_pair(): warning: given matrix app
ears ill-conditioned");
return true;
}
else
{
return false;
}
}
#else
{
arma_ignore(eigval);
arma_ignore(l_eigvec);
arma_ignore(r_eigvec);
arma_ignore(X);
arma_ignore(Y);
arma_ignore(side);
arma_stop("eig_pair(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
//! Eigenvalues and eigenvectors of general square complex matrix pair.
//! The argument 'side' specifies which eigenvectors should be calculated
template<typename T, typename T1, typename T2>
inline
bool
auxlib::eig_pair
(
Col< std::complex<T> >& eigval,
Mat< std::complex<T> >& l_eigvec,
Mat< std::complex<T> >& r_eigvec,
const Base< std::complex<T>, T1 >& X,
const Base< std::complex<T>, T2 >& Y,
const char side
)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
typedef typename std::complex<T> eT;
char jobvl;
char jobvr;
switch(side)
{
case 'l': // left
jobvl = 'V';
jobvr = 'N';
break;
case 'r': // right
jobvl = 'N';
jobvr = 'V';
break;
case 'b': // both
jobvl = 'V';
jobvr = 'V';
break;
case 'n': // neither
jobvl = 'N';
jobvr = 'N';
break;
default:
arma_stop("eig_pair(): parameter 'side' is invalid");
return false;
}
Mat<eT> A(X.get_ref());
Mat<eT> B(Y.get_ref());
arma_debug_check( ((A.is_square() == false) || (B.is_square() == false)
), "eig_pair(): given matrix is not square" );
arma_debug_check( (A.n_rows != B.n_rows), "eig_pair(): given matrices m
ust have the same size" );
if(A.is_empty())
{
eigval.reset();
l_eigvec.reset();
r_eigvec.reset();
return true;
}
const uword A_n_rows = A.n_rows;
podarray<eT> alpha(A_n_rows);
podarray<eT> beta(A_n_rows);
l_eigvec.set_size( ((jobvl == 'V') ? A_n_rows : 1), A_n_rows );
r_eigvec.set_size( ((jobvr == 'V') ? A_n_rows : 1), A_n_rows );
blas_int N = blas_int(A_n_rows);
blas_int ldvl = blas_int(l_eigvec.n_rows);
blas_int ldvr = blas_int(r_eigvec.n_rows);
blas_int lwork = 3 * ((std::max)(1,2*N));
blas_int info = 0;
podarray<eT> work( static_cast<uword>(lwork) );
podarray<T> rwork( static_cast<uword>(8*N) );
arma_extra_debug_print("lapack::cx_ggev()");
lapack::cx_ggev
(
&jobvl, &jobvr, &N,
A.memptr(), &N, B.memptr(), &N,
alpha.memptr(), beta.memptr(),
l_eigvec.memptr(), &ldvl, r_eigvec.memptr(), &ldvr,
work.memptr(), &lwork, rwork.memptr(),
&info
);
if(info == 0)
{
// TODO: figure out a more robust way to create the eigen values;
// TODO: from LAPACK docs: the quotients ALPHA(j)/BETA(j) may easily
over- or underflow, and BETA(j) may even be zero
eigval.set_size(A_n_rows);
eT* eigval_mem = eigval.memptr();
const eT* alpha_mem = alpha.memptr();
const eT* beta_mem = beta.memptr();
const std::complex<T> cx_zero( T(0), T(0) );
bool beta_has_zero = false;
for(uword i=0; i<A_n_rows; ++i)
{
eigval_mem[i] = alpha_mem[i] / beta_mem[i];
if(beta_mem[i] == cx_zero) { beta_has_zero = true; }
// // TODO: not sure if this is the right approach
// eigval_mem[i] = (beta_mem[i] != cx_zero) ? (alpha_mem[i] / beta_
mem[i]) : cx_zero;
}
arma_debug_warn(beta_has_zero, "eig_pair(): warning: given matrix app
ears ill-conditioned");
return true;
}
else
{
return false;
}
}
#else
{
arma_ignore(eigval);
arma_ignore(l_eigvec);
arma_ignore(r_eigvec);
arma_ignore(X);
arma_ignore(Y);
arma_ignore(side);
arma_stop("eig_pair(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X) auxlib::chol(Mat<eT>& out, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
out = X.get_ref(); out = X.get_ref();
skipping to change at line 2490 skipping to change at line 2663
arma_ignore(S); arma_ignore(S);
arma_ignore(V); arma_ignore(V);
arma_ignore(X); arma_ignore(X);
arma_ignore(mode); arma_ignore(mode);
arma_stop("svd(): use of LAPACK needs to be enabled"); arma_stop("svd(): use of LAPACK needs to be enabled");
return false; return false;
} }
#endif #endif
} }
// EXPERIMENTAL
template<typename eT, typename T1>
inline
bool
auxlib::svd_dc(Col<eT>& S, const Base<eT,T1>& X, uword& X_n_rows, uword& X_
n_cols)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK)
{
Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows;
X_n_cols = A.n_cols;
if(A.is_empty())
{
S.reset();
return true;
}
Mat<eT> U(1, 1);
Mat<eT> V(1, 1);
char jobz = 'N';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 3 * ( 3*min_mn + std::max( std::max(m,n), 7*min_mn )
);
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::gesdd<eT>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, iwork.memptr(), &info
);
return (info == 0);
}
#else
{
arma_ignore(S);
arma_ignore(X);
arma_ignore(X_n_rows);
arma_ignore(X_n_cols);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
// EXPERIMENTAL
template<typename T, typename T1>
inline
bool
auxlib::svd_dc(Col<T>& S, const Base<std::complex<T>, T1>& X, uword& X_n_ro
ws, uword& X_n_cols)
{
arma_extra_debug_sigprint();
#if (defined(ARMA_USE_LAPACK) && defined(ARMA_DONT_USE_CX_GESDD))
{
arma_extra_debug_print("auxlib::svd_dc(): redirecting to auxlib::svd(),
as use of lapack::cx_gesdd() is disabled");
return auxlib::svd(S, X, X_n_rows, X_n_cols);
}
#elif defined(ARMA_USE_LAPACK)
{
typedef std::complex<T> eT;
Mat<eT> A(X.get_ref());
X_n_rows = A.n_rows;
X_n_cols = A.n_cols;
if(A.is_empty())
{
S.reset();
return true;
}
Mat<eT> U(1, 1);
Mat<eT> V(1, 1);
char jobz = 'N';
blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows);
blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 3 * (2*min_mn + std::max(m,n));
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork ) );
podarray<T> rwork( static_cast<uword>(5*min_mn) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::cx_gesdd<T>
(
&jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info
);
return (info == 0);
}
#else
{
arma_ignore(S);
arma_ignore(X);
arma_ignore(X_n_rows);
arma_ignore(X_n_cols);
arma_stop("svd(): use of LAPACK needs to be enabled");
return false;
}
#endif
}
// EXPERIMENTAL
template<typename eT, typename T1>
inline
bool
auxlib::svd_dc(Col<eT>& S, const Base<eT,T1>& X)
{
arma_extra_debug_sigprint();
uword junk;
return auxlib::svd_dc(S, X, junk, junk);
}
// EXPERIMENTAL
template<typename T, typename T1>
inline
bool
auxlib::svd_dc(Col<T>& S, const Base<std::complex<T>, T1>& X)
{
arma_extra_debug_sigprint();
uword junk;
return auxlib::svd_dc(S, X, junk, junk);
}
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
bool bool
auxlib::svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X) auxlib::svd_dc(Mat<eT>& U, Col<eT>& S, Mat<eT>& V, const Base<eT,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
skipping to change at line 2517 skipping to change at line 2845
} }
U.set_size(A.n_rows, A.n_rows); U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols); V.set_size(A.n_cols, A.n_cols);
char jobz = 'A'; char jobz = 'A';
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n); blas_int min_mn = (std::min)(m,n);
blas_int max_mn = (std::max)(m,n);
blas_int lda = blas_int(A.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldu = blas_int(U.n_rows); blas_int ldu = blas_int(U.n_rows);
blas_int ldvt = blas_int(V.n_rows); blas_int ldvt = blas_int(V.n_rows);
blas_int lwork = 3 * ( 3*min_mn*min_mn + (std::max)( (std::max)(m,n), blas_int lwork1 = 3*min_mn*min_mn + (std::max)( max_mn, 4*min_mn*min_m
4*min_mn*min_mn + 4*min_mn ) ); n + 4*min_mn );
blas_int lwork2 = 3*min_mn + (std::max)( max_mn, 4*min_mn*min_m
n + 3*min_mn + max_mn );
blas_int lwork = 2 * ((std::max)(lwork1, lwork2)); // due to differe
nces between lapack 3.1 and 3.4
blas_int info = 0; blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) ); S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork ) ); podarray<eT> work( static_cast<uword>(lwork ) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn) ); podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
lapack::gesdd<eT> lapack::gesdd<eT>
( (
&jobz, &m, &n, &jobz, &m, &n,
skipping to change at line 2583 skipping to change at line 2914
S.reset(); S.reset();
V.eye(A.n_cols, A.n_cols); V.eye(A.n_cols, A.n_cols);
return true; return true;
} }
U.set_size(A.n_rows, A.n_rows); U.set_size(A.n_rows, A.n_rows);
V.set_size(A.n_cols, A.n_cols); V.set_size(A.n_cols, A.n_cols);
char jobz = 'A'; char jobz = 'A';
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n); blas_int min_mn = (std::min)(m,n);
blas_int lda = blas_int(A.n_rows); blas_int max_mn = (std::max)(m,n);
blas_int ldu = blas_int(U.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldvt = blas_int(V.n_rows); blas_int ldu = blas_int(U.n_rows);
blas_int lwork = 3 * (min_mn*min_mn + 2*min_mn + (std::max)(m,n)); blas_int ldvt = blas_int(V.n_rows);
blas_int info = 0; blas_int lwork = 2 * (min_mn*min_mn + 2*min_mn + max_mn);
blas_int lrwork1 = 5*min_mn*min_mn + 7*min_mn;
blas_int lrwork2 = min_mn * ((std::max)(5*min_mn+7, 2*max_mn + 2*min_mn
+1));
blas_int lrwork = (std::max)(lrwork1, lrwork2); // due to differences
between lapack 3.1 and 3.4
blas_int info = 0;
S.set_size( static_cast<uword>(min_mn) ); S.set_size( static_cast<uword>(min_mn) );
podarray<eT> work( static_cast<uword>(lwork podarray<eT> work( static_cast<uword>(lwork ) );
) ); podarray<T> rwork( static_cast<uword>(lrwork ) );
podarray<T> rwork( static_cast<uword>(5*min_mn*min_mn + 7*min_mn podarray<blas_int> iwork( static_cast<uword>(8*min_mn) );
) );
podarray<blas_int> iwork( static_cast<uword>(8*min_mn
) );
lapack::cx_gesdd<T> lapack::cx_gesdd<T>
( (
&jobz, &m, &n, &jobz, &m, &n,
A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt, A.memptr(), &lda, S.memptr(), U.memptr(), &ldu, V.memptr(), &ldvt,
work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info work.memptr(), &lwork, rwork.memptr(), iwork.memptr(), &info
); );
op_htrans::apply_mat_inplace(V); op_htrans::apply_mat_inplace(V);
skipping to change at line 2637 skipping to change at line 2972
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
char jobz = 'S'; char jobz = 'S';
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n); blas_int min_mn = (std::min)(m,n);
blas_int max_mn = (std::max)(m,n);
blas_int lda = blas_int(A.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldu = m; blas_int ldu = m;
blas_int ldvt = min_mn; blas_int ldvt = min_mn;
blas_int lwork = 3 * ( 3*min_mn + 4*min_mn*min_mn + 3*min_mn + std::ma blas_int lwork1 = 3*min_mn*min_mn + (std::max)( max_mn, 4*min_mn*min_mn
x(m,n) ); // based on lapack 3.4 docs, which have a slightly different fo + 4*min_mn );
rmula to lapack 3.1 docs blas_int lwork2 = 3*min_mn + (std::max)( max_mn, 4*min_mn*min_mn
+ 3*min_mn + max_mn );
blas_int lwork = 2 * ((std::max)(lwork1, lwork2)); // due to differen
ces between lapack 3.1 and 3.4
blas_int info = 0; blas_int info = 0;
if(A.is_empty()) if(A.is_empty())
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) ); V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) );
return true; return true;
} }
skipping to change at line 2704 skipping to change at line 3042
return auxlib::svd_econ(U, S, V, X, 'b'); return auxlib::svd_econ(U, S, V, X, 'b');
} }
#elif defined(ARMA_USE_LAPACK) #elif defined(ARMA_USE_LAPACK)
{ {
typedef std::complex<T> eT; typedef std::complex<T> eT;
Mat<eT> A(X.get_ref()); Mat<eT> A(X.get_ref());
char jobz = 'S'; char jobz = 'S';
blas_int m = blas_int(A.n_rows); blas_int m = blas_int(A.n_rows);
blas_int n = blas_int(A.n_cols); blas_int n = blas_int(A.n_cols);
blas_int min_mn = (std::min)(m,n); blas_int min_mn = (std::min)(m,n);
blas_int max_mn = (std::max)(m,n); blas_int max_mn = (std::max)(m,n);
blas_int lda = blas_int(A.n_rows); blas_int lda = blas_int(A.n_rows);
blas_int ldu = m; blas_int ldu = m;
blas_int ldvt = min_mn; blas_int ldvt = min_mn;
blas_int lwork = 3 * (min_mn*min_mn + 2*min_mn + max_mn); blas_int lwork = 2 * (min_mn*min_mn + 2*min_mn + max_mn);
blas_int lrwork = min_mn * (std::max)( 5*min_mn+7, 2*max_mn + 2*min_mn+ blas_int lrwork1 = 5*min_mn*min_mn + 7*min_mn;
1 ); // based on lapack 3.4 docs, which have a different formula to lapack blas_int lrwork2 = min_mn * ((std::max)(5*min_mn+7, 2*max_mn + 2*min_mn
3.1 docs +1));
blas_int info = 0; blas_int lrwork = (std::max)(lrwork1, lrwork2); // due to differences
between lapack 3.1 and 3.4
blas_int info = 0;
if(A.is_empty()) if(A.is_empty())
{ {
U.eye(); U.eye();
S.reset(); S.reset();
V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) ); V.eye( static_cast<uword>(n), static_cast<uword>(min_mn) );
return true; return true;
} }
S.set_size( static_cast<uword>(min_mn) ); S.set_size( static_cast<uword>(min_mn) );
skipping to change at line 2771 skipping to change at line 3111
auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool sl ow) auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Base<eT,T1>& X, const bool sl ow)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
bool status = false; bool status = false;
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
if( (A_n_rows <= 4) && (slow == false) ) if( (A_n_rows <= 4) && (slow == false) )
{ {
Mat<eT> A_inv; Mat<eT> A_inv(A_n_rows, A_n_rows);
status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows); status = auxlib::inv_noalias_tinymat(A_inv, A, A_n_rows);
if(status == true) if(status == true)
{ {
const unwrap_check<T1> Y( X.get_ref(), out ); const unwrap_check<T1> Y( X.get_ref(), out );
const Mat<eT>& B = Y.M; const Mat<eT>& B = Y.M;
const uword B_n_rows = B.n_rows; const uword B_n_rows = B.n_rows;
const uword B_n_cols = B.n_cols; const uword B_n_cols = B.n_cols;
 End of changes. 60 change blocks. 
440 lines changed or deleted 742 lines changed or added


 compiler_setup.hpp   compiler_setup.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2014 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2014 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#define arma_hot #define arma_hot
#define arma_cold #define arma_cold
#define arma_pure #define arma_pure
#define arma_const #define arma_const
#define arma_aligned #define arma_aligned
skipping to change at line 42 skipping to change at line 42
#else #else
#define arma_fortran(function) arma_fortran2_noprefix(function) #define arma_fortran(function) arma_fortran2_noprefix(function)
#define arma_atlas(function) function #define arma_atlas(function) function
#endif #endif
#define arma_fortran_prefix(function) arma_fortran2_prefix(function) #define arma_fortran_prefix(function) arma_fortran2_prefix(function)
#define arma_fortran_noprefix(function) arma_fortran2_noprefix(function) #define arma_fortran_noprefix(function) arma_fortran2_noprefix(function)
#define ARMA_INCFILE_WRAP(x) <x> #define ARMA_INCFILE_WRAP(x) <x>
// posix_memalign() is part of IEEE standard 1003.1
// http://pubs.opengroup.org/onlinepubs/009696899/functions/posix_memalign.
html
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
// http://sourceforge.net/p/predef/wiki/Standards/
#if ( defined(_POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO >= 200112L) )
#define ARMA_HAVE_POSIX_MEMALIGN
#endif
#if defined(__APPLE__)
#define ARMA_BLAS_SDOT_BUG
#undef ARMA_HAVE_POSIX_MEMALIGN
#endif
#if defined(__MINGW32__)
#undef ARMA_HAVE_POSIX_MEMALIGN
#endif
#if (__cplusplus >= 201103L) #if (__cplusplus >= 201103L)
#if !defined(ARMA_USE_CXX11) #if !defined(ARMA_USE_CXX11)
#define ARMA_USE_CXX11 #define ARMA_USE_CXX11
#endif #endif
#endif #endif
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
#if !defined(ARMA_USE_U64S64) #if !defined(ARMA_USE_U64S64)
#define ARMA_USE_U64S64 #define ARMA_USE_U64S64
#endif #endif
#endif #endif
#if defined(ARMA_64BIT_WORD) #if defined(ARMA_64BIT_WORD)
#if !defined(ARMA_USE_U64S64) #if !defined(ARMA_USE_U64S64)
#define ARMA_USE_U64S64 #define ARMA_USE_U64S64
#endif #endif
#endif #endif
#if (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L))
#define ARMA_HAVE_GETTIMEOFDAY
#if defined(__GNUG__)
#define ARMA_HAVE_SNPRINTF
#define ARMA_HAVE_ISFINITE
#define ARMA_HAVE_LOG1P
#endif
#endif
// posix_memalign() is part of IEEE standard 1003.1
// http://pubs.opengroup.org/onlinepubs/009696899/functions/posix_memalign.
html
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
// http://sourceforge.net/p/predef/wiki/Standards/
#if ( defined(_POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO >= 200112L) )
#define ARMA_HAVE_POSIX_MEMALIGN
#endif
#if defined(__APPLE__)
#define ARMA_BLAS_SDOT_BUG
#undef ARMA_HAVE_POSIX_MEMALIGN
#endif
#if defined(__MINGW32__)
#undef ARMA_HAVE_POSIX_MEMALIGN
#endif
#if defined (__GNUG__) #if defined (__GNUG__)
#define ARMA_FNSIG __PRETTY_FUNCTION__ #define ARMA_FNSIG __PRETTY_FUNCTION__
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
#define ARMA_FNSIG __FUNCSIG__ #define ARMA_FNSIG __FUNCSIG__
#elif defined(__INTEL_COMPILER) #elif defined(__INTEL_COMPILER)
#define ARMA_FNSIG __FUNCTION__ #define ARMA_FNSIG __FUNCTION__
#elif defined(ARMA_USE_CXX11) #elif defined(ARMA_USE_CXX11)
#define ARMA_FNSIG __func__ #define ARMA_FNSIG __func__
#else #else
#define ARMA_FNSIG "(unknown)" #define ARMA_FNSIG "(unknown)"
#endif #endif
#if defined(__INTEL_COMPILER) #if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER < 1000) #if (__INTEL_COMPILER_BUILD_DATE < 20090623)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#if (__INTEL_COMPILER <= 1110)
#undef ARMA_HAVE_STD_ISFINITE
#endif
#undef ARMA_HAVE_STD_TR1
#define ARMA_GOOD_COMPILER
#define ARMA_HAVE_ICC_ASSUME_ALIGNED #define ARMA_HAVE_ICC_ASSUME_ALIGNED
#if defined(__GNUG__) #endif
// #undef arma_aligned
// #define arma_aligned __attribute__((aligned))
#undef arma_align_mem
#define arma_align_mem __attribute__((aligned(16)))
#define ARMA_HAVE_ALIGNED_ATTRIBUTE
#elif defined(_MSC_VER)
// #if (_MANAGED == 1) || (_M_CEE == 1)
//
// // don't do any alignment when compiling in "managed code" mode
//
// #undef arma_aligned
// #define arma_aligned
//
// #undef arma_align_mem
// #define arma_align_mem
//
// #elif (_MSC_VER >= 1700)
//
// #undef arma_align_mem
// #define arma_align_mem __declspec(align(16))
//
// #define ARMA_HAVE_ALIGNED_ATTRIBUTE
//
// #endif
#endif #if defined(__GNUG__)
#elif defined(__GNUG__) #define ARMA_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNU C_PATCHLEVEL__)
#if (__GNUC__ < 4) #if (ARMA_GCC_VERSION < 40200)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#define ARMA_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNU #if ( (ARMA_GCC_VERSION >= 40700) && (ARMA_GCC_VERSION <= 40701) )
C_PATCHLEVEL__) #error "gcc versions 4.7.0 and 4.7.1 are unsupported; use 4.7.2 or late
r"
// due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549
#endif
#define ARMA_GOOD_COMPILER #define ARMA_GOOD_COMPILER
#undef ARMA_HAVE_STD_TR1 #undef ARMA_HAVE_TR1
#undef arma_pure #undef arma_pure
#undef arma_const #undef arma_const
#undef arma_aligned #undef arma_aligned
#undef arma_align_mem #undef arma_align_mem
#undef arma_warn_unused #undef arma_warn_unused
#undef arma_deprecated #undef arma_deprecated
#undef arma_malloc #undef arma_malloc
#undef arma_inline #undef arma_inline
#undef arma_noinline #undef arma_noinline
skipping to change at line 170 skipping to change at line 147
#define arma_aligned __attribute__((__aligned__)) #define arma_aligned __attribute__((__aligned__))
#define arma_align_mem __attribute__((__aligned__(16))) #define arma_align_mem __attribute__((__aligned__(16)))
#define arma_warn_unused __attribute__((__warn_unused_result__)) #define arma_warn_unused __attribute__((__warn_unused_result__))
#define arma_deprecated __attribute__((__deprecated__)) #define arma_deprecated __attribute__((__deprecated__))
#define arma_malloc __attribute__((__malloc__)) #define arma_malloc __attribute__((__malloc__))
#define arma_inline inline __attribute__((__always_inline__)) #define arma_inline inline __attribute__((__always_inline__))
#define arma_noinline __attribute__((__noinline__)) #define arma_noinline __attribute__((__noinline__))
#define ARMA_HAVE_ALIGNED_ATTRIBUTE #define ARMA_HAVE_ALIGNED_ATTRIBUTE
#if (ARMA_GCC_VERSION >= 40300)
#undef arma_hot
#undef arma_cold
#define arma_hot __attribute__((__hot__))
#define arma_cold __attribute__((__cold__))
#endif
#if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__GXX_EXPERIMENTAL_CXX0X__)
#if !defined(ARMA_USE_CXX11) #if !defined(ARMA_USE_CXX11)
#define ARMA_USE_CXX11 #define ARMA_USE_CXX11
#endif #endif
#endif #endif
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
#if (ARMA_GCC_VERSION < 40700) && !defined(__clang__) #if (ARMA_GCC_VERSION < 40700) && !defined(__clang__)
#pragma message ("Your C++ compiler is in C++11 mode, but it has inco mplete support for C++11 features") #pragma message ("Your C++ compiler is in C++11 mode, but it has inco mplete support for C++11 features")
#endif #endif
#endif #endif
#if (ARMA_GCC_VERSION >= 40200) #if !defined(ARMA_USE_CXX11)
#if !defined(ARMA_USE_CXX11) #if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_COMP
#if defined(_GLIBCXX_USE_C99_MATH_TR1) && defined(_GLIBCXX_USE_C99_CO LEX_TR1)
MPLEX_TR1) #define ARMA_HAVE_TR1
#define ARMA_HAVE_TR1
#endif
#endif #endif
#endif #endif
#if defined(__clang__) #if (ARMA_GCC_VERSION >= 40300)
#undef ARMA_HAVE_STD_TR1 #undef arma_hot
//#undef ARMA_GOOD_COMPILER #undef arma_cold
#endif
#if ( (ARMA_GCC_VERSION >= 40700) && (ARMA_GCC_VERSION <= 40701) ) #define arma_hot __attribute__((__hot__))
#error "gcc versions 4.7.0 and 4.7.1 are unsupported; use 4.7.2 or late #define arma_cold __attribute__((__cold__))
r"
// due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53549
#endif #endif
#if (ARMA_GCC_VERSION >= 40700) #if (ARMA_GCC_VERSION >= 40700)
#define ARMA_HAVE_GCC_ASSUME_ALIGNED #define ARMA_HAVE_GCC_ASSUME_ALIGNED
#endif
#if defined(__clang__)
#undef ARMA_HAVE_TR1
#undef ARMA_HAVE_GCC_ASSUME_ALIGNED
// TODO: future versions of clang may also have __builtin_assume_aligne d // TODO: future versions of clang may also have __builtin_assume_aligne d
#endif #endif
#if defined(__INTEL_COMPILER)
#undef ARMA_HAVE_TR1
#undef ARMA_HAVE_GCC_ASSUME_ALIGNED
#endif
#undef ARMA_GCC_VERSION #undef ARMA_GCC_VERSION
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if (_MSC_VER < 1500) #if (_MSC_VER < 1700)
#error "*** Need a newer compiler ***" #error "*** Need a newer compiler ***"
#endif #endif
#undef ARMA_GOOD_COMPILER #undef ARMA_GOOD_COMPILER
#undef ARMA_HAVE_STD_ISFINITE #undef ARMA_HAVE_SNPRINTF
#undef ARMA_HAVE_STD_SNPRINTF #undef ARMA_HAVE_ISFINITE
#undef ARMA_HAVE_LOG1P #undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_TR1
#undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1
// #undef arma_inline // #undef arma_inline
// #define arma_inline inline __forceinline // #define arma_inline inline __forceinline
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant #pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 4510) // default constructor could not be gener ated #pragma warning(disable: 4510) // default constructor could not be gener ated
#pragma warning(disable: 4511) // copy constructor can't be generated #pragma warning(disable: 4511) // copy constructor can't be generated
#pragma warning(disable: 4512) // assignment operator can't be generated #pragma warning(disable: 4512) // assignment operator can't be generated
skipping to change at line 275 skipping to change at line 248
// //
// #define ARMA_HAVE_ALIGNED_ATTRIBUTE // #define ARMA_HAVE_ALIGNED_ATTRIBUTE
// //
// // disable warnings: "structure was padded due to __declspec(align(1 6))" // // disable warnings: "structure was padded due to __declspec(align(1 6))"
// #pragma warning(disable: 4324) // #pragma warning(disable: 4324)
// //
// #endif // #endif
#endif #endif
#if defined(__CUDACC__) #if defined(__SUNPRO_CC)
#undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_SNPRINTF // http://www.oracle.com/technetwork/server-storage/solarisstudio/trainin
g/index-jsp-141991.html
// http://www.oracle.com/technetwork/server-storage/solarisstudio/documen
tation/cplusplus-faq-355066.html
#if (__SUNPRO_CC < 0x5100)
#error "*** Need a newer compiler ***"
#endif
#undef ARMA_HAVE_SNPRINTF
#undef ARMA_HAVE_ISFINITE
#undef ARMA_HAVE_LOG1P #undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_TR1
#undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1
#endif #endif
#if defined(__SUNPRO_CC) #if defined(__CUDACC__)
#undef ARMA_HAVE_STD_ISFINITE
#undef ARMA_HAVE_STD_SNPRINTF #undef ARMA_HAVE_SNPRINTF
#undef ARMA_HAVE_ISFINITE
#undef ARMA_HAVE_LOG1P #undef ARMA_HAVE_LOG1P
#undef ARMA_HAVE_STD_ISINF #undef ARMA_HAVE_TR1
#undef ARMA_HAVE_STD_ISNAN
#undef ARMA_HAVE_STD_TR1 #endif
#if defined(log2)
#undef log2
#pragma message ("detected 'log2' macro and undefined it")
#endif
//
// whoever defined macros with the names "min" and "max" should be permanen
tly removed from the gene pool
#if defined(min) || defined(max)
#undef min
#undef max
#pragma message ("detected 'min' and/or 'max' macros and undefined them;
you may wish to define NOMINMAX before including any windows header")
#endif #endif
 End of changes. 24 change blocks. 
104 lines changed or deleted 101 lines changed or added


 config.hpp   config.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2014 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2013 Ryan Curtin
// Copyright (C) 2008-2014 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#if !defined(ARMA_USE_LAPACK) #if !defined(ARMA_USE_LAPACK)
#define ARMA_USE_LAPACK #define ARMA_USE_LAPACK
//// Uncomment the above line if you have LAPACK or a high-speed replacemen t for LAPACK, //// Uncomment the above line if you have LAPACK or a high-speed replacemen t for LAPACK,
//// such as Intel MKL, AMD ACML, or the Accelerate framework. //// such as Intel MKL, AMD ACML, or the Accelerate framework.
//// LAPACK is required for matrix decompositions (eg. SVD) and matrix inve rse. //// LAPACK is required for matrix decompositions (eg. SVD) and matrix inve rse.
#endif #endif
#if !defined(ARMA_USE_BLAS) #if !defined(ARMA_USE_BLAS)
#define ARMA_USE_BLAS #define ARMA_USE_BLAS
//// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS, //// Uncomment the above line if you have BLAS or a high-speed replacement for BLAS,
//// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate fra mework. //// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate fra mework.
//// BLAS is used for matrix multiplication. //// BLAS is used for matrix multiplication.
//// Without BLAS, matrix multiplication will still work, but might be slow er. //// Without BLAS, matrix multiplication will still work, but might be slow er.
#endif #endif
#if !defined(ARMA_USE_ARPACK)
/* #undef ARMA_USE_ARPACK */
//// Uncomment the above line if you have ARPACK or a high-speed replacemen
t for ARPACK.
//// ARPACK is required for eigendecompositions of sparse matrices, eg. eig
s_sym()
#endif
#define ARMA_USE_WRAPPER #define ARMA_USE_WRAPPER
//// Comment out the above line if you're getting linking errors when compi ling your programs, //// Comment out the above line if you're getting linking errors when compi ling your programs,
//// or if you prefer to directly link with LAPACK and/or BLAS. //// or if you prefer to directly link with LAPACK, BLAS or ARPACK.
//// You will then need to link your programs directly with -llapack -lblas instead of -larmadillo //// You will then need to link your programs directly with -llapack -lblas instead of -larmadillo
// #define ARMA_BLAS_CAPITALS // #define ARMA_BLAS_CAPITALS
//// Uncomment the above line if your BLAS and LAPACK libraries have capita lised function names (eg. ACML on 64-bit Windows) //// Uncomment the above line if your BLAS and LAPACK libraries have capita lised function names (eg. ACML on 64-bit Windows)
#define ARMA_BLAS_UNDERSCORE #define ARMA_BLAS_UNDERSCORE
//// Uncomment the above line if your BLAS and LAPACK libraries have functi on names with a trailing underscore. //// Uncomment the above line if your BLAS and LAPACK libraries have functi on names with a trailing underscore.
//// Conversely, comment it out if the function names don't have a trailing underscore. //// Conversely, comment it out if the function names don't have a trailing underscore.
// #define ARMA_BLAS_LONG // #define ARMA_BLAS_LONG
skipping to change at line 104 skipping to change at line 111
//// Uncomment the above line if you want to disable all run-time checks. //// Uncomment the above line if you want to disable all run-time checks.
//// This will result in faster code, but you first need to make sure that your code runs correctly! //// This will result in faster code, but you first need to make sure that your code runs correctly!
//// We strongly recommend to have the run-time checks enabled during devel opment, //// We strongly recommend to have the run-time checks enabled during devel opment,
//// as this greatly aids in finding mistakes in your code, and hence speed s up development. //// as this greatly aids in finding mistakes in your code, and hence speed s up development.
//// We recommend that run-time checks be disabled _only_ for the shipped v ersion of your program. //// We recommend that run-time checks be disabled _only_ for the shipped v ersion of your program.
// #define ARMA_EXTRA_DEBUG // #define ARMA_EXTRA_DEBUG
//// Uncomment the above line if you want to see the function traces of how Armadillo evaluates expressions. //// Uncomment the above line if you want to see the function traces of how Armadillo evaluates expressions.
//// This is mainly useful for debugging of the library. //// This is mainly useful for debugging of the library.
// #define ARMA_USE_BOOST
// #define ARMA_USE_BOOST_DATE
#if !defined(ARMA_DEFAULT_OSTREAM) #if !defined(ARMA_DEFAULT_OSTREAM)
#define ARMA_DEFAULT_OSTREAM std::cout #define ARMA_DEFAULT_OSTREAM std::cout
#endif #endif
#define ARMA_PRINT_LOGIC_ERRORS #define ARMA_PRINT_ERRORS
#define ARMA_PRINT_RUNTIME_ERRORS
//#define ARMA_PRINT_HDF5_ERRORS //#define ARMA_PRINT_HDF5_ERRORS
#define ARMA_HAVE_STD_ISFINITE #if defined(ARMA_DONT_PRINT_ERRORS)
#define ARMA_HAVE_STD_ISINF #undef ARMA_PRINT_ERRORS
#define ARMA_HAVE_STD_ISNAN #undef ARMA_PRINT_HDF5_ERRORS
#define ARMA_HAVE_STD_SNPRINTF #endif
#define ARMA_HAVE_LOG1P
#define ARMA_HAVE_GETTIMEOFDAY
#if defined(ARMA_DONT_USE_LAPACK) #if defined(ARMA_DONT_USE_LAPACK)
#undef ARMA_USE_LAPACK #undef ARMA_USE_LAPACK
#endif #endif
#if defined(ARMA_DONT_USE_BLAS) #if defined(ARMA_DONT_USE_BLAS)
#undef ARMA_USE_BLAS #undef ARMA_USE_BLAS
#endif #endif
#if defined(ARMA_DONT_USE_WRAPPER) #if defined(ARMA_DONT_USE_ARPACK)
#undef ARMA_USE_WRAPPER #undef ARMA_USE_ARPACK
#endif #endif
#if defined(ARMA_DONT_USE_ATLAS) #if defined(ARMA_DONT_USE_ATLAS)
#undef ARMA_USE_ATLAS #undef ARMA_USE_ATLAS
#undef ARMA_ATLAS_INCLUDE_DIR #undef ARMA_ATLAS_INCLUDE_DIR
#endif #endif
#if defined(ARMA_DONT_USE_WRAPPER)
#undef ARMA_USE_WRAPPER
#endif
#if defined(ARMA_DONT_USE_CXX11) #if defined(ARMA_DONT_USE_CXX11)
#undef ARMA_USE_CXX11 #undef ARMA_USE_CXX11
#undef ARMA_USE_CXX11_RNG #undef ARMA_USE_CXX11_RNG
#endif #endif
#if defined(ARMA_DONT_USE_HDF5) #if defined(ARMA_USE_WRAPPER)
#undef ARMA_USE_HDF5 #if defined(ARMA_USE_CXX11)
#endif #if !defined(ARMA_USE_CXX11_RNG)
/* #undef ARMA_USE_CXX11_RNG */
#if defined(ARMA_DONT_USE_BOOST) #endif
#undef ARMA_USE_BOOST #endif
#undef ARMA_USE_BOOST_DATE
#undef ARMA_USE_BOOST_FORMAT
#endif #endif
#if defined(ARMA_DONT_PRINT_LOGIC_ERRORS) #if defined(ARMA_DONT_USE_HDF5)
#undef ARMA_PRINT_LOGIC_ERRORS #undef ARMA_USE_HDF5
#endif
#if defined(ARMA_DONT_PRINT_RUNTIME_ERRORS)
#undef ARMA_PRINT_RUNTIME_ERRORS
#endif #endif
 End of changes. 10 change blocks. 
31 lines changed or deleted 31 lines changed or added


 debug.hpp   debug.hpp 
skipping to change at line 81 skipping to change at line 81
// arma_stop // arma_stop
//! print a message to get_stream_err1() and/or throw a logic_error excepti on //! print a message to get_stream_err1() and/or throw a logic_error excepti on
template<typename T1> template<typename T1>
arma_cold arma_cold
arma_noinline arma_noinline
static static
void void
arma_stop(const T1& x) arma_stop(const T1& x)
{ {
#if defined(ARMA_PRINT_LOGIC_ERRORS) #if defined(ARMA_PRINT_ERRORS)
{ {
std::ostream& out = get_stream_err1(); std::ostream& out = get_stream_err1();
out.flush(); out.flush();
out << '\n'; out << '\n';
out << "error: " << x << '\n'; out << "error: " << x << '\n';
out << '\n'; out << '\n';
out.flush(); out.flush();
} }
skipping to change at line 108 skipping to change at line 108
throw std::logic_error( std::string(x) ); throw std::logic_error( std::string(x) );
} }
template<typename T1> template<typename T1>
arma_cold arma_cold
arma_noinline arma_noinline
static static
void void
arma_stop_bad_alloc(const T1& x) arma_stop_bad_alloc(const T1& x)
{ {
std::ostream& out = get_stream_err1(); #if defined(ARMA_PRINT_ERRORS)
{
std::ostream& out = get_stream_err2();
out.flush(); out.flush();
out << '\n'; out << '\n';
out << "error: " << x << '\n'; out << "error: " << x << '\n';
out << '\n'; out << '\n';
out.flush(); out.flush();
}
#else
{
arma_ignore(x);
}
#endif
throw std::bad_alloc(); throw std::bad_alloc();
} }
// //
// arma_bad // arma_bad
//! print a message to get_stream_err2() and/or throw a run-time error exce ption //! print a message to get_stream_err2() and/or throw a run-time error exce ption
template<typename T1> template<typename T1>
arma_cold arma_cold
arma_noinline arma_noinline
static static
void void
arma_bad(const T1& x, const bool hurl = true) arma_bad(const T1& x, const bool hurl = true)
{ {
#if defined(ARMA_PRINT_RUNTIME_ERRORS) #if defined(ARMA_PRINT_ERRORS)
{ {
std::ostream& out = get_stream_err2(); std::ostream& out = get_stream_err2();
out.flush(); out.flush();
out << '\n'; out << '\n';
out << "error: " << x << '\n'; out << "error: " << x << '\n';
out << '\n'; out << '\n';
out.flush(); out.flush();
} }
skipping to change at line 1041 skipping to change at line 1049
out << "@ ---" << '\n'; out << "@ ---" << '\n';
out << "@ Armadillo " out << "@ Armadillo "
<< arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch << arma_version::major << '.' << arma_version::minor << '.' << arma_version::patch
<< " (" << nickname << ")\n"; << " (" << nickname << ")\n";
out << "@ arma_config::use_wrapper = " << arma_config::use_wrapper << '\n'; out << "@ arma_config::use_wrapper = " << arma_config::use_wrapper << '\n';
out << "@ arma_config::use_cxx11 = " << arma_config::use_cxx11 << '\n'; out << "@ arma_config::use_cxx11 = " << arma_config::use_cxx11 << '\n';
out << "@ arma_config::lapack = " << arma_config::lapack << '\n'; out << "@ arma_config::lapack = " << arma_config::lapack << '\n';
out << "@ arma_config::blas = " << arma_config::blas << '\n'; out << "@ arma_config::blas = " << arma_config::blas << '\n';
out << "@ arma_config::arpack = " << arma_config::arpack << '\n';
out << "@ arma_config::atlas = " << arma_config::atlas << '\n'; out << "@ arma_config::atlas = " << arma_config::atlas << '\n';
out << "@ arma_config::hdf5 = " << arma_config::hdf5 << '\n'; out << "@ arma_config::hdf5 = " << arma_config::hdf5 << '\n';
out << "@ arma_config::boost = " << arma_config::boost
<< '\n';
out << "@ arma_config::boost_date = " << arma_config::boost_date
<< '\n';
out << "@ arma_config::good_comp = " << arma_config::good_comp << '\n'; out << "@ arma_config::good_comp = " << arma_config::good_comp << '\n';
out << "@ arma_config::extra_code = " << arma_config::extra_code << '\n'; out << "@ arma_config::extra_code = " << arma_config::extra_code << '\n';
out << "@ arma_config::mat_prealloc = " << arma_config::mat_preallo c << '\n'; out << "@ arma_config::mat_prealloc = " << arma_config::mat_preallo c << '\n';
out << "@ sizeof(void*) = " << sizeof(void*) << '\n'; out << "@ sizeof(void*) = " << sizeof(void*) << '\n';
out << "@ sizeof(uword) = " << sizeof(uword) << '\n'; out << "@ sizeof(uword) = " << sizeof(uword) << '\n';
out << "@ sizeof(int) = " << sizeof(int) << '\n'; out << "@ sizeof(int) = " << sizeof(int) << '\n';
out << "@ sizeof(long) = " << sizeof(long) << '\n'; out << "@ sizeof(long) = " << sizeof(long) << '\n';
out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n'; out << "@ sizeof(blas_int) = " << sizeof(blas_int) << '\n';
out << "@ little_endian = " << little_endian << '\n'; out << "@ little_endian = " << little_endian << '\n';
out << "@ ---" << std::endl; out << "@ ---" << std::endl;
 End of changes. 7 change blocks. 
12 lines changed or deleted 17 lines changed or added


 fn_det.hpp   fn_det.hpp 
skipping to change at line 187 skipping to change at line 187
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const eT tmp = det(X.m, slow); const eT tmp = det(X.m, slow);
arma_warn( (tmp == eT(0)), "det(): warning: denominator is zero" ); arma_debug_warn( (tmp == eT(0)), "det(): warning: denominator is zero" );
return eT(1) / tmp; return eT(1) / tmp;
} }
template<typename T1> template<typename T1>
inline inline
arma_warn_unused arma_warn_unused
typename T1::elem_type typename T1::elem_type
det det
( (
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_elem.hpp   fn_elem.hpp 
skipping to change at line 12 skipping to change at line 12
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_elem //! \addtogroup fn_elem
//! @{ //! @{
// //
// find
template<typename eT, typename T1>
inline
const mtOp<uword, T1, op_find>
find(const Base<eT,T1>& X, const uword k = 0, const char* direction = "firs
t")
{
arma_extra_debug_sigprint();
const char sig = direction[0];
arma_debug_check
(
(sig != 'f' && sig != 'F' && sig != 'l' && sig != 'L'),
"find(): 3rd input argument must be \"first\" or \"last\""
);
const uword type = (sig == 'f' || sig == 'F') ? 0 : 1;
return mtOp<uword, T1, op_find>(X.get_ref(), k, type);
}
//
// real // real
template<typename T1> template<typename T1>
arma_inline arma_inline
const T1& const T1&
real(const Base<typename T1::pod_type, T1>& X) real(const Base<typename T1::pod_type, T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return X.get_ref(); return X.get_ref();
 End of changes. 1 change blocks. 
24 lines changed or deleted 0 lines changed or added


 fn_inplace_strans.hpp   fn_inplace_strans.hpp 
skipping to change at line 18 skipping to change at line 18
//! \addtogroup fn_inplace_strans //! \addtogroup fn_inplace_strans
//! @{ //! @{
template<typename eT> template<typename eT>
inline inline
void void
inplace_strans inplace_strans
( (
Mat<eT>& X, Mat<eT>& X,
const char* method = "standard" const char* method = "std"
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_strans(): unkn own method specified" ); arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_strans(): unkn own method specified" );
const bool low_memory = (sig == 'l'); const bool low_memory = (sig == 'l');
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 fn_inplace_trans.hpp   fn_inplace_trans.hpp 
skipping to change at line 22 skipping to change at line 22
inline inline
typename typename
enable_if2 enable_if2
< <
is_cx<eT>::no, is_cx<eT>::no,
void void
>::result >::result
inplace_htrans inplace_htrans
( (
Mat<eT>& X, Mat<eT>& X,
const char* method = "standard" const char* method = "std"
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
inplace_strans(X, method); inplace_strans(X, method);
} }
template<typename eT> template<typename eT>
inline inline
typename typename
enable_if2 enable_if2
< <
is_cx<eT>::yes, is_cx<eT>::yes,
void void
>::result >::result
inplace_htrans inplace_htrans
( (
Mat<eT>& X, Mat<eT>& X,
const char* method = "standard" const char* method = "std"
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_htrans(): unkn own method specified" ); arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_htrans(): unkn own method specified" );
const bool low_memory = (sig == 'l'); const bool low_memory = (sig == 'l');
skipping to change at line 75 skipping to change at line 75
inline inline
typename typename
enable_if2 enable_if2
< <
is_cx<eT>::no, is_cx<eT>::no,
void void
>::result >::result
inplace_trans inplace_trans
( (
Mat<eT>& X, Mat<eT>& X,
const char* method = "standard" const char* method = "std"
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_trans(): unkno wn method specified" ); arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_trans(): unkno wn method specified" );
inplace_strans(X, method); inplace_strans(X, method);
} }
skipping to change at line 98 skipping to change at line 98
inline inline
typename typename
enable_if2 enable_if2
< <
is_cx<eT>::yes, is_cx<eT>::yes,
void void
>::result >::result
inplace_trans inplace_trans
( (
Mat<eT>& X, Mat<eT>& X,
const char* method = "standard" const char* method = "std"
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_trans(): unkno wn method specified" ); arma_debug_check( ((sig != 's') && (sig != 'l')), "inplace_trans(): unkno wn method specified" );
inplace_htrans(X, method); inplace_htrans(X, method);
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 fn_inv.hpp   fn_inv.hpp 
skipping to change at line 86 skipping to change at line 86
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method specified" ); arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method specified" );
return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0); return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
} }
//! delayed matrix inverse (symmetric positive definite matrices)
template<typename T1> template<typename T1>
arma_inline inline
const Op<T1, op_inv_sympd> bool
inv inv
( (
const Op<T1, op_sympd>& X, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X,
const bool slow = false, const bool slow = false,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(slow);
arma_ignore(junk); arma_ignore(junk);
return Op<T1, op_inv_sympd>(X.m, 0, 0); try
} {
out = inv(X,slow);
template<typename T1> }
arma_inline catch(std::runtime_error&)
const Op<T1, op_inv_sympd> {
inv return false;
( }
const Op<T1, op_sympd>& X,
const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "inv(): unknown method
specified" );
return Op<T1, op_inv_sympd>(X.m, 0, 0); return true;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
inv inv
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const bool slow = false, const char* method,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
try try
{ {
out = inv(X,slow); out = inv(X,method);
} }
catch(std::runtime_error&) catch(std::runtime_error&)
{ {
return false; return false;
} }
return true; return true;
} }
//! inverse of symmetric positive definite matrices
template<typename T1>
arma_inline
const Op<T1, op_inv_sympd>
inv_sympd
(
const Base<typename T1::elem_type, T1>& X,
const char* method = "std",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'f')), "inv_sympd(): unknown m
ethod specified" );
return Op<T1, op_inv_sympd>(X.get_ref(), 0, 0);
}
template<typename T1> template<typename T1>
inline inline
bool bool
inv inv_sympd
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char* method, const char* method = "std",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
try try
{ {
out = inv(X,method); out = inv_sympd(X,method);
} }
catch(std::runtime_error&) catch(std::runtime_error&)
{ {
return false; return false;
} }
return true; return true;
} }
//! @} //! @}
 End of changes. 12 change blocks. 
32 lines changed or deleted 41 lines changed or added


 fn_misc.hpp   fn_misc.hpp 
skipping to change at line 169 skipping to change at line 169
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
const Cube<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
return A.is_finite(); return A.is_finite();
} }
//! DO NOT USE IN NEW CODE; change instances of inv(sympd(X)) to inv_sympd( X)
template<typename T1> template<typename T1>
arma_inline
arma_deprecated arma_deprecated
Op<T1, op_sympd> inline
const T1&
sympd(const Base<typename T1::elem_type,T1>& X) sympd(const Base<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
return Op<T1, op_sympd>(X.get_ref()); return X.get_ref();
} }
template<typename eT> template<typename eT>
inline inline
void void
swap(Mat<eT>& A, Mat<eT>& B) swap(Mat<eT>& A, Mat<eT>& B)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
A.swap(B); A.swap(B);
 End of changes. 4 change blocks. 
3 lines changed or deleted 4 lines changed or added


 fn_pinv.hpp   fn_pinv.hpp 
skipping to change at line 19 skipping to change at line 19
//! \addtogroup fn_pinv //! \addtogroup fn_pinv
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
const Op<T1, op_pinv> const Op<T1, op_pinv>
pinv pinv
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename T1::elem_type tol = 0.0, const typename T1::elem_type tol = 0.0,
const char* method = "standard", const char* method = "dc",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
const char sig = method[0]; const char sig = method[0];
arma_debug_check( ((sig != 's') && (sig != 'd')), "pinv(): unknown method specified" ); arma_debug_check( ((sig != 's') && (sig != 'd')), "pinv(): unknown method specified" );
skipping to change at line 41 skipping to change at line 41
} }
template<typename T1> template<typename T1>
inline inline
bool bool
pinv pinv
( (
Mat<typename T1::elem_type>& out, Mat<typename T1::elem_type>& out,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename T1::elem_type tol = 0.0, const typename T1::elem_type tol = 0.0,
const char* method = "standard", const char* method = "dc",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
try try
{ {
out = pinv(X, tol, method); out = pinv(X, tol, method);
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fn_rank.hpp   fn_rank.hpp 
// Copyright (C) 2009-2011 Conrad Sanderson // Copyright (C) 2009-2013 Conrad Sanderson
// Copyright (C) 2009-2011 NICTA (www.nicta.com.au) // Copyright (C) 2009-2013 NICTA (www.nicta.com.au)
// Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2009-2010 Dimitrios Bouzas
// Copyright (C) 2011 Stanislav Funiak // Copyright (C) 2011 Stanislav Funiak
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_rank //! \addtogroup fn_rank
//! @{ //! @{
skipping to change at line 33 skipping to change at line 33
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
uword X_n_rows; uword X_n_rows;
uword X_n_cols; uword X_n_cols;
Col<T> s; Col<T> s;
const bool status = auxlib::svd(s, X, X_n_rows, X_n_cols); const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols);
const uword n_elem = s.n_elem; const uword n_elem = s.n_elem;
if(status == true) if(status == true)
{ {
if( (tol == T(0)) && (n_elem > 0) ) if( (tol == T(0)) && (n_elem > 0) )
{ {
tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s)); tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s));
} }
// count non zero valued elements in s // count non zero valued elements in s
const T* s_mem = s.memptr(); const T* s_mem = s.memptr();
uword count = 0;
uword count = 0;
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
if(s_mem[i] > tol) if(s_mem[i] > tol) { ++count; }
{
++count;
}
} }
return count; return count;
} }
else else
{ {
arma_bad("rank(): failed to converge"); arma_bad("rank(): failed to converge");
return uword(0); return uword(0);
} }
 End of changes. 4 change blocks. 
9 lines changed or deleted 7 lines changed or added


 fn_sort.hpp   fn_sort.hpp 
// Copyright (C) 2008-2013 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2013 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_sort //! \addtogroup fn_sort
//! @{ //! @{
//! kept for compatibility with old code
template<typename T1> template<typename T1>
arma_inline arma_inline
typename typename
enable_if2 enable_if2
< <
( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == false) ), ( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == false) ),
const Op<T1, op_sort> const Op<T1, op_sort>
>::result >::result
sort sort
( (
skipping to change at line 57 skipping to change at line 58
const char sig = sort_direction[0]; const char sig = sort_direction[0];
arma_debug_check( (sig != 'a') && (sig != 'd'), "sort(): unknown sort dir ection"); arma_debug_check( (sig != 'a') && (sig != 'd'), "sort(): unknown sort dir ection");
const uword sort_type = (sig == 'a') ? 0 : 1; const uword sort_type = (sig == 'a') ? 0 : 1;
return Op<T1, op_sort>(X, sort_type, dim); return Op<T1, op_sort>(X, sort_type, dim);
} }
//! kept for compatibility with old code
template<typename T1> template<typename T1>
arma_inline arma_inline
typename typename
enable_if2 enable_if2
< <
( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == true) ), ( (is_arma_type<T1>::value == true) && (resolves_to_vector<T1>::value == true) ),
const Op<T1, op_sort> const Op<T1, op_sort>
>::result >::result
sort sort
( (
 End of changes. 2 change blocks. 
0 lines changed or deleted 2 lines changed or added


 fn_sort_index.hpp   fn_sort_index.hpp 
skipping to change at line 96 skipping to change at line 96
std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator ); std::stable_sort( packet_vec.begin(), packet_vec.end(), comparator );
} }
} }
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
{ {
out_mem[i] = packet_vec[i].index; out_mem[i] = packet_vec[i].index;
} }
} }
//! kept for compatibility with old code
template<typename T1> template<typename T1>
inline inline
umat umat
sort_index sort_index
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const uword sort_type = 0, const uword sort_type = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
) )
{ {
skipping to change at line 137 skipping to change at line 138
sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 0, 0>(out.memptr(), A.mem, A.n_ele m);
} }
else else
{ {
sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele m); sort_index_helper<out_elem_type, eT, 1, 0>(out.memptr(), A.mem, A.n_ele m);
} }
return out; return out;
} }
//! kept for compatibility with old code
template<typename T1> template<typename T1>
inline inline
umat umat
stable_sort_index stable_sort_index
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const uword sort_type = 0, const uword sort_type = 0,
const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 const typename arma_not_cx<typename T1::elem_type>::result* junk = 0
) )
{ {
 End of changes. 2 change blocks. 
0 lines changed or deleted 2 lines changed or added


 fn_speye.hpp   fn_speye.hpp 
skipping to change at line 20 skipping to change at line 20
//! Generate a sparse matrix with the values along the main diagonal set to one //! Generate a sparse matrix with the values along the main diagonal set to one
template<typename obj_type> template<typename obj_type>
inline inline
obj_type obj_type
speye(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpC ol_SpRow_only<obj_type>::result* junk = NULL) speye(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpC ol_SpRow_only<obj_type>::result* junk = NULL)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
if(is_SpCol<obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "speye(): incompatible size" );
}
else
if(is_SpRow<obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "speye(): incompatible size" );
}
obj_type out; obj_type out;
out.eye(n_rows, n_cols); out.eye(n_rows, n_cols);
return out; return out;
} }
// Convenience shortcut method (no template parameter necessary) // Convenience shortcut method (no template parameter necessary)
inline inline
sp_mat sp_mat
 End of changes. 1 change blocks. 
0 lines changed or deleted 10 lines changed or added


 fn_spones.hpp   fn_spones.hpp 
// Copyright (C) 2012 Conrad Sanderson // Copyright (C) 2012-2013 Conrad Sanderson
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_spones //! \addtogroup fn_spones
//! @{ //! @{
//! Generate a sparse matrix with the non-zero values in the same locations as in the given sparse matrix X, //! Generate a sparse matrix with the non-zero values in the same locations as in the given sparse matrix X,
//! with the non-zero values set to one //! with the non-zero values set to one
skipping to change at line 23 skipping to change at line 23
inline inline
SpMat<typename T1::elem_type> SpMat<typename T1::elem_type>
spones(const SpBase<typename T1::elem_type, T1>& X) spones(const SpBase<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;
SpMat<eT> out( X.get_ref() ); SpMat<eT> out( X.get_ref() );
const uword nnz = out.n_nonzero; arrayops::inplace_set( access::rwp(out.values), eT(1), out.n_nonzero );
eT* values = access::rwp(out.values);
for(uword i=0; i < nnz; ++i)
{
values[i] = eT(1);
}
return out; return out;
} }
//! @} //! @}
 End of changes. 2 change blocks. 
9 lines changed or deleted 2 lines changed or added


 fn_svd.hpp   fn_svd.hpp 
skipping to change at line 26 skipping to change at line 26
Col<typename T1::pod_type>& S, Col<typename T1::pod_type>& S,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
// it doesn't matter if X is an alias of S, as auxlib::svd() makes a copy of X // it doesn't matter if X is an alias of S, as auxlib::svd() makes a copy of X
const bool status = auxlib::svd(S, X); const bool status = auxlib::svd_dc(S, X);
if(status == false) if(status == false)
{ {
S.reset(); S.reset();
arma_bad("svd(): failed to converge", false); arma_bad("svd(): failed to converge", false);
} }
return status; return status;
} }
skipping to change at line 51 skipping to change at line 51
( (
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
Col<typename T1::pod_type> out; Col<typename T1::pod_type> out;
const bool status = auxlib::svd(out, X); const bool status = auxlib::svd_dc(out, X);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("svd(): failed to converge"); arma_bad("svd(): failed to converge");
} }
return out; return out;
} }
template<typename T1> template<typename T1>
inline inline
bool bool
svd svd
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char* method = "standard", const char* method = "dc",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_debug_check arma_debug_check
( (
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd(): two or more output objects are the same object" "svd(): two or more output objects are the same object"
skipping to change at line 112 skipping to change at line 112
template<typename T1> template<typename T1>
inline inline
bool bool
svd_econ svd_econ
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char mode, const char mode,
const char* method = "standard", const char* method = "dc",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
arma_debug_check arma_debug_check
( (
( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ), ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*) (&V)) ),
"svd_econ(): two or more output objects are the same object" "svd_econ(): two or more output objects are the same object"
skipping to change at line 158 skipping to change at line 158
template<typename T1> template<typename T1>
inline inline
bool bool
svd_econ svd_econ
( (
Mat<typename T1::elem_type>& U, Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S, Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V, Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X, const Base<typename T1::elem_type,T1>& X,
const char* side = "both", const char* side = "both",
const char* method = "standard", const char* method = "dc",
const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
) )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return svd_econ(U,S,V,X,side[0],method); return svd_econ(U,S,V,X,side[0],method);
} }
// TODO: remove this function in version 4.0
template<typename T1>
arma_deprecated
inline
bool
svd_thin
(
Mat<typename T1::elem_type>& U,
Col<typename T1::pod_type >& S,
Mat<typename T1::elem_type>& V,
const Base<typename T1::elem_type,T1>& X,
const char mode = 'b',
const typename arma_blas_type_only<typename T1::elem_type>::result* junk
= 0
)
{
arma_ignore(junk);
return svd_econ(U,S,V,X,mode);
}
//! @} //! @}
 End of changes. 6 change blocks. 
26 lines changed or deleted 5 lines changed or added


 fn_zeros.hpp   fn_zeros.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup fn_zeros //! \addtogroup fn_zeros
//! @{ //! @{
//! Generate a vector with all elements set to zero //! Generate a vector with all elements set to zero
arma_inline arma_inline
skipping to change at line 91 skipping to change at line 91
arma_inline arma_inline
const GenCube<typename cube_type::elem_type, gen_zeros> const GenCube<typename cube_type::elem_type, gen_zeros>
zeros(const uword n_rows, const uword n_cols, const uword n_slices, const t ypename arma_Cube_only<cube_type>::result* junk = 0) zeros(const uword n_rows, const uword n_cols, const uword n_slices, const t ypename arma_Cube_only<cube_type>::result* junk = 0)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_ignore(junk); arma_ignore(junk);
return GenCube<typename cube_type::elem_type, gen_zeros>(n_rows, n_cols, n_slices); return GenCube<typename cube_type::elem_type, gen_zeros>(n_rows, n_cols, n_slices);
} }
template<typename sp_obj_type>
inline
sp_obj_type
zeros(const uword n_rows, const uword n_cols, const typename arma_SpMat_SpC
ol_SpRow_only<sp_obj_type>::result* junk = 0)
{
arma_extra_debug_sigprint();
arma_ignore(junk);
if(is_SpCol<sp_obj_type>::value == true)
{
arma_debug_check( (n_cols != 1), "zeros(): incompatible size" );
}
else
if(is_SpRow<sp_obj_type>::value == true)
{
arma_debug_check( (n_rows != 1), "zeros(): incompatible size" );
}
return sp_obj_type(n_rows, n_cols);
}
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 24 lines changed or added


 glue_times_bones.hpp   glue_times_bones.hpp 
skipping to change at line 42 skipping to change at line 42
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
}; };
template<> template<>
struct glue_times_redirect2_helper<true> struct glue_times_redirect2_helper<true>
{ {
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
}; };
template<bool is_eT_blas_type>
struct glue_times_redirect3_helper
{
template<typename T1, typename T2, typename T3>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const
Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
};
template<>
struct glue_times_redirect3_helper<true>
{
template<typename T1, typename T2, typename T3>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const
Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
};
template<uword N> template<uword N>
struct glue_times_redirect struct glue_times_redirect
{ {
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X); arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
}; };
template<> template<>
struct glue_times_redirect<2> struct glue_times_redirect<2>
{ {
 End of changes. 1 change blocks. 
0 lines changed or deleted 16 lines changed or added


 glue_times_meat.hpp   glue_times_meat.hpp 
skipping to change at line 88 skipping to change at line 88
arma_debug_check( (A.is_square() == false), "inv(): given matrix is not square" ); arma_debug_check( (A.is_square() == false), "inv(): given matrix is not square" );
const unwrap_check<T2> B_tmp(X.B, out); const unwrap_check<T2> B_tmp(X.B, out);
const Mat<eT>& B = B_tmp.M; const Mat<eT>& B = B_tmp.M;
glue_solve::solve_direct( out, A, B, A_strip.slow ); glue_solve::solve_direct( out, A, B, A_strip.slow );
} }
} }
template<bool is_eT_blas_type>
template<typename T1, typename T2, typename T3>
arma_hot
inline
void
glue_times_redirect3_helper<is_eT_blas_type>::apply(Mat<typename T1::elem_t
ype>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
// we have exactly 3 objects
// hence we can safely expand X as X.A.A, X.A.B and X.B
const partial_unwrap_check<T1> tmp1(X.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.B, out);
const partial_unwrap_check<T3> tmp3(X.B, out);
const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M;
const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M;
const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M;
const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val()) : eT(0);
glue_times::apply
<
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
partial_unwrap_check<T3>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim
es || partial_unwrap_check<T3>::do_times)
>
(out, A, B, C, alpha);
}
template<typename T1, typename T2, typename T3>
arma_hot
inline
void
glue_times_redirect3_helper<true>::apply(Mat<typename T1::elem_type>& out,
const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
{
arma_extra_debug_sigprint();
// TODO: investigate detecting inv(A)*B*C and replacing with solve(A,B)*C
typedef typename T1::elem_type eT;
if(strip_inv<T2>::do_inv == false)
{
// we have exactly 3 objects
// hence we can safely expand X as X.A.A, X.A.B and X.B
const partial_unwrap_check<T1> tmp1(X.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.B, out);
const partial_unwrap_check<T3> tmp3(X.B, out);
const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M;
const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M;
const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M;
const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_un
wrap_check<T2>::do_times || partial_unwrap_check<T3>::do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * t
mp3.get_val()) : eT(0);
glue_times::apply
<
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
partial_unwrap_check<T3>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_t
imes || partial_unwrap_check<T3>::do_times)
>
(out, A, B, C, alpha);
}
else
{
// replace A*inv(B)*C with A*solve(B,C)
arma_extra_debug_print("glue_times_redirect<3>::apply(): detected A*inv
(B)*C");
const strip_inv<T2> B_strip(X.A.B);
Mat<eT> B = B_strip.M;
arma_debug_check( (B.is_square() == false), "inv(): given matrix is not
square" );
const unwrap<T3> C_tmp(X.B);
const Mat<eT>& C = C_tmp.M;
Mat<eT> solve_result;
glue_solve::solve_direct( solve_result, B, C, B_strip.slow );
const partial_unwrap_check<T1> tmp1(X.A.A, out);
const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M;
const bool use_alpha = partial_unwrap_check<T1>::do_times;
const eT alpha = use_alpha ? tmp1.get_val() : eT(0);
glue_times::apply
<
eT,
partial_unwrap_check<T1>::do_trans,
false,
partial_unwrap_check<T1>::do_times
>
(out, A, solve_result, alpha);
}
}
template<uword N> template<uword N>
template<typename T1, typename T2> template<typename T1, typename T2>
arma_hot arma_hot
inline inline
void void
glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& X) glue_times_redirect<N>::apply(Mat<typename T1::elem_type>& out, const Glue< T1,T2,glue_times>& 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 141 skipping to change at line 252
template<typename T1, typename T2, typename T3> template<typename T1, typename T2, typename T3>
arma_hot arma_hot
inline inline
void void
glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X) glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>, T3, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
// TODO: investigate detecting inv(A)*B*C and replacing with solve(A,B)*C glue_times_redirect3_helper< is_supported_blas_type<eT>::value >::apply(o
// TODO: investigate detecting A*inv(B)*C and replacing with A*solve(B,C) ut, X);
// there is exactly 3 objects
// hence we can safely expand X as X.A.A, X.A.B and X.B
const partial_unwrap_check<T1> tmp1(X.A.A, out);
const partial_unwrap_check<T2> tmp2(X.A.B, out);
const partial_unwrap_check<T3> tmp3(X.B, out);
const typename partial_unwrap_check<T1>::stored_type& A = tmp1.M;
const typename partial_unwrap_check<T2>::stored_type& B = tmp2.M;
const typename partial_unwrap_check<T3>::stored_type& C = tmp3.M;
const bool use_alpha = partial_unwrap_check<T1>::do_times || partial_unwr
ap_check<T2>::do_times || partial_unwrap_check<T3>::do_times;
const eT alpha = use_alpha ? (tmp1.get_val() * tmp2.get_val() * tmp
3.get_val()) : eT(0);
glue_times::apply
<
eT,
partial_unwrap_check<T1>::do_trans,
partial_unwrap_check<T2>::do_trans,
partial_unwrap_check<T3>::do_trans,
(partial_unwrap_check<T1>::do_times || partial_unwrap_check<T2>::do_tim
es || partial_unwrap_check<T3>::do_times)
>
(out, A, B, C, alpha);
} }
template<typename T1, typename T2, typename T3, typename T4> template<typename T1, typename T2, typename T3, typename T4>
arma_hot arma_hot
inline inline
void void
glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
 End of changes. 2 change blocks. 
29 lines changed or deleted 123 lines changed or added


 lapack_bones.hpp   lapack_bones.hpp 
skipping to change at line 48 skipping to change at line 48
#define arma_cheevd cheevd #define arma_cheevd cheevd
#define arma_zheevd zheevd #define arma_zheevd zheevd
#define arma_sgeev sgeev #define arma_sgeev sgeev
#define arma_dgeev dgeev #define arma_dgeev dgeev
#define arma_cgeev cgeev #define arma_cgeev cgeev
#define arma_zgeev zgeev #define arma_zgeev zgeev
#define arma_sggev sggev
#define arma_dggev dggev
#define arma_cggev cggev
#define arma_zggev zggev
#define arma_spotrf spotrf #define arma_spotrf spotrf
#define arma_dpotrf dpotrf #define arma_dpotrf dpotrf
#define arma_cpotrf cpotrf #define arma_cpotrf cpotrf
#define arma_zpotrf zpotrf #define arma_zpotrf zpotrf
#define arma_spotri spotri #define arma_spotri spotri
#define arma_dpotri dpotri #define arma_dpotri dpotri
#define arma_cpotri cpotri #define arma_cpotri cpotri
#define arma_zpotri zpotri #define arma_zpotri zpotri
skipping to change at line 150 skipping to change at line 156
#define arma_cheevd CHEEVD #define arma_cheevd CHEEVD
#define arma_zheevd ZHEEVD #define arma_zheevd ZHEEVD
#define arma_sgeev SGEEV #define arma_sgeev SGEEV
#define arma_dgeev DGEEV #define arma_dgeev DGEEV
#define arma_cgeev CGEEV #define arma_cgeev CGEEV
#define arma_zgeev ZGEEV #define arma_zgeev ZGEEV
#define arma_sggev SGGEV
#define arma_dggev DGGEV
#define arma_cggev CGGEV
#define arma_zggev ZGGEV
#define arma_spotrf SPOTRF #define arma_spotrf SPOTRF
#define arma_dpotrf DPOTRF #define arma_dpotrf DPOTRF
#define arma_cpotrf CPOTRF #define arma_cpotrf CPOTRF
#define arma_zpotrf ZPOTRF #define arma_zpotrf ZPOTRF
#define arma_spotri SPOTRI #define arma_spotri SPOTRI
#define arma_dpotri DPOTRI #define arma_dpotri DPOTRI
#define arma_cpotri CPOTRI #define arma_cpotri CPOTRI
#define arma_zpotri ZPOTRI #define arma_zpotri ZPOTRI
skipping to change at line 263 skipping to change at line 275
void arma_fortran(arma_zheevd)(char* jobz, char* uplo, blas_int* n, voi d* a, blas_int* lda, double* w, void* work, blas_int* lwork, double* rwor k, blas_int* lrwork, blas_int* iwork, blas_int* liwork, blas_int* info); void arma_fortran(arma_zheevd)(char* jobz, char* uplo, blas_int* n, voi d* a, blas_int* lda, double* w, void* work, blas_int* lwork, double* rwor k, blas_int* lrwork, blas_int* iwork, blas_int* liwork, blas_int* info);
// eigenvector decomposition of general real matrices // eigenvector decomposition of general real matrices
void arma_fortran(arma_sgeev)(char* jobvl, char* jobvr, blas_int* n, flo at* a, blas_int* lda, float* wr, float* wi, float* vl, blas_int* ldvl, float* vr, blas_int* ldvr, float* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_sgeev)(char* jobvl, char* jobvr, blas_int* n, flo at* a, blas_int* lda, float* wr, float* wi, float* vl, blas_int* ldvl, float* vr, blas_int* ldvr, float* work, blas_int* lwork, blas_int* info);
void arma_fortran(arma_dgeev)(char* jobvl, char* jobvr, blas_int* n, doub le* a, blas_int* lda, double* wr, double* wi, double* vl, blas_int* ldvl, d ouble* vr, blas_int* ldvr, double* work, blas_int* lwork, blas_int* info); void arma_fortran(arma_dgeev)(char* jobvl, char* jobvr, blas_int* n, doub le* a, blas_int* lda, double* wr, double* wi, double* vl, blas_int* ldvl, d ouble* vr, blas_int* ldvr, double* work, blas_int* lwork, blas_int* info);
// eigenvector decomposition of general complex matrices // eigenvector decomposition of general complex matrices
void arma_fortran(arma_cgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, float* rwork, blas_int* info); void arma_fortran(arma_cgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, float* rwork, blas_int* info);
void arma_fortran(arma_zgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, double* rwork, blas_int* info); void arma_fortran(arma_zgeev)(char* jobvl, char* jobvr, blas_int* n, void * a, blas_int* lda, void* w, void* vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork, double* rwork, blas_int* info);
// eigenvector decomposition of general real matrix pair
void arma_fortran(arma_sggev)(char* jobvl, char* jobvr, blas_int* n, flo
at* a, blas_int* lda, float* b, blas_int* ldb, float* alphar, float* alp
hai, float* beta, float* vl, blas_int* ldvl, float* vr, blas_int* ldvr,
float* work, blas_int* lwork, blas_int* info);
void arma_fortran(arma_dggev)(char* jobvl, char* jobvr, blas_int* n, doub
le* a, blas_int* lda, double* b, blas_int* ldb, double* alphar, double* alp
hai, double* beta, double* vl, blas_int* ldvl, double* vr, blas_int* ldvr,
double* work, blas_int* lwork, blas_int* info);
// eigenvector decomposition of general complex matrix pair
void arma_fortran(arma_cggev)(char* jobvl, char* jobvr, blas_int* n, void
* a, blas_int* lda, void* b, blas_int* ldb, void* alpha, void* beta, void*
vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork,
float* rwork, blas_int* info);
void arma_fortran(arma_zggev)(char* jobvl, char* jobvr, blas_int* n, void
* a, blas_int* lda, void* b, blas_int* ldb, void* alpha, void* beta, void*
vl, blas_int* ldvl, void* vr, blas_int* ldvr, void* work, blas_int* lwork,
double* rwork, blas_int* info);
// Cholesky decomposition // Cholesky decomposition
void arma_fortran(arma_spotrf)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_spotrf)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info);
void arma_fortran(arma_dpotrf)(char* uplo, blas_int* n, double* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_dpotrf)(char* uplo, blas_int* n, double* a, blas_i nt* lda, blas_int* info);
void arma_fortran(arma_cpotrf)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_cpotrf)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info);
void arma_fortran(arma_zpotrf)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_zpotrf)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info);
// matrix inversion (using Cholesky decomposition result) // matrix inversion (using Cholesky decomposition result)
void arma_fortran(arma_spotri)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_spotri)(char* uplo, blas_int* n, float* a, blas_i nt* lda, blas_int* info);
void arma_fortran(arma_dpotri)(char* uplo, blas_int* n, double* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_dpotri)(char* uplo, blas_int* n, double* a, blas_i nt* lda, blas_int* info);
void arma_fortran(arma_cpotri)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info); void arma_fortran(arma_cpotri)(char* uplo, blas_int* n, void* a, blas_i nt* lda, blas_int* info);
 End of changes. 3 change blocks. 
0 lines changed or deleted 32 lines changed or added


 lapack_wrapper.hpp   lapack_wrapper.hpp 
skipping to change at line 270 skipping to change at line 270
{ {
typedef double T; typedef double T;
typedef typename std::complex<T> cx_T; typedef typename std::complex<T> cx_T;
arma_fortran(arma_zgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info); arma_fortran(arma_zgeev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)w, (c x_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work, lwork, (T*)rwork, info);
} }
} }
template<typename eT> template<typename eT>
inline inline
void void
ggev
(
char* jobvl, char* jobvr, blas_int* n,
eT* a, blas_int* lda, eT* b, blas_int* ldb,
eT* alphar, eT* alphai, eT* beta,
eT* vl, blas_int* ldvl, eT* vr, blas_int* ldvr,
eT* work, blas_int* lwork,
blas_int* info
)
{
arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true)
{
typedef float T;
arma_fortran(arma_sggev)(jobvl, jobvr, n, (T*)a, lda, (T*)b, ldb, (T*
)alphar, (T*)alphai, (T*)beta, (T*)vl, ldvl, (T*)vr, ldvr, (T*)work, lwork,
info);
}
else
if(is_double<eT>::value == true)
{
typedef double T;
arma_fortran(arma_dggev)(jobvl, jobvr, n, (T*)a, lda, (T*)b, ldb, (T*
)alphar, (T*)alphai, (T*)beta, (T*)vl, ldvl, (T*)vr, ldvr, (T*)work, lwork,
info);
}
}
template<typename eT>
inline
void
cx_ggev
(
char* jobvl, char* jobvr, blas_int* n,
eT* a, blas_int* lda, eT* b, blas_int* ldb,
eT* alpha, eT* beta,
eT* vl, blas_int* ldvl, eT* vr, blas_int* ldvr,
eT* work, blas_int* lwork, typename eT::value_type* rwork,
blas_int* info
)
{
arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_supported_complex_float<eT>::value == true)
{
typedef float T;
typedef typename std::complex<T> cx_T;
arma_fortran(arma_cggev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)b, ld
b, (cx_T*)alpha, (cx_T*)beta, (cx_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work
, lwork, (T*)rwork, info);
}
else
if(is_supported_complex_double<eT>::value == true)
{
typedef double T;
typedef typename std::complex<T> cx_T;
arma_fortran(arma_zggev)(jobvl, jobvr, n, (cx_T*)a, lda, (cx_T*)b, ld
b, (cx_T*)alpha, (cx_T*)beta, (cx_T*)vl, ldvl, (cx_T*)vr, ldvr, (cx_T*)work
, lwork, (T*)rwork, info);
}
}
template<typename eT>
inline
void
potrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info) potrf(char* uplo, blas_int* n, eT* a, blas_int* lda, blas_int* info)
{ {
arma_type_check(( is_supported_blas_type<eT>::value == false )); arma_type_check(( is_supported_blas_type<eT>::value == false ));
if(is_float<eT>::value == true) if(is_float<eT>::value == true)
{ {
typedef float T; typedef float T;
arma_fortran(arma_spotrf)(uplo, n, (T*)a, lda, info); arma_fortran(arma_spotrf)(uplo, n, (T*)a, lda, info);
} }
else else
 End of changes. 1 change blocks. 
0 lines changed or deleted 66 lines changed or added


 op_inv_meat.hpp   op_inv_meat.hpp 
skipping to change at line 116 skipping to change at line 116
void void
op_inv_sympd::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_sy mpd>& X) op_inv_sympd::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_inv_sy mpd>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = auxlib::inv_sympd(out, X.m, X.aux_uword_a); const bool status = auxlib::inv_sympd(out, X.m, X.aux_uword_a);
if(status == false) if(status == false)
{ {
out.reset(); out.reset();
arma_bad("inv(): matrix appears to be singular"); arma_bad("inv_sympd(): matrix appears to be singular");
} }
} }
//! @} //! @}
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 op_misc_bones.hpp   op_misc_bones.hpp 
skipping to change at line 44 skipping to change at line 44
{ {
public: public:
template<typename T1> template<typename T1>
inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typ ename T1::pod_type, T1, op_abs>& X); inline static void apply( Mat<typename T1::pod_type>& out, const mtOp<typ ename T1::pod_type, T1, op_abs>& X);
template<typename T1> template<typename T1>
inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCub e<typename T1::pod_type, T1, op_abs>& X); inline static void apply( Cube<typename T1::pod_type>& out, const mtOpCub e<typename T1::pod_type, T1, op_abs>& X);
}; };
class op_sympd
{
public:
template<typename T1>
inline static void apply( Mat<typename T1::elem_type>& out, const Op<T1,
op_sympd>& X);
};
//! @} //! @}
 End of changes. 1 change blocks. 
9 lines changed or deleted 0 lines changed or added


 op_misc_meat.hpp   op_misc_meat.hpp 
skipping to change at line 263 skipping to change at line 263
for(uword slice=0; slice < n_slices; ++slice) for(uword slice=0; slice < n_slices; ++slice)
for(uword col=0; col < n_cols; ++col ) for(uword col=0; col < n_cols; ++col )
for(uword row=0; row < n_rows; ++row ) for(uword row=0; row < n_rows; ++row )
{ {
*out_mem = std::abs( P.at(row,col,slice) ); *out_mem = std::abs( P.at(row,col,slice) );
out_mem++; out_mem++;
} }
} }
} }
template<typename T1>
inline
void
op_sympd::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_sympd>&
X )
{
arma_extra_debug_sigprint();
out = X.m;
}
//! @} //! @}
 End of changes. 1 change blocks. 
11 lines changed or deleted 0 lines changed or added


 op_resize_meat.hpp   op_resize_meat.hpp 
skipping to change at line 31 skipping to change at line 31
const uword out_n_cols = in.aux_uword_b; const uword out_n_cols = in.aux_uword_b;
const unwrap<T1> tmp(in.m); const unwrap<T1> tmp(in.m);
const Mat<eT>& A = tmp.M; const Mat<eT>& A = tmp.M;
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const bool alias = (&actual_out == &A); const bool alias = (&actual_out == &A);
if( alias && (A_n_rows == out_n_rows) && (A_n_cols == out_n_cols) ) if(alias)
{ {
return; if( (A_n_rows == out_n_rows) && (A_n_cols == out_n_cols) )
{
return;
}
if(actual_out.is_empty())
{
actual_out.zeros(out_n_rows, out_n_cols);
return;
}
} }
Mat<eT> B; Mat<eT> B;
Mat<eT>& out = alias ? B : actual_out; Mat<eT>& out = alias ? B : actual_out;
out.set_size(out_n_rows, out_n_cols); out.set_size(out_n_rows, out_n_cols);
if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) ) if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) )
{ {
out.zeros(); out.zeros();
skipping to change at line 82 skipping to change at line 91
const unwrap_cube<T1> tmp(in.m); const unwrap_cube<T1> tmp(in.m);
const Cube<eT>& A = tmp.M; const Cube<eT>& A = tmp.M;
const uword A_n_rows = A.n_rows; const uword A_n_rows = A.n_rows;
const uword A_n_cols = A.n_cols; const uword A_n_cols = A.n_cols;
const uword A_n_slices = A.n_slices; const uword A_n_slices = A.n_slices;
const bool alias = (&actual_out == &A); const bool alias = (&actual_out == &A);
if( alias && (A_n_rows == out_n_rows) && (A_n_cols == out_n_cols) && (A_n _slices == out_n_slices) ) if(alias)
{ {
return; if( (A_n_rows == out_n_rows) && (A_n_cols == out_n_cols) && (A_n_slices
== out_n_slices) )
{
return;
}
if(actual_out.is_empty())
{
actual_out.zeros(out_n_rows, out_n_cols, out_n_slices);
return;
}
} }
Cube<eT> B; Cube<eT> B;
Cube<eT>& out = alias ? B : actual_out; Cube<eT>& out = alias ? B : actual_out;
out.set_size(out_n_rows, out_n_cols, out_n_slices); out.set_size(out_n_rows, out_n_cols, out_n_slices);
if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) || (out_n_slices > A_n_slices) ) if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) || (out_n_slices > A_n_slices) )
{ {
out.zeros(); out.zeros();
 End of changes. 4 change blocks. 
4 lines changed or deleted 23 lines changed or added


 op_vectorise_bones.hpp   op_vectorise_bones.hpp 
skipping to change at line 17 skipping to change at line 17
//! \addtogroup op_vectorise //! \addtogroup op_vectorise
//! @{ //! @{
class op_vectorise_col class op_vectorise_col
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_vectorise_col>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_vectorise_col>& in);
template<typename T1> inline static void apply_expr( Mat<typename T1::ele template<typename T1> inline static void apply_proxy( Mat<typename T1::el
m_type>& out, const T1& expr); em_type>& out, const Proxy<T1>& P);
};
class op_vectorise_row
{
public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ
e>& out, const Op<T1,op_vectorise_row>& in);
template<typename T1> inline static void apply_proxy( Mat<typename T1::el
em_type>& out, const Proxy<T1>& P);
}; };
class op_vectorise_all class op_vectorise_all
{ {
public: public:
template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_vectorise_all>& in); template<typename T1> inline static void apply( Mat<typename T1::elem_typ e>& out, const Op<T1,op_vectorise_all>& in);
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
2 lines changed or deleted 13 lines changed or added


 op_vectorise_meat.hpp   op_vectorise_meat.hpp 
skipping to change at line 18 skipping to change at line 18
//! \addtogroup op_vectorise //! \addtogroup op_vectorise
//! @{ //! @{
template<typename T1> template<typename T1>
inline inline
void void
op_vectorise_col::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ve ctorise_col>& in) op_vectorise_col::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ve ctorise_col>& in)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
op_vectorise_col::apply_expr(out, in.m); const Proxy<T1> P(in.m);
op_vectorise_col::apply_proxy(out, P);
} }
template<typename T1> template<typename T1>
inline inline
void void
op_vectorise_col::apply_expr(Mat<typename T1::elem_type>& out, const T1& ex pr) op_vectorise_col::apply_proxy(Mat<typename T1::elem_type>& out, const Proxy <T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const Proxy<T1> P(expr);
if(P.is_alias(out) == false) if(P.is_alias(out) == false)
{ {
const uword N = P.get_n_elem(); const uword N = P.get_n_elem();
out.set_size(N, 1); out.set_size(N, 1);
if(is_Mat<typename Proxy<T1>::stored_type>::value == true) if(is_Mat<typename Proxy<T1>::stored_type>::value == true)
{ {
const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q); const unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
skipping to change at line 104 skipping to change at line 104
else // we have aliasing else // we have aliasing
{ {
arma_extra_debug_print("op_vectorise_col::apply(): aliasing detected"); arma_extra_debug_print("op_vectorise_col::apply(): aliasing detected");
if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy< T1>::fake_mat == false) ) if( (is_Mat<typename Proxy<T1>::stored_type>::value == true) && (Proxy< T1>::fake_mat == false) )
{ {
out.set_size(out.n_elem, 1); // set_size() doesn't destroy data as l ong as the number of elements in the matrix remains the same out.set_size(out.n_elem, 1); // set_size() doesn't destroy data as l ong as the number of elements in the matrix remains the same
} }
else else
{ {
const Mat<eT> tmp(P.Q); Mat<eT> tmp;
op_vectorise_col::apply_proxy(tmp, P);
out = vectorise(tmp); out.steal_mem(tmp);
} }
} }
} }
template<typename T1> template<typename T1>
inline inline
void void
op_vectorise_all::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ve op_vectorise_row::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ve
ctorise_all>& in) ctorise_row>& in)
{
arma_extra_debug_sigprint();
const Proxy<T1> P(in.m);
op_vectorise_row::apply_proxy(out, P);
}
template<typename T1>
inline
void
op_vectorise_row::apply_proxy(Mat<typename T1::elem_type>& out, const Proxy
<T1>& P)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
if(P.is_alias(out) == false)
{
out.set_size( 1, P.get_n_elem() );
eT* outmem = out.memptr();
const uword n_rows = P.get_n_rows();
const uword n_cols = P.get_n_cols();
for(uword row=0; row < n_rows; ++row)
{
uword i,j;
for(i=0, j=1; j < n_cols; i+=2, j+=2)
{
const eT tmp_i = P.at(row,i);
const eT tmp_j = P.at(row,j);
*outmem = tmp_i; outmem++;
*outmem = tmp_j; outmem++;
}
if(i < n_cols)
{
*outmem = P.at(row,i); outmem++;
}
}
}
else // we have aliasing
{
arma_extra_debug_print("op_vectorise_row::apply(): aliasing detected");
Mat<eT> tmp;
op_vectorise_row::apply_proxy(tmp, P);
out.steal_mem(tmp);
}
}
template<typename T1>
inline
void
op_vectorise_all::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_ve
ctorise_all>& in)
{
arma_extra_debug_sigprint();
const Proxy<T1> P(in.m);
const uword dim = in.aux_uword_a; const uword dim = in.aux_uword_a;
if(dim == 0) if(dim == 0)
{ {
op_vectorise_col::apply_expr(out, in.m); op_vectorise_col::apply_proxy(out, P);
} }
else else
{ {
const unwrap<T1> tmp(in.m); op_vectorise_row::apply_proxy(out, P);
const Mat<eT>& A = tmp.M;
out = reshape(A, 1, A.n_elem, 1);
} }
} }
//! @} //! @}
 End of changes. 9 change blocks. 
13 lines changed or deleted 75 lines changed or added


 operator_ostream.hpp   operator_ostream.hpp 
// Copyright (C) 2008-2012 Conrad Sanderson // Copyright (C) 2008-2013 Conrad Sanderson
// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup operator_ostream //! \addtogroup operator_ostream
//! @{ //! @{
template<typename eT, typename T1> template<typename eT, typename T1>
inline inline
skipping to change at line 42 skipping to change at line 42
const unwrap_spmat<T1> tmp(X.get_ref()); const unwrap_spmat<T1> tmp(X.get_ref());
arma_ostream::print(o, tmp.M, true); arma_ostream::print(o, tmp.M, true);
return o; return o;
} }
template<typename T1> template<typename T1>
inline inline
std::ostream& std::ostream&
operator<< (std::ostream& o, const SpValProxy<T1>& X)
{
arma_extra_debug_sigprint();
typedef typename T1::elem_type eT;
o << eT(X);
return o;
}
template<typename T1>
inline
std::ostream&
operator<< (std::ostream& o, const BaseCube<typename T1::elem_type,T1>& X) operator<< (std::ostream& o, const BaseCube<typename T1::elem_type,T1>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const unwrap_cube<T1> tmp(X.get_ref()); const unwrap_cube<T1> tmp(X.get_ref());
arma_ostream::print(o, tmp.M, true); arma_ostream::print(o, tmp.M, true);
return o; return o;
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 16 lines changed or added


 podarray_meat.hpp   podarray_meat.hpp 
skipping to change at line 233 skipping to change at line 233
arrayops::inplace_set(memptr(), val, n_elem); arrayops::inplace_set(memptr(), val, n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::zeros() podarray<eT>::zeros()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
fill(eT(0)); arrayops::fill_zeros(memptr(), n_elem);
} }
template<typename eT> template<typename eT>
inline inline
void void
podarray<eT>::zeros(const uword new_n_elem) podarray<eT>::zeros(const uword new_n_elem)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
init_warm(new_n_elem); init_warm(new_n_elem);
fill(eT(0)); arrayops::fill_zeros(memptr(), n_elem);
} }
template<typename eT> template<typename eT>
arma_inline arma_inline
eT* eT*
podarray<eT>::memptr() podarray<eT>::memptr()
{ {
return mem; return mem;
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 strip.hpp   strip.hpp 
// Copyright (C) 2010-2012 Conrad Sanderson // Copyright (C) 2010-2013 Conrad Sanderson
// Copyright (C) 2010-2012 NICTA (www.nicta.com.au) // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! \addtogroup strip //! \addtogroup strip
//! @{ //! @{
template<typename T1> template<typename T1>
struct strip_diagmat struct strip_diagmat
skipping to change at line 80 skipping to change at line 80
: M(X.m) : M(X.m)
, slow(X.aux_uword_a == 1) , slow(X.aux_uword_a == 1)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const T1& M; const T1& M;
const bool slow; const bool slow;
static const bool do_inv = true; static const bool do_inv = true;
};
template<typename T1>
struct strip_inv< Op<T1, op_inv_sympd> >
{
typedef T1 stored_type;
arma_hot inline
strip_inv(const Op<T1, op_inv_sympd>& X)
: M(X.m)
, slow(X.aux_uword_a == 1)
{
arma_extra_debug_sigprint();
}
const T1& M;
const bool slow;
static const bool do_inv = true;
}; };
//! @} //! @}
 End of changes. 2 change blocks. 
2 lines changed or deleted 21 lines changed or added


 subview_elem1_bones.hpp   subview_elem1_bones.hpp 
skipping to change at line 22 skipping to change at line 22
class subview_elem1 : public Base<eT, subview_elem1<eT,T1> > class subview_elem1 : public Base<eT, subview_elem1<eT,T1> >
{ {
public: public:
typedef eT elem_type; typedef eT elem_type;
typedef typename get_pod_type<elem_type>::result pod_type; typedef typename get_pod_type<elem_type>::result pod_type;
static const bool is_row = false; static const bool is_row = false;
static const bool is_col = true; static const bool is_col = true;
arma_aligned const Mat<eT> fake_m;
arma_aligned const Mat<eT>& m; arma_aligned const Mat<eT>& m;
arma_aligned const Base<uword,T1>& a; arma_aligned const Base<uword,T1>& a;
protected: protected:
arma_inline subview_elem1(const Mat<eT>& in_m, const Base<uword,T1>& in_a arma_inline subview_elem1(const Mat<eT>& in_m, const Base<uword,T1>& in_
); a);
arma_inline subview_elem1(const Cube<eT>& in_q, const Base<uword,T1>& in_
a);
public: public:
inline ~subview_elem1(); inline ~subview_elem1();
template<typename op_type> inline void inplace_op(const eT val); template<typename op_type> inline void inplace_op(const eT val);
template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const subv iew_elem1<eT,T2>& x );
template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x ); template<typename op_type, typename T2> inline void inplace_op(const Base <eT,T2>& x );
arma_inline const Op<subview_elem1<eT,T1>,op_htrans> t() const; arma_inline const Op<subview_elem1<eT,T1>,op_htrans> t() const;
skipping to change at line 78 skipping to change at line 80
template<typename op_type> inline static void mat_inplace_op(Mat<eT>& out , const subview_elem1& in); template<typename op_type> inline static void mat_inplace_op(Mat<eT>& out , const subview_elem1& in);
inline static void plus_inplace(Mat<eT>& out, const subview_elem1& in); inline static void plus_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void minus_inplace(Mat<eT>& out, const subview_elem1& in); inline static void minus_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void schur_inplace(Mat<eT>& out, const subview_elem1& in); inline static void schur_inplace(Mat<eT>& out, const subview_elem1& in);
inline static void div_inplace(Mat<eT>& out, const subview_elem1& in); inline static void div_inplace(Mat<eT>& out, const subview_elem1& in);
private: private:
friend class Mat<eT>; friend class Mat<eT>;
friend class Cube<eT>;
subview_elem1(); subview_elem1();
}; };
//! @} //! @}
 End of changes. 3 change blocks. 
3 lines changed or deleted 8 lines changed or added


 subview_elem1_meat.hpp   subview_elem1_meat.hpp 
skipping to change at line 28 skipping to change at line 28
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline arma_inline
subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<uword,T 1>& in_a) subview_elem1<eT,T1>::subview_elem1(const Mat<eT>& in_m, const Base<uword,T 1>& in_a)
: m(in_m) : m(in_m)
, a(in_a) , a(in_a)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT, typename T1> template<typename eT, typename T1>
arma_inline
subview_elem1<eT,T1>::subview_elem1(const Cube<eT>& in_q, const Base<uword,
T1>& in_a)
: fake_m( const_cast< eT* >(in_q.memptr()), in_q.n_elem, 1, false )
, m( fake_m )
, a( in_a )
{
arma_extra_debug_sigprint();
}
template<typename eT, typename T1>
template<typename op_type> template<typename op_type>
inline inline
void void
subview_elem1<eT,T1>::inplace_op(const eT val) subview_elem1<eT,T1>::inplace_op(const eT val)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
Mat<eT>& m_local = const_cast< Mat<eT>& >(m); Mat<eT>& m_local = const_cast< Mat<eT>& >(m);
eT* m_mem = m_local.memptr(); eT* m_mem = m_local.memptr();
 End of changes. 1 change blocks. 
0 lines changed or deleted 11 lines changed or added


 unwrap.hpp   unwrap.hpp 
skipping to change at line 518 skipping to change at line 518
typedef typename T1::elem_type eT1; typedef typename T1::elem_type eT1;
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const T1& A, const Mat<eT2>&) unwrap_check_mixed(const T1& A, const Mat<eT2>&)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2> //template<typename eT2>
inline inline
unwrap_check_mixed(const T1& A, const bool) unwrap_check_mixed(const T1& A, const bool)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
const Mat<eT1> M; const Mat<eT1> M;
}; };
skipping to change at line 541 skipping to change at line 541
{ {
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Mat<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Mat<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2> //template<typename eT2>
inline inline
unwrap_check_mixed(const Mat<eT1>& A, const bool is_alias) unwrap_check_mixed(const Mat<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Mat<eT1>(A) : 0 ) : M_local( is_alias ? new Mat<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A ) , M ( is_alias ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
skipping to change at line 575 skipping to change at line 575
{ {
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Row<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Row<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2> //template<typename eT2>
inline inline
unwrap_check_mixed(const Row<eT1>& A, const bool is_alias) unwrap_check_mixed(const Row<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Row<eT1>(A) : 0 ) : M_local( is_alias ? new Row<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A ) , M ( is_alias ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
skipping to change at line 609 skipping to change at line 609
{ {
template<typename eT2> template<typename eT2>
inline inline
unwrap_check_mixed(const Col<eT1>& A, const Mat<eT2>& B) unwrap_check_mixed(const Col<eT1>& A, const Mat<eT2>& B)
: M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col<eT1>(A) : 0 ) : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col<eT1>(A) : 0 )
, M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
template<typename eT2> //template<typename eT2>
inline inline
unwrap_check_mixed(const Col<eT1>& A, const bool is_alias) unwrap_check_mixed(const Col<eT1>& A, const bool is_alias)
: M_local( is_alias ? new Col<eT1>(A) : 0 ) : M_local( is_alias ? new Col<eT1>(A) : 0 )
, M ( is_alias ? (*M_local) : A ) , M ( is_alias ? (*M_local) : A )
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
} }
inline inline
~unwrap_check_mixed() ~unwrap_check_mixed()
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 unwrap_cube.hpp   unwrap_cube.hpp 
skipping to change at line 50 skipping to change at line 50
const Cube<eT>& M; const Cube<eT>& M;
}; };
// //
// //
// //
template<typename T1> template<typename T1>
class unwrap_cube_check class unwrap_cube_check
{ {
public:
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
inline inline
unwrap_cube_check(const T1& A, const Cube<eT>&) unwrap_cube_check(const T1& A, const Cube<eT>&)
: M(A) : M(A)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
arma_type_check(( is_arma_cube_type<T1>::value == false )); arma_type_check(( is_arma_cube_type<T1>::value == false ));
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 wall_clock_bones.hpp   wall_clock_bones.hpp 
skipping to change at line 28 skipping to change at line 28
inline void tic(); //!< start the timer inline void tic(); //!< start the timer
inline double toc(); //!< return the number of seconds since the last ca ll to tic() inline double toc(); //!< return the number of seconds since the last ca ll to tic()
private: private:
bool valid; bool valid;
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
std::chrono::steady_clock::time_point chrono_time1; std::chrono::steady_clock::time_point chrono_time1;
#elif defined(ARMA_USE_BOOST_DATE)
boost::posix_time::ptime boost_time1;
boost::posix_time::time_duration boost_duration;
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
struct timeval posix_time1; struct timeval posix_time1;
struct timeval posix_time2; struct timeval posix_time2;
#else #else
clock_t time1; clock_t time1;
#endif #endif
}; };
//! @} //! @}
 End of changes. 1 change blocks. 
3 lines changed or deleted 0 lines changed or added


 wall_clock_meat.hpp   wall_clock_meat.hpp 
skipping to change at line 35 skipping to change at line 35
void void
wall_clock::tic() wall_clock::tic()
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
{ {
chrono_time1 = std::chrono::steady_clock::now(); chrono_time1 = std::chrono::steady_clock::now();
valid = true; valid = true;
} }
#elif defined(ARMA_USE_BOOST_DATE)
{
boost_time1 = boost::posix_time::microsec_clock::local_time();
valid = true;
}
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
{ {
gettimeofday(&posix_time1, 0); gettimeofday(&posix_time1, 0);
valid = true; valid = true;
} }
#else #else
{ {
time1 = clock(); time1 = clock();
valid = true; valid = true;
} }
skipping to change at line 71 skipping to change at line 66
#if defined(ARMA_USE_CXX11) #if defined(ARMA_USE_CXX11)
{ {
const std::chrono::steady_clock::time_point chrono_time2 = std::chron o::steady_clock::now(); const std::chrono::steady_clock::time_point chrono_time2 = std::chron o::steady_clock::now();
typedef std::chrono::duration<double> duration_type; typedef std::chrono::duration<double> duration_type;
const duration_type chrono_span = std::chrono::duration_cast< duratio n_type >(chrono_time2 - chrono_time1); const duration_type chrono_span = std::chrono::duration_cast< duratio n_type >(chrono_time2 - chrono_time1);
return chrono_span.count(); return chrono_span.count();
} }
#elif defined(ARMA_USE_BOOST_DATE)
{
boost_duration = boost::posix_time::microsec_clock::local_time() - bo
ost_time1;
return boost_duration.total_microseconds() * 1e-6;
}
#elif defined(ARMA_HAVE_GETTIMEOFDAY) #elif defined(ARMA_HAVE_GETTIMEOFDAY)
{ {
gettimeofday(&posix_time2, 0); gettimeofday(&posix_time2, 0);
const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1 .0e-6; const double tmp_time1 = posix_time1.tv_sec + posix_time1.tv_usec * 1 .0e-6;
const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1 .0e-6; const double tmp_time2 = posix_time2.tv_sec + posix_time2.tv_usec * 1 .0e-6;
return tmp_time2 - tmp_time1; return tmp_time2 - tmp_time1;
} }
#else #else
 End of changes. 2 change blocks. 
11 lines changed or deleted 0 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/