catch size errors early
This commit is contained in:
@@ -81,6 +81,9 @@ op_reshape::apply_mat_inplace(Mat<eT>& A, const uword new_n_rows, const uword ne
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
arma_conform_check( (A.vec_state == 1) && (new_n_cols != 1), "reshape(): requested size is not compatible with column vector layout" );
|
||||
arma_conform_check( (A.vec_state == 2) && (new_n_rows != 1), "reshape(): requested size is not compatible with row vector layout" );
|
||||
|
||||
const uword new_n_elem = new_n_rows * new_n_cols;
|
||||
|
||||
if(A.n_elem == new_n_elem) { A.set_size(new_n_rows, new_n_cols); return; }
|
||||
|
||||
@@ -58,6 +58,9 @@ op_resize::apply_mat_inplace(Mat<eT>& A, const uword new_n_rows, const uword new
|
||||
|
||||
if( (A.n_rows == new_n_rows) && (A.n_cols == new_n_cols) ) { return; }
|
||||
|
||||
arma_conform_check( (A.vec_state == 1) && (new_n_cols != 1), "resize(): requested size is not compatible with column vector layout" );
|
||||
arma_conform_check( (A.vec_state == 2) && (new_n_rows != 1), "resize(): requested size is not compatible with row vector layout" );
|
||||
|
||||
if(A.is_empty()) { A.zeros(new_n_rows, new_n_cols); return; }
|
||||
|
||||
Mat<eT> B;
|
||||
|
||||
Reference in New Issue
Block a user