eigen/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_norm.cpp
2021-12-07 19:57:38 +00:00

26 lines
748 B
C++

#include <Eigen/Dense>
#include <iostream>
int main()
{
Eigen::VectorXf v(2);
Eigen::MatrixXf m(2,2), n(2,2);
v << -1,
2;
m << 1,-2,
-3,4;
std::cout << "v.squaredNorm() = " << v.squaredNorm() << std::endl;
std::cout << "v.norm() = " << v.norm() << std::endl;
std::cout << "v.lpNorm<1>() = " << v.lpNorm<1>() << std::endl;
std::cout << "v.lpNorm<Infinity>() = " << v.lpNorm<Eigen::Infinity>() << std::endl;
std::cout << std::endl;
std::cout << "m.squaredNorm() = " << m.squaredNorm() << std::endl;
std::cout << "m.norm() = " << m.norm() << std::endl;
std::cout << "m.lpNorm<1>() = " << m.lpNorm<1>() << std::endl;
std::cout << "m.lpNorm<Infinity>() = " << m.lpNorm<Eigen::Infinity>() << std::endl;
}