vector - Pushing element at back of vec in armadillo -
how can push element @ end of vector in vec of armadillo? performing adding , removing element in sorted list in loop. expensive thing. way doing in case of removing element vec x vec x_curr as:
x_curr = x(find(x != element))
however not trivial in case of adding element in loop.
x_curr = x; x_curr << element; x_curr = sort(x_curr);
this not correct. in addition not efficient. efficient way in armadillo. other stl library solution. using in rcpp armadillo. can perhaps sorting every loop. x_curr used store of indices of column of arma::mat i.e. going use mat.col(x_curr).
i don't understand question.
armadillo math library, operates on vectors. if not know size, allocate guessed n
elements , resize in common 'times two' idiom needed, , shrink @ end. if know size, have no problem.
the stl has so-called generic containers , algorithms, not linear algebra. need figure out need most, , plan implementation accordingly.
Comments
Post a Comment