[freecad] 01/02: Fix Sketcher: Solver: FullPivLU::compute for Eigen-3.3. (Closes: #811239)
Anton Gladky
gladk at moszumanska.debian.org
Sun Jan 17 13:05:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
gladk pushed a commit to branch master
in repository freecad.
commit f4d259b2c9db50c38531ba05e85d09108ef512e3
Author: Abdullah Tahiri <abdullah.tahiri.yo at gmail.com>
Date: Sun Jan 17 13:44:28 2016 +0100
Fix Sketcher: Solver: FullPivLU::compute for Eigen-3.3. (Closes: #811239)
---
debian/control | 2 +-
debian/patches/GCS_eigen3.patch | 116 ++++++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 118 insertions(+), 1 deletion(-)
diff --git a/debian/control b/debian/control
index c38bbbf..a6d7ce6 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,7 @@ Build-Depends: cmake,
libboost-thread-dev,
libcoin80-dev,
libcv-dev,
- libeigen3-dev,
+ libeigen3-dev (>= 3.3~beta1),
libf2c2-dev,
libfltk1.3-dev,
libgts-bin,
diff --git a/debian/patches/GCS_eigen3.patch b/debian/patches/GCS_eigen3.patch
new file mode 100644
index 0000000..b1ea878
--- /dev/null
+++ b/debian/patches/GCS_eigen3.patch
@@ -0,0 +1,116 @@
+Description: Sketcher: Solver: FullPivLU::compute for Eigen-3.3
+Author: Abdullah Tahiri <abdullah.tahiri.yo at gmail.com>
+Bug-Debian: https://bugs.debian.org/811239
+Forwarded: https://github.com/FreeCAD/FreeCAD/commit/86f045441468724de9fb45af67b982be26c8a48b
+Reviewed-By: Anton Gladky <gladk at debian.org>
+Last-Update: 2016-01-17
+
+--- freecad-0.15.4671+dfsg1.orig/src/Mod/Sketcher/App/planegcs/GCS.cpp
++++ freecad-0.15.4671+dfsg1/src/Mod/Sketcher/App/planegcs/GCS.cpp
+@@ -39,105 +39,7 @@
+ #include <boost/graph/adjacency_list.hpp>
+ #include <boost/graph/connected_components.hpp>
+
+-// http://forum.freecadweb.org/viewtopic.php?f=3&t=4651&start=40
+-namespace Eigen {
+-
+-typedef Matrix<double,-1,-1,0,-1,-1> MatrixdType;
+-template<>
+-FullPivLU<MatrixdType>& FullPivLU<MatrixdType>::compute(const MatrixdType& matrix)
+-{
+- m_isInitialized = true;
+- m_lu = matrix;
+-
+- const Index size = matrix.diagonalSize();
+- const Index rows = matrix.rows();
+- const Index cols = matrix.cols();
+-
+- // will store the transpositions, before we accumulate them at the end.
+- // can't accumulate on-the-fly because that will be done in reverse order for the rows.
+- m_rowsTranspositions.resize(matrix.rows());
+- m_colsTranspositions.resize(matrix.cols());
+- Index number_of_transpositions = 0; // number of NONTRIVIAL transpositions, i.e. m_rowsTranspositions[i]!=i
+-
+- m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case)
+- m_maxpivot = RealScalar(0);
+- RealScalar cutoff(0);
+-
+- for(Index k = 0; k < size; ++k)
+- {
+- // First, we need to find the pivot.
+-
+- // biggest coefficient in the remaining bottom-right corner (starting at row k, col k)
+- Index row_of_biggest_in_corner, col_of_biggest_in_corner;
+- RealScalar biggest_in_corner;
+- biggest_in_corner = m_lu.bottomRightCorner(rows-k, cols-k)
+- .cwiseAbs()
+- .maxCoeff(&row_of_biggest_in_corner, &col_of_biggest_in_corner);
+- row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner,
+- col_of_biggest_in_corner += k; // need to add k to them.
+-
+- // when k==0, biggest_in_corner is the biggest coeff absolute value in the original matrix
+- if(k == 0) cutoff = biggest_in_corner * NumTraits<Scalar>::epsilon();
+-
+- // if the pivot (hence the corner) is "zero", terminate to avoid generating nan/inf values.
+- // Notice that using an exact comparison (biggest_in_corner==0) here, as Golub-van Loan do in
+- // their pseudo-code, results in numerical instability! The cutoff here has been validated
+- // by running the unit test 'lu' with many repetitions.
+- if(biggest_in_corner < cutoff)
+- {
+- // before exiting, make sure to initialize the still uninitialized transpositions
+- // in a sane state without destroying what we already have.
+- m_nonzero_pivots = k;
+- for(Index i = k; i < size; ++i)
+- {
+- m_rowsTranspositions.coeffRef(i) = i;
+- m_colsTranspositions.coeffRef(i) = i;
+- }
+- break;
+- }
+-
+- if(biggest_in_corner > m_maxpivot) m_maxpivot = biggest_in_corner;
+-
+- // Now that we've found the pivot, we need to apply the row/col swaps to
+- // bring it to the location (k,k).
+-
+- m_rowsTranspositions.coeffRef(k) = row_of_biggest_in_corner;
+- m_colsTranspositions.coeffRef(k) = col_of_biggest_in_corner;
+- if(k != row_of_biggest_in_corner) {
+- m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
+- ++number_of_transpositions;
+- }
+- if(k != col_of_biggest_in_corner) {
+- m_lu.col(k).swap(m_lu.col(col_of_biggest_in_corner));
+- ++number_of_transpositions;
+- }
+-
+- // Now that the pivot is at the right location, we update the remaining
+- // bottom-right corner by Gaussian elimination.
+-
+- if(k<rows-1)
+- m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k);
+- if(k<size-1)
+- m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).tail(rows-k-1) * m_lu.row(k).tail(cols-k-1);
+- }
+-
+- // the main loop is over, we still have to accumulate the transpositions to find the
+- // permutations P and Q
+-
+- m_p.setIdentity(rows);
+- for(Index k = size-1; k >= 0; --k)
+- m_p.applyTranspositionOnTheRight(k, m_rowsTranspositions.coeff(k));
+-
+- m_q.setIdentity(cols);
+- for(Index k = 0; k < size; ++k)
+- m_q.applyTranspositionOnTheRight(k, m_colsTranspositions.coeff(k));
+-
+- m_det_pq = (number_of_transpositions%2) ? -1 : 1;
+- return *this;
+-}
+-
+-} // Eigen
+-
++#define EIGEN_STOCK_FULLPIVLU_COMPUTE
+ namespace GCS
+ {
+
diff --git a/debian/patches/series b/debian/patches/series
index d56b9ea..72036d8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,3 +10,4 @@ gcc5.patch
remove_doc-files.patch
remove_getting_webpage.patch
eigen3.patch
+GCS_eigen3.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/freecad.git
More information about the debian-science-commits
mailing list