Browse Source

Eigen Patch: Silence a warning regarding unused variable.

tempestpy_adaptions
Tim Quatmann 5 years ago
parent
commit
57e42a16de
  1. 86
      resources/3rdparty/patches/eigen.patch

86
resources/3rdparty/patches/eigen.patch

@ -1,20 +1,18 @@
From 9f1a66bef29005a4cbe178241cad563fcb0dfa5f Mon Sep 17 00:00:00 2001
From 4d2074e54b27877bcd694add91447b569d88e918 Mon Sep 17 00:00:00 2001
From: Tim Quatmann <tim.quatmann@cs.rwth-aachen.de> From: Tim Quatmann <tim.quatmann@cs.rwth-aachen.de>
Date: Mon, 18 May 2020 11:58:47 +0200
Subject: [PATCH 1/2] Adaptions for SparseLU to work with Scalar types that do
not default construct from a double (like CLN numbers) or that do not have an
operator< or std::abs
Date: Wed, 20 May 2020 15:48:43 +0200
Subject: [PATCH] Eigen Patch
--- ---
Eigen/src/SparseLU/SparseLU.h | 10 +-- Eigen/src/SparseLU/SparseLU.h | 10 +--
Eigen/src/SparseLU/SparseLU_column_bmod.h | 2 +- Eigen/src/SparseLU/SparseLU_column_bmod.h | 2 +-
Eigen/src/SparseLU/SparseLU_copy_to_ucol.h | 2 +- Eigen/src/SparseLU/SparseLU_copy_to_ucol.h | 2 +-
Eigen/src/SparseLU/SparseLU_panel_bmod.h | 6 +- Eigen/src/SparseLU/SparseLU_panel_bmod.h | 6 +-
Eigen/src/SparseLU/SparseLU_pivotL.h | 74 +++++++++++++++-------
5 files changed, 62 insertions(+), 32 deletions(-)
Eigen/src/SparseLU/SparseLU_pivotL.h | 79 +++++++++++++++-------
5 files changed, 63 insertions(+), 36 deletions(-)
diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h
index 7104831c0..9aeceb021 100644
index 7104831..9aeceb0 100644
--- a/Eigen/src/SparseLU/SparseLU.h --- a/Eigen/src/SparseLU/SparseLU.h
+++ b/Eigen/src/SparseLU/SparseLU.h +++ b/Eigen/src/SparseLU/SparseLU.h
@@ -97,12 +97,12 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, @@ -97,12 +97,12 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >,
@ -60,7 +58,7 @@ index 7104831c0..9aeceb021 100644
// which are available in the L part :) // which are available in the L part :)
for (Index j = 0; j < this->cols(); ++j) for (Index j = 0; j < this->cols(); ++j)
diff --git a/Eigen/src/SparseLU/SparseLU_column_bmod.h b/Eigen/src/SparseLU/SparseLU_column_bmod.h diff --git a/Eigen/src/SparseLU/SparseLU_column_bmod.h b/Eigen/src/SparseLU/SparseLU_column_bmod.h
index b57f06802..be15e5ee6 100644
index b57f068..be15e5e 100644
--- a/Eigen/src/SparseLU/SparseLU_column_bmod.h --- a/Eigen/src/SparseLU/SparseLU_column_bmod.h
+++ b/Eigen/src/SparseLU/SparseLU_column_bmod.h +++ b/Eigen/src/SparseLU/SparseLU_column_bmod.h
@@ -129,7 +129,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::column_bmod(const Index jcol, const Ind @@ -129,7 +129,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::column_bmod(const Index jcol, const Ind
@ -73,7 +71,7 @@ index b57f06802..be15e5ee6 100644
} }
diff --git a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h diff --git a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h
index c32d8d8b1..03c8aaf85 100644
index c32d8d8..03c8aaf 100644
--- a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h --- a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h
+++ b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +++ b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h
@@ -87,7 +87,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const In @@ -87,7 +87,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const In
@ -86,7 +84,7 @@ index c32d8d8b1..03c8aaf85 100644
isub++; isub++;
} }
diff --git a/Eigen/src/SparseLU/SparseLU_panel_bmod.h b/Eigen/src/SparseLU/SparseLU_panel_bmod.h diff --git a/Eigen/src/SparseLU/SparseLU_panel_bmod.h b/Eigen/src/SparseLU/SparseLU_panel_bmod.h
index 822cf32c3..5dc819cf7 100644
index 822cf32..5dc819c 100644
--- a/Eigen/src/SparseLU/SparseLU_panel_bmod.h --- a/Eigen/src/SparseLU/SparseLU_panel_bmod.h
+++ b/Eigen/src/SparseLU/SparseLU_panel_bmod.h +++ b/Eigen/src/SparseLU/SparseLU_panel_bmod.h
@@ -122,7 +122,7 @@ void SparseLUImpl<Scalar,StorageIndex>::panel_bmod(const Index m, const Index w, @@ -122,7 +122,7 @@ void SparseLUImpl<Scalar,StorageIndex>::panel_bmod(const Index m, const Index w,
@ -117,7 +115,7 @@ index 822cf32c3..5dc819cf7 100644
u_col++; u_col++;
} }
diff --git a/Eigen/src/SparseLU/SparseLU_pivotL.h b/Eigen/src/SparseLU/SparseLU_pivotL.h diff --git a/Eigen/src/SparseLU/SparseLU_pivotL.h b/Eigen/src/SparseLU/SparseLU_pivotL.h
index a86dac93f..2ad56531c 100644
index a86dac9..f1ebd3c 100644
--- a/Eigen/src/SparseLU/SparseLU_pivotL.h --- a/Eigen/src/SparseLU/SparseLU_pivotL.h
+++ b/Eigen/src/SparseLU/SparseLU_pivotL.h +++ b/Eigen/src/SparseLU/SparseLU_pivotL.h
@@ -32,7 +32,46 @@ @@ -32,7 +32,46 @@
@ -125,11 +123,11 @@ index a86dac93f..2ad56531c 100644
namespace Eigen { namespace Eigen {
namespace internal { namespace internal {
- -
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<std::is_same<Scalar, double>::value, int>::type = 0>
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<!std::is_same<Scalar, storm::RationalFunction>::value, int>::type = 0>
+ void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) { + void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) {
+ double rtemp = 0;
+ Scalar rtemp = 0;
+ for (Index isub = nsupc; isub < nsupr; ++isub) { + for (Index isub = nsupc; isub < nsupr; ++isub) {
+ rtemp = std::abs(lu_col_ptr[isub]);
+ rtemp = storm::utility::abs(lu_col_ptr[isub]);
+ if (rtemp > pivmax) { + if (rtemp > pivmax) {
+ pivmax = rtemp; + pivmax = rtemp;
+ pivptr = isub; + pivptr = isub;
@ -138,7 +136,7 @@ index a86dac93f..2ad56531c 100644
+ } + }
+ } + }
+ +
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<!std::is_same<Scalar, double>::value, int>::type = 0>
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<std::is_same<Scalar, storm::RationalFunction>::value, int>::type = 0>
+ void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) { + void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) {
+ bool foundPivotElement = false; + bool foundPivotElement = false;
+ for (Index isub = nsupc; isub < nsupr; ++isub) { + for (Index isub = nsupc; isub < nsupr; ++isub) {
@ -168,7 +166,7 @@ index a86dac93f..2ad56531c 100644
/** /**
* \brief Performs the numerical pivotin on the current column of L, and the CDIV operation. * \brief Performs the numerical pivotin on the current column of L, and the CDIV operation.
* *
@@ -70,26 +109,19 @@ Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScal
@@ -70,42 +109,30 @@ Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScal
StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode
// Determine the largest abs numerical value for partial pivoting // Determine the largest abs numerical value for partial pivoting
@ -205,7 +203,14 @@ index a86dac93f..2ad56531c 100644
perm_r(pivrow) = StorageIndex(jcol); perm_r(pivrow) = StorageIndex(jcol);
return (jcol+1); return (jcol+1);
} }
@@ -103,9 +135,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScal
- RealScalar thresh = diagpivotthresh * pivmax;
-
- // Choose appropriate pivotal element
-
+ // Choose appropriate pivotal element
{
// Test if the diagonal element can be used as a pivot (given the threshold value)
if (diag >= 0 ) if (diag >= 0 )
{ {
// Diagonal element exists // Diagonal element exists
@ -216,7 +221,7 @@ index a86dac93f..2ad56531c 100644
} }
pivrow = lsub_ptr[pivptr]; pivrow = lsub_ptr[pivptr];
} }
@@ -125,7 +155,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScal
@@ -125,7 +152,7 @@ Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScal
} }
} }
// cdiv operations // cdiv operations
@ -226,46 +231,5 @@ index a86dac93f..2ad56531c 100644
lu_col_ptr[k] *= temp; lu_col_ptr[k] *= temp;
return 0; return 0;
-- --
2.24.2 (Apple Git-127)
From 366d73d04bedd7c58fc6b7e96f32a72422ceea89 Mon Sep 17 00:00:00 2001
From: Tim Quatmann <tim.quatmann@cs.rwth-aachen.de>
Date: Tue, 19 May 2020 08:52:28 +0200
Subject: [PATCH 2/2] Fixed actually using largest pivot with rational numbers
---
Eigen/src/SparseLU/SparseLU_pivotL.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Eigen/src/SparseLU/SparseLU_pivotL.h b/Eigen/src/SparseLU/SparseLU_pivotL.h
index 2ad56531c..cc2dd9292 100644
--- a/Eigen/src/SparseLU/SparseLU_pivotL.h
+++ b/Eigen/src/SparseLU/SparseLU_pivotL.h
@@ -32,11 +32,11 @@
namespace Eigen {
namespace internal {
- template<typename Scalar, typename StorageIndex, typename std::enable_if<std::is_same<Scalar, double>::value, int>::type = 0>
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<!std::is_same<Scalar, storm::RationalFunction>::value, int>::type = 0>
void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) {
- double rtemp = 0;
+ Scalar rtemp = 0;
for (Index isub = nsupc; isub < nsupr; ++isub) {
- rtemp = std::abs(lu_col_ptr[isub]);
+ rtemp = storm::utility::abs(lu_col_ptr[isub]);
if (rtemp > pivmax) {
pivmax = rtemp;
pivptr = isub;
@@ -45,7 +45,7 @@ namespace internal {
}
}
- template<typename Scalar, typename StorageIndex, typename std::enable_if<!std::is_same<Scalar, double>::value, int>::type = 0>
+ template<typename Scalar, typename StorageIndex, typename std::enable_if<std::is_same<Scalar, storm::RationalFunction>::value, int>::type = 0>
void findLargestAbsolutePivotElement(const Index& nsupc, const Index& nsupr, Scalar const* lu_col_ptr, StorageIndex const* lsub_ptr, Index const& diagind, Index& diag, Index& pivptr, Scalar& pivmax) {
bool foundPivotElement = false;
for (Index isub = nsupc; isub < nsupr; ++isub) {
--
2.24.2 (Apple Git-127)
2.21.0 (Apple Git-122)
Loading…
Cancel
Save