This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to compute a L1 norm of a vector?

Tags: None
(comma "," separated)
rwerp
Registered Member
Posts
4
Karma
0
OS

How to compute a L1 norm of a vector?

Sat Dec 19, 2009 10:38 pm
I want to calculate a L1 norm of a difference of two VectorXd vectors. I've tried

Code: Select all
(a - b).lpNorm<1>();


but it fails in Cygwin GCC with the message

g++.exe -Wreturn-type -o dist/Debug/Cygwin_4.x-Windows/marketfactorintegration build/Debug/Cygwin_4.x-Windows/main.o ../Maths/dist/Debug/Cygwin_4.x-Windows/libmaths.a
build/Debug/Cygwin_4.x-Windows/main.o: In function `_Z9scan_rhosd':
/cygdrive/g/NetBeansWorkspace/MarketFactorIntegration/main.cpp:239: undefined reference to `double Eigen::MatrixBase<Eigen::CwiseBinaryOp<Eigen::ei_scalar_difference_op<double>, Eigen::Matrix<double, 10000, 1, 2, 10000, 1>, Eigen::Matrix<double, 10000, 1, 2, 10000, 1> > >::lpNorm<1>() const'
build/Debug/Cygwin_4.x-Windows/main.o:/cygdrive/g/NetBeansWorkspace/MarketFactorIntegration/main.cpp:203: undefined reference to `double Eigen::MatrixBase<Eigen::Matrix<double, 10000, 1, 2, 10000, 1> >::lpNorm<1>() const'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/marketfactorintegration.exe] Error 1
make[2]: Leaving directory `/cygdrive/g/NetBeansWorkspace/MarketFactorIntegration'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/g/NetBeansWorkspace/MarketFactorIntegration'
make: *** [.build-impl] Error 2


However,

Code: Select all
(a - b).cwise().abs().sum();


compiles.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
lpNorm() requires the Array module.
Code: Select all
#include<eigen/Array


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
rwerp
Registered Member
Posts
4
Karma
0
OS
It works, thanks.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]