mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[upstream_utils] Update Sleipnir (#6709)
Upstream now uses std::format/std::print, so we have to backport it to fmtlib.
This commit is contained in:
@@ -21,8 +21,7 @@ namespace sleipnir::detail {
|
||||
|
||||
struct SLEIPNIR_DLLEXPORT Expression;
|
||||
|
||||
inline constexpr void IntrusiveSharedPtrIncRefCount(Expression* expr);
|
||||
// FIXME: Make constexpr after upgrading to GCC 12+
|
||||
inline void IntrusiveSharedPtrIncRefCount(Expression* expr);
|
||||
inline void IntrusiveSharedPtrDecRefCount(Expression* expr);
|
||||
|
||||
/**
|
||||
@@ -410,7 +409,7 @@ SLEIPNIR_DLLEXPORT inline ExpressionPtr sqrt(const ExpressionPtr& x);
|
||||
*
|
||||
* @param expr The shared pointer's managed object.
|
||||
*/
|
||||
inline constexpr void IntrusiveSharedPtrIncRefCount(Expression* expr) {
|
||||
inline void IntrusiveSharedPtrIncRefCount(Expression* expr) {
|
||||
++expr->refCount;
|
||||
}
|
||||
|
||||
@@ -419,7 +418,6 @@ inline constexpr void IntrusiveSharedPtrIncRefCount(Expression* expr) {
|
||||
*
|
||||
* @param expr The shared pointer's managed object.
|
||||
*/
|
||||
// FIXME: Make constexpr after upgrading to GCC 12+
|
||||
inline void IntrusiveSharedPtrDecRefCount(Expression* expr) {
|
||||
// If a deeply nested tree is being deallocated all at once, calling the
|
||||
// Expression destructor when expr's refcount reaches zero can cause a stack
|
||||
|
||||
@@ -26,6 +26,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Assigns a VariableBlock to the block.
|
||||
*
|
||||
* @param values VariableBlock of values.
|
||||
*/
|
||||
VariableBlock<Mat>& operator=(const VariableBlock<Mat>& values) {
|
||||
if (this == &values) {
|
||||
@@ -56,6 +58,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Assigns a VariableBlock to the block.
|
||||
*
|
||||
* @param values VariableBlock of values.
|
||||
*/
|
||||
VariableBlock<Mat>& operator=(VariableBlock<Mat>&& values) {
|
||||
if (this == &values) {
|
||||
@@ -124,6 +128,8 @@ class VariableBlock {
|
||||
* Assigns a double to the block.
|
||||
*
|
||||
* This only works for blocks with one row and one column.
|
||||
*
|
||||
* @param value Value to assign.
|
||||
*/
|
||||
VariableBlock<Mat>& SetValue(double value) {
|
||||
Assert(Rows() == 1 && Cols() == 1);
|
||||
@@ -135,6 +141,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Assigns an Eigen matrix to the block.
|
||||
*
|
||||
* @param values Eigen matrix of values to assign.
|
||||
*/
|
||||
template <typename Derived>
|
||||
VariableBlock<Mat>& operator=(const Eigen::MatrixBase<Derived>& values) {
|
||||
@@ -152,6 +160,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Sets block's internal values.
|
||||
*
|
||||
* @param values Eigen matrix of values.
|
||||
*/
|
||||
template <typename Derived>
|
||||
requires std::same_as<typename Derived::Scalar, double>
|
||||
@@ -170,6 +180,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Assigns a VariableMatrix to the block.
|
||||
*
|
||||
* @param values VariableMatrix of values.
|
||||
*/
|
||||
VariableBlock<Mat>& operator=(const Mat& values) {
|
||||
Assert(Rows() == values.Rows());
|
||||
@@ -185,6 +197,8 @@ class VariableBlock {
|
||||
|
||||
/**
|
||||
* Assigns a VariableMatrix to the block.
|
||||
*
|
||||
* @param values VariableMatrix of values.
|
||||
*/
|
||||
VariableBlock<Mat>& operator=(Mat&& values) {
|
||||
Assert(Rows() == values.Rows());
|
||||
|
||||
@@ -137,6 +137,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a VariableMatrix from an Eigen matrix.
|
||||
*
|
||||
* @param values Eigen matrix of values.
|
||||
*/
|
||||
template <typename Derived>
|
||||
VariableMatrix(const Eigen::MatrixBase<Derived>& values) // NOLINT
|
||||
@@ -152,6 +154,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a VariableMatrix from an Eigen diagonal matrix.
|
||||
*
|
||||
* @param values Diagonal matrix of values.
|
||||
*/
|
||||
template <typename Derived>
|
||||
VariableMatrix(const Eigen::DiagonalBase<Derived>& values) // NOLINT
|
||||
@@ -171,6 +175,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Assigns an Eigen matrix to a VariableMatrix.
|
||||
*
|
||||
* @param values Eigen matrix of values.
|
||||
*/
|
||||
template <typename Derived>
|
||||
VariableMatrix& operator=(const Eigen::MatrixBase<Derived>& values) {
|
||||
@@ -188,6 +194,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Sets the VariableMatrix's internal values.
|
||||
*
|
||||
* @param values Eigen matrix of values.
|
||||
*/
|
||||
template <typename Derived>
|
||||
requires std::same_as<typename Derived::Scalar, double>
|
||||
@@ -206,6 +214,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a scalar VariableMatrix from a Variable.
|
||||
*
|
||||
* @param variable Variable.
|
||||
*/
|
||||
VariableMatrix(const Variable& variable) // NOLINT
|
||||
: m_rows{1}, m_cols{1} {
|
||||
@@ -214,6 +224,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a scalar VariableMatrix from a Variable.
|
||||
*
|
||||
* @param variable Variable.
|
||||
*/
|
||||
VariableMatrix(Variable&& variable) : m_rows{1}, m_cols{1} { // NOLINT
|
||||
m_storage.emplace_back(std::move(variable));
|
||||
@@ -221,6 +233,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a VariableMatrix from a VariableBlock.
|
||||
*
|
||||
* @param values VariableBlock of values.
|
||||
*/
|
||||
VariableMatrix(const VariableBlock<VariableMatrix>& values) // NOLINT
|
||||
: m_rows{values.Rows()}, m_cols{values.Cols()} {
|
||||
@@ -233,6 +247,8 @@ class SLEIPNIR_DLLEXPORT VariableMatrix {
|
||||
|
||||
/**
|
||||
* Constructs a VariableMatrix from a VariableBlock.
|
||||
*
|
||||
* @param values VariableBlock of values.
|
||||
*/
|
||||
VariableMatrix(const VariableBlock<const VariableMatrix>& values) // NOLINT
|
||||
: m_rows{values.Rows()}, m_cols{values.Cols()} {
|
||||
|
||||
@@ -15,6 +15,10 @@ template <typename T>
|
||||
concept ScalarLike = std::same_as<T, double> || std::same_as<T, int> ||
|
||||
std::same_as<T, Variable>;
|
||||
|
||||
template <typename T>
|
||||
concept SleipnirMatrixLike = std::same_as<T, VariableMatrix> ||
|
||||
std::same_as<T, VariableBlock<VariableMatrix>>;
|
||||
|
||||
template <typename Derived>
|
||||
concept EigenMatrixLike =
|
||||
std::derived_from<Derived, Eigen::MatrixBase<Derived>>;
|
||||
@@ -23,8 +27,6 @@ template <typename T>
|
||||
concept EigenSolver = requires(T t) { t.solve(Eigen::VectorXd{}); };
|
||||
|
||||
template <typename T>
|
||||
concept MatrixLike =
|
||||
std::same_as<T, VariableMatrix> ||
|
||||
std::same_as<T, VariableBlock<VariableMatrix>> || EigenMatrixLike<T>;
|
||||
concept MatrixLike = SleipnirMatrixLike<T> || EigenMatrixLike<T>;
|
||||
|
||||
} // namespace sleipnir
|
||||
|
||||
Reference in New Issue
Block a user