[mlpack] Question about Armadillo

Ryan Curtin ryan at ratml.org
Tue Jun 27 12:36:01 EDT 2017


On Tue, Jun 27, 2017 at 08:43:35PM +0500, Kirill Mishchenko wrote:
> The type of T is 
> 
> arma::Glue<arma::Op<arma::Gen<arma::Col<double>, arma::gen_zeros>, arma::op_htrans>, arma::Op<arma::Gen<arma::Col<double>, arma::gen_zeros>, arma::op_htrans>, arma::glue_join_rows>
> 
> I guess there should be something wrong with the line 
> 
> const T& ref = arma::join_rows(arma::zeros(2).t(), arma::zeros(2).t());
> 
> since this works fine
> 
> template<typename T>
> void f(const T& arg)
> {
>   arma::mat m = arg;
> }
> 
> BOOST_AUTO_TEST_CASE(RefTest)
> {
>   f(arma::join_rows(arma::zeros(2).t(), arma::zeros(2).t()));
> }

Hmm, interesting, I wonder if the instantiation of the Glue<> type
itself causes some problem.  Usually I think these types are not
actually instantiated in programs, and they can be entirely optimized
out by the compiler (not always but in many cases I believe this is
true).  I suppose it's possible that the instantiation itself is causing
something ugly to happen at runtime, but I don't know if it's worthwhile
to dig that deep.  If you want to though, feel free, I would be
interested to see what you find. :)

-- 
Ryan Curtin    | "More like a nonja."
ryan at ratml.org |   - Pops


More information about the mlpack mailing list