00001 #include <iostream> 00002 #include <Eigen/Dense> 00003 00004 using namespace std; 00005 int main() 00006 { 00007 Eigen::MatrixXf mat(2,4); 00008 Eigen::VectorXf v(4); 00009 00010 mat << 1, 2, 6, 9, 00011 3, 1, 7, 2; 00012 00013 v << 0,1,2,3; 00014 00015 //add v to each row of m 00016 mat.rowwise() += v; 00017 00018 std::cout << "Broadcasting result: " << std::endl; 00019 std::cout << mat << std::endl; 00020 }