File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments