C++ Version of Yaomin's GDBR function, using RcppArmadillo