aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Chen-Pang He <jdh8@ms63.hinet.net>2013-07-21 01:00:36 +0800
committerGravatar Chen-Pang He <jdh8@ms63.hinet.net>2013-07-21 01:00:36 +0800
commit51573da3a4407288b900e8764e20de4fc09018d3 (patch)
treea5a2f49243092de4ae75a83d6ba5444041f3f290
parent1191949e8725106035d0f7276857217585a115ef (diff)
Warn about power of a matrix with non-semisimple 0 eigenvalue.
-rw-r--r--unsupported/Eigen/MatrixFunctions4
-rw-r--r--unsupported/doc/examples/MatrixPower_failure.cpp20
2 files changed, 24 insertions, 0 deletions
diff --git a/unsupported/Eigen/MatrixFunctions b/unsupported/Eigen/MatrixFunctions
index 41dfab390..ff466a519 100644
--- a/unsupported/Eigen/MatrixFunctions
+++ b/unsupported/Eigen/MatrixFunctions
@@ -262,6 +262,10 @@ where \f$ T_1 \f$ is invertible. Then \f$ T^p \f$ is given by
0 & 0
\end{array}. \right] \f]
+\warning Fractional power of a matrix with a non-semisimple zero
+eigenvalue is not well-defined. We introduce an assertion failure
+against inaccurate result, e.g. \include MatrixPower_failure.cpp
+
Details of the algorithm can be found in: Nicholas J. Higham and
Lijing Lin, "A Schur-Pad&eacute; algorithm for fractional powers of a
matrix," <em>SIAM J. %Matrix Anal. Applic.</em>,
diff --git a/unsupported/doc/examples/MatrixPower_failure.cpp b/unsupported/doc/examples/MatrixPower_failure.cpp
new file mode 100644
index 000000000..d20de78a0
--- /dev/null
+++ b/unsupported/doc/examples/MatrixPower_failure.cpp
@@ -0,0 +1,20 @@
+#include <unsupported/Eigen/MatrixFunctions>
+#include <iostream>
+
+int main()
+{
+ Eigen::Matrix4d A;
+ A << 0, 0, 2, 3,
+ 0, 0, 4, 5,
+ 0, 0, 6, 7,
+ 0, 0, 8, 9;
+ std::cout << A.pow(0.37) << std::endl;
+
+ // The 1 makes eigenvalue 0 non-semisimple.
+ A.coeffRef(0, 1) = 1;
+
+ // This fails if EIGEN_NO_DEBUG is undefined.
+ std::cout << A.pow(0.37) << std::endl;
+
+ return 0;
+}