eigen: svd example, use pkg-config

This commit is contained in:
Ciro Santilli
2018-05-08 22:24:18 +01:00
parent 6b61365556
commit 7cf9f23ae0
5 changed files with 36 additions and 18 deletions

View File

@@ -4208,7 +4208,7 @@ Header only linear algebra library supported by Buildroot:
.... ....
./build -B 'BR2_PACKAGE_EIGEN=y' -k ./build -B 'BR2_PACKAGE_EIGEN=y' -k
./run -F '/eigen.out' ./run -F '/eigen.out;/eigen_svd.out'
.... ....
===== PARSEC benchmark ===== PARSEC benchmark
@@ -5050,7 +5050,7 @@ so which shows that the whole delay is inside our install itself.
I put an `echo f` in `check_bin_arch`, and it just loops forever, does not stop on a particular package. I put an `echo f` in `check_bin_arch`, and it just loops forever, does not stop on a particular package.
Ignored / declied patch at: http://lists.busybox.net/pipermail/buildroot/2018-May/220662.html I might just fork Buildroot on the submodule if this keeps annoying me. Ignored / declined patch at: http://lists.busybox.net/pipermail/buildroot/2018-May/220662.html I might just fork Buildroot on the submodule if this keeps annoying me.
=== Report upstream bugs === Report upstream bugs

View File

@@ -15,6 +15,7 @@ endif
ifeq ($(BR2_PACKAGE_EIGEN),y) ifeq ($(BR2_PACKAGE_EIGEN),y)
# Header only. # Header only.
#LIBS += -leigen #LIBS += -leigen
CXXFLAGS_EXTRA += $(shell $(PKG_CONFIG) --cflags --libs eigen3)
else else
OUTS := $(filter-out eigen%$(OUT_EXT),$(OUTS)) OUTS := $(filter-out eigen%$(OUT_EXT),$(OUTS))
endif endif

View File

@@ -30,7 +30,3 @@ These programs can also be compiled and used on host.
.. link:ioctl.c[] .. link:ioctl.c[]
.. link:netlink.c[] .. link:netlink.c[]
.. link:poll.c[] .. link:poll.c[]
. Buildroot libraries
.. link:eigen.cpp[]
.. link:openmp.c[]
.. link:openblas.c[]

View File

@@ -1,14 +1,11 @@
/* Official hello world. */ /* Adapted from: https://eigen.tuxfamily.org/dox/GettingStarted.html */
#include <iostream> #include <iostream>
#include <eigen3/Eigen/Dense> #include <Eigen/Dense>
using Eigen::MatrixXd; int main() {
int main() Eigen::MatrixXd m(2,2);
{ m(0,0) = 3;
MatrixXd m(2,2); m(1,0) = 2.5;
m(0,0) = 3; m(0,1) = -1;
m(1,0) = 2.5; m(1,1) = m(1,0) + m(0,1);
m(0,1) = -1; std::cout << m << std::endl;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
} }

View File

@@ -0,0 +1,24 @@
/* Adapted from: https://eigen.tuxfamily.org/dox/classEigen_1_1JacobiSVD.html */
#include <iostream>
using std::cout;
using std::endl;
#include <Eigen/Core>
#include <Eigen/SVD>
using Eigen::ComputeThinU;
using Eigen::ComputeThinV;
using Eigen::JacobiSVD;
using Eigen::MatrixXf;
using Eigen::Vector3f;
int main() {
MatrixXf m = MatrixXf::Random(3,2);
JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV);
Vector3f rhs(1, 0, 0);
cout << "m = " << endl << m << endl << endl;
cout << "svd.singularValues() = " << endl << svd.singularValues() << endl << endl;
cout << "svd.MatrixU() = " << endl << svd.matrixU() << endl << endl;
cout << "svd.MatrixV() = " << endl << svd.matrixV() << endl << endl;
cout << "svd.solve() = " << endl << svd.solve(rhs) << endl << endl;
}