mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Documentation: fill the placeholders, add a custom CSS file,
add a reference to the tutorial in the main page.
This commit is contained in:
22
doc/examples/Tutorial_simple_example_dynamic_size.cpp
Normal file
22
doc/examples/Tutorial_simple_example_dynamic_size.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <Eigen/Core>
|
||||
|
||||
// import most common Eigen's types
|
||||
USING_PART_OF_NAMESPACE_EIGEN
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
for (int size=1; size<=4; ++size)
|
||||
{
|
||||
MatrixXi m(size,size+1); // creates a size x (size+1) matrix of int
|
||||
for (int j=0; j<m.cols(); ++j) // loop over the columns
|
||||
for (int i=0; i<m.rows(); ++i) // loop over the rows
|
||||
m(i,j) = i+j*m.rows(); // to access matrix elements use operator (int,int)
|
||||
std::cout << m << "\n\n";
|
||||
}
|
||||
|
||||
VectorXf v4(4);
|
||||
// to access vector elements
|
||||
// you can use either operator () or operator []
|
||||
v4[0] = 1; v4[1] = 2; v4(2) = 3; v4(3) = 4;
|
||||
std::cout << "\nv4:\n" << v4 << std::endl;
|
||||
}
|
||||
14
doc/examples/Tutorial_simple_example_fixed_size.cpp
Normal file
14
doc/examples/Tutorial_simple_example_fixed_size.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <Eigen/Core>
|
||||
|
||||
// import most common Eigen's types
|
||||
USING_PART_OF_NAMESPACE_EIGEN
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Matrix3f m3;
|
||||
m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
|
||||
Matrix4f m4 = Matrix4f::Identity();
|
||||
Vector4i v4(1, 2, 3, 4);
|
||||
|
||||
std::cout << "m3\n" << m3 << "\nm4:\n" << m4 << "\nv4:\n" << v4 << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user