Skip to content

Commit 74e5ec6

Browse files
committed
Create README.md
1 parent b28d37d commit 74e5ec6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Eigen/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `Eigen/Dense`
2+
3+
```cpp
4+
#include <algorithm>
5+
#include <random>
6+
// ... other Eigen includes
7+
VectorXd u{12};
8+
std::mt19937 rng{std::random_device{}()};
9+
std::uniform_real_distribution<> dist{-1, 1};
10+
std::generate(u.data(), u.data() + u.size(), [&]() { return dist(rng); });
11+
std::student_t_distribution<> tdist{5};
12+
std::generate(u.data(), u.data() + u.size(), [&]() { return tdist(rng); });
13+
auto u2 = u.array().abs();
14+
std::cout << u2.transpose() << std::endl;
15+
auto max_u = std::max_element(u2.begin(), u2.end() + u2.size());
16+
std::cout << "Max: " << *max_u << std::endl;
17+
u2 = u2.unaryExpr([](double x) { return x * x; });
18+
// std::experimental::linalg::matrix_vector_product
19+
// std::experimental::linalg::dot
20+
```

0 commit comments

Comments
 (0)