TemplateKeyword_flexible.cpp File Reference
#include <Eigen/Dense>
#include <iostream>

Functions

template<typename Derived1 , typename Derived2 >
void copyUpperTriangularPart (Eigen::MatrixBase< Derived1 > &dst, const Eigen::MatrixBase< Derived2 > &src)
 
int main ()
 

Function Documentation

◆ copyUpperTriangularPart()

template<typename Derived1 , typename Derived2 >
void copyUpperTriangularPart ( Eigen::MatrixBase< Derived1 > &  dst,
const Eigen::MatrixBase< Derived2 > &  src 
)
5  {
6  /* Note the 'template' keywords in the following line! */
7  dst.template triangularView<Eigen::Upper>() = src.template triangularView<Eigen::Upper>();
8 }

Referenced by main().

◆ main()

int main ( )
10  {
11  Eigen::MatrixXi m1 = Eigen::MatrixXi::Ones(5, 5);
12  Eigen::MatrixXi m2 = Eigen::MatrixXi::Random(4, 4);
13  std::cout << "m2 before copy:" << std::endl;
14  std::cout << m2 << std::endl << std::endl;
15  copyUpperTriangularPart(m2, m1.topLeftCorner(4, 4));
16  std::cout << "m2 after copy:" << std::endl;
17  std::cout << m2 << std::endl << std::endl;
18 }
Matrix3d m1
Definition: IOFormat.cpp:2
void copyUpperTriangularPart(Eigen::MatrixBase< Derived1 > &dst, const Eigen::MatrixBase< Derived2 > &src)
Definition: TemplateKeyword_flexible.cpp:5
MatrixType m2(n_dims)

References copyUpperTriangularPart(), m1, and m2().