[Solved] Eigen: how can I substitute matrix positive values with 1 and 0 otherwise?
You don’t need .select(). You just need to cast an array of bool to an array of H‘s component type. H = ((K * W).array() > 0.0).cast<double>(); Your original attempt failed because the size of your constant 1/0 array is not match with the size of H. Using VectorXd::Constant is not a good choice when … Read more