forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract function into random_polynomial_matrix.h
This code is test-only, and uses uncontrolled randomness, so doesn't belong in the common library. (It also happens to break with Eigen 3.2, so got in my way.)
- Loading branch information
1 parent
c1d81ae
commit 01eec0b
Showing
5 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "drake/common/polynomial.h" | ||
|
||
namespace drake { | ||
namespace test { | ||
|
||
/// Obtains a matrix of random unvariate Polynomials of the specified size. | ||
template <typename CoefficientType = double> | ||
static Eigen::Matrix<Polynomial<CoefficientType>, | ||
Eigen::Dynamic, Eigen::Dynamic> | ||
RandomPolynomialMatrix(Eigen::Index num_coefficients_per_polynomial, | ||
Eigen::Index rows, Eigen::Index cols) { | ||
Eigen::Matrix<Polynomial<CoefficientType>, Eigen::Dynamic, Eigen::Dynamic> | ||
mat(rows, cols); | ||
for (Eigen::Index row = 0; row < mat.rows(); ++row) { | ||
for (Eigen::Index col = 0; col < mat.cols(); ++col) { | ||
auto coeffs = | ||
(Eigen::Matrix<CoefficientType, Eigen::Dynamic, 1>::Random( | ||
num_coefficients_per_polynomial)).eval(); | ||
mat(row, col) = Polynomial<CoefficientType>(coeffs); | ||
} | ||
} | ||
return mat; | ||
} | ||
|
||
} // namespace test | ||
} // namespace drake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters