inline void GenEigsSolver<eT, SelectionRule, OpType>::init(eT* init_resid) { arma_extra_debug_sigprint(); // Reset all matrices/vectors to zero fac_V.zeros(dim_n, ncv); fac_H.zeros(ncv, ncv); fac_f.zeros(dim_n); ritz_val.zeros(ncv); ritz_vec.zeros(ncv, nev); ritz_est.zeros(ncv); ritz_conv.assign(nev, false); nmatop = 0; niter = 0; Col<eT> r(init_resid, dim_n, false); // The first column of fac_V Col<eT> v(fac_V.colptr(0), dim_n, false); eT rnorm = norm(r); arma_check( (rnorm < eps), "newarp::GenEigsSolver::init(): initial residual vector cannot be zero" ); v = r / rnorm; Col<eT> w(dim_n); op.perform_op(v.memptr(), w.memptr()); nmatop++; fac_H(0, 0) = dot(v, w); fac_f = w - v * fac_H(0, 0); }
arma_inline eT* subview_cube<eT>::slice_colptr(const u32 in_slice, const u32 in_col) { arma_check( (m_ptr == 0), "subview_cube::slice_colptr(): cube is read-only"); return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]); }
arma_inline eT& subview_cube<eT>::at(const u32 in_row, const u32 in_col, const u32 in_slice) { arma_check( (m_ptr == 0), "subview_cube::at(): cube is read-only"); const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; return access::rw( (*m_ptr).mem[index] ); }
arma_inline eT& subview_cube<eT>::operator()(const u32 in_row, const u32 in_col, const u32 in_slice) { arma_check( (m_ptr == 0), "subview_cube::operator(): matrix is read-only"); arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds"); const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; return access::rw( (*m_ptr).mem[index] ); }
arma_inline oT& subview_field<oT>::operator()(const u32 in_row, const u32 in_col) { arma_check( (f_ptr == 0), "subview_field::operator(): field is read-only"); arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview_field::operator(): index out of bounds"); const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; return *((*f_ptr).mem[index]); }
arma_inline oT& subview_field<oT>::at(const u32 in_row, const u32 in_col) { //arma_extra_debug_sigprint(); arma_check( (f_ptr == 0), "subview_field::at(): field is read-only"); const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; return *((*f_ptr).mem[index]); }
arma_inline oT& subview_field<oT>::operator[](const u32 i) { arma_check( (f_ptr == 0), "subview_field::operator[]: field is read-only"); const u32 in_col = i / n_rows; const u32 in_row = i % n_rows; const u32 index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; return *((*f_ptr).mem[index]); }
arma_warn_unused inline Col<uword> find(const SpBase<typename T1::elem_type,T1>& X, const uword k, const char* direction) { arma_extra_debug_sigprint(); arma_check(true, "find(SpBase,k,direction): not implemented yet"); // TODO Col<uword> out; return out; }
arma_inline eT& subview_cube<eT>::operator[](const u32 i) { arma_check( (m_ptr == 0), "subview_cube::operator[]: cube is read-only"); const u32 in_slice = i / n_elem_slice; const u32 offset = in_slice * n_elem_slice; const u32 j = i - offset; const u32 in_col = j / n_rows; const u32 in_row = j % n_rows; const u32 index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row; return access::rw( (*m_ptr).mem[index] ); }