Go to the documentation of this file.00001 #include <Eigen/Array>
00002
00003 int main(int argc, char *argv[])
00004 {
00005 std::cout.precision(2);
00006
00007
00008 Eigen::Matrix3f m3 = Eigen::Matrix3f::Random();
00009 Eigen::Matrix4f m4 = Eigen::Matrix4f::Identity();
00010
00011 std::cout << "*** Step 1 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
00012
00013
00014 m4.setZero();
00015 m3.diagonal().setOnes();
00016
00017 std::cout << "*** Step 2 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
00018
00019
00020 m4.block<3,3>(0,1) = m3;
00021 m3.row(2) = m4.block<1,3>(2,0);
00022
00023 std::cout << "*** Step 3 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
00024
00025
00026 {
00027 int rows = 3, cols = 3;
00028 m4.block(0,1,3,3).setIdentity();
00029 std::cout << "*** Step 4 ***\nm4:\n" << m4 << std::endl;
00030 }
00031
00032
00033 m4.diagonal().block(1,2).setOnes();
00034 std::cout << "*** Step 5 ***\nm4.diagonal():\n" << m4.diagonal() << std::endl;
00035 std::cout << "m4.diagonal().start(3)\n" << m4.diagonal().start(3) << std::endl;
00036
00037
00038 m4 = m4.cwise()*m4;
00039 m3 = m3.cwise().cos();
00040 std::cout << "*** Step 6 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
00041
00042
00043 std::cout << "*** Step 7 ***\n m4.sum(): " << m4.sum() << std::endl;
00044 std::cout << "m4.col(2).sum(): " << m4.col(2).sum() << std::endl;
00045 std::cout << "m4.colwise().sum():\n" << m4.colwise().sum() << std::endl;
00046 std::cout << "m4.rowwise().sum():\n" << m4.rowwise().sum() << std::endl;
00047
00048
00049 m4 = m4 * m4;
00050 Eigen::Matrix4f other = (m4 * m4).lazy();
00051 m4 = m4 + m4;
00052 m4 = -m4 + m4 + 5 * m4;
00053 m4 = m4 * (m4 + m4);
00054
00055 m3 = m3 * m4.block<3,3>(1,1);
00056
00057
00058 m4 = m4 * m4.transpose();
00059 m4 = m4 * m4.transpose().eval();
00060
00061 std::cout << "*** Step 8 ***\nm3:\n" << m3 << "\nm4:\n" << m4 << std::endl;
00062 }