[wpimath] Remove deprecated MakeMatrix() function (#4202)

This commit is contained in:
Tyler Veness
2022-04-30 22:52:05 -07:00
committed by GitHub
parent e28776d361
commit ebd2a303bf
2 changed files with 0 additions and 61 deletions

View File

@@ -93,30 +93,6 @@ bool IsStabilizableImpl(const Matrixd<States, States>& A,
} // namespace detail
/**
* Creates a matrix from the given list of elements.
*
* The elements of the matrix are filled in in row-major order.
*
* @param elems An array of elements in the matrix.
* @return A matrix containing the given elements.
* @deprecated Use Eigen::Matrix or Eigen::Vector initializer list constructor.
*/
template <int Rows, int Cols, typename... Ts,
typename =
std::enable_if_t<std::conjunction_v<std::is_same<double, Ts>...>>>
WPI_DEPRECATED(
"Use Eigen::Matrix or Eigen::Vector initializer list constructor")
Matrixd<Rows, Cols> MakeMatrix(Ts... elems) {
static_assert(
sizeof...(elems) == Rows * Cols,
"Number of provided elements doesn't match matrix dimensionality");
Matrixd<Rows, Cols> result;
detail::MatrixImpl<Rows, Cols>(result, elems...);
return result;
}
/**
* Creates a cost matrix from the given vector for use with LQR.
*

View File

@@ -10,43 +10,6 @@
#include "frc/StateSpaceUtil.h"
#include "frc/system/NumericalIntegration.h"
TEST(StateSpaceUtilTest, MakeMatrix) {
// Column vector
frc::Vectord<2> mat1 = frc::MakeMatrix<2, 1>(1.0, 2.0);
EXPECT_NEAR(mat1(0), 1.0, 1e-3);
EXPECT_NEAR(mat1(1), 2.0, 1e-3);
// Row vector
Eigen::RowVector<double, 2> mat2 = frc::MakeMatrix<1, 2>(1.0, 2.0);
EXPECT_NEAR(mat2(0), 1.0, 1e-3);
EXPECT_NEAR(mat2(1), 2.0, 1e-3);
// Square matrix
frc::Matrixd<2, 2> mat3 = frc::MakeMatrix<2, 2>(1.0, 2.0, 3.0, 4.0);
EXPECT_NEAR(mat3(0, 0), 1.0, 1e-3);
EXPECT_NEAR(mat3(0, 1), 2.0, 1e-3);
EXPECT_NEAR(mat3(1, 0), 3.0, 1e-3);
EXPECT_NEAR(mat3(1, 1), 4.0, 1e-3);
// Nonsquare matrix with more rows than columns
frc::Matrixd<3, 2> mat4 = frc::MakeMatrix<3, 2>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
EXPECT_NEAR(mat4(0, 0), 1.0, 1e-3);
EXPECT_NEAR(mat4(0, 1), 2.0, 1e-3);
EXPECT_NEAR(mat4(1, 0), 3.0, 1e-3);
EXPECT_NEAR(mat4(1, 1), 4.0, 1e-3);
EXPECT_NEAR(mat4(2, 0), 5.0, 1e-3);
EXPECT_NEAR(mat4(2, 1), 6.0, 1e-3);
// Nonsquare matrix with more columns than rows
frc::Matrixd<2, 3> mat5 = frc::MakeMatrix<2, 3>(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
EXPECT_NEAR(mat5(0, 0), 1.0, 1e-3);
EXPECT_NEAR(mat5(0, 1), 2.0, 1e-3);
EXPECT_NEAR(mat5(0, 2), 3.0, 1e-3);
EXPECT_NEAR(mat5(1, 0), 4.0, 1e-3);
EXPECT_NEAR(mat5(1, 1), 5.0, 1e-3);
EXPECT_NEAR(mat5(1, 2), 6.0, 1e-3);
}
TEST(StateSpaceUtilTest, CostParameterPack) {
frc::Matrixd<3, 3> mat = frc::MakeCostMatrix(1.0, 2.0, 3.0);
EXPECT_NEAR(mat(0, 0), 1.0, 1e-3);