mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
Move eigen to third party (#282)
* remove useless statement * Add eigen to third_party dir * remove reducdant lines
This commit is contained in:
21
third_party/eigen/doc/snippets/Tutorial_Map_using.cpp
vendored
Normal file
21
third_party/eigen/doc/snippets/Tutorial_Map_using.cpp
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
typedef Matrix<float, 1, Dynamic> MatrixType;
|
||||
typedef Map<MatrixType> MapType;
|
||||
typedef Map<const MatrixType> MapTypeConst; // a read-only map
|
||||
const int n_dims = 5;
|
||||
|
||||
MatrixType m1(n_dims), m2(n_dims);
|
||||
m1.setRandom();
|
||||
m2.setRandom();
|
||||
float *p = &m2(0); // get the address storing the data for m2
|
||||
MapType m2map(p, m2.size()); // m2map shares data with m2
|
||||
MapTypeConst m2mapconst(p, m2.size()); // a read-only accessor for m2
|
||||
|
||||
cout << "m1: " << m1 << endl;
|
||||
cout << "m2: " << m2 << endl;
|
||||
cout << "Squared euclidean distance: " << (m1 - m2).squaredNorm() << endl;
|
||||
cout << "Squared euclidean distance, using map: " << (m1 - m2map).squaredNorm()
|
||||
<< endl;
|
||||
m2map(3) = 7; // this will change m2, since they share the same array
|
||||
cout << "Updated m2: " << m2 << endl;
|
||||
cout << "m2 coefficient 2, constant accessor: " << m2mapconst(2) << endl;
|
||||
/* m2mapconst(2) = 5; */ // this yields a compile-time error
|
||||
Reference in New Issue
Block a user