The following doesn't work under g++4.9, but does work under clang:
#include <iostream>
#include <armadillo>
int main()
{
arma::Col<std::complex<double>> v = {0.0, 0.0, 0.0, 0.0};
auto v1 = v(arma::span(1, 2));
auto v2 = arma::real(v1);
auto v3 = arma::real(v(arma::span(1, 2)));
std::cout << v << std::endl;
std::cout << v1 << std::endl;
std::cout << v2 << std::endl;
std::cout << v3 << std::endl;
}
The final cout gives an empty vector.
Conrad Sanderson looked at this code and advised to avoid using "auto" with armadillo, as one might end up referencing a temporary object that no longer exists. Thus, it might be a good idea to audit the code and reduce potential for future problems.
The following doesn't work under g++4.9, but does work under clang:
The final cout gives an empty vector.
Conrad Sanderson looked at this code and advised to avoid using "auto" with armadillo, as one might end up referencing a temporary object that no longer exists. Thus, it might be a good idea to audit the code and reduce potential for future problems.