Hot answers tagged

6

No, in the general case, there is no suitable workaround. C++ is a statically typed language, and the compiler needs to know all types at compilation time. If your code worked, the following would also const size_t n = std::rand(); Eigen::Matrix<double, n, n> A; and rand() only gives a random number at run-time, which, at compile-time is unknown. ...


5

The other answers already tell you what went wrong, but I will add a terminology note: the term for what is happening is that the pencil $A - \lambda B$ is a singular matrix pencil, i.e., $\det (A - \lambda B)$ is identically equal to zero. So there are no generalized eigenvalues (or, at least, they cannot be defined as usual as the roots of the generalized ...


4

Certainly. There are a few things you have to define for your type that are listed on this page in the documentation: https://eigen.tuxfamily.org/dox/TopicCustomizing_CustomScalar.html It basically boils down to defining arithmetic operators appropriately for your type, plus specializing a traits template NumTraits that describes your type. The link above ...


3

I suspect the root of your trouble is what has been detected in the comments by Vibe: For any number $\omega\in \mathbb{K}$ (with $\mathbb{K}= \mathbb{R}$ or $\mathbb{C}$) you can find $\boldsymbol{X}$ such that $AX = \omega BX$ (with $A$ and $B$ taken in your concrete example). You have already decomposed the problem in 4 blocks of 3 variables. Then let us ...


3

As others have mentioned in comments, solving $A^TAx=A^Tb$ (the so-called least-norm solution) can be performed without explicitly forming $A^TA$ with the QR decomposition. It works like this: $$A=QR$$ where $Q$ has the interesting properties that $Q^TQ=I$ and $R$ is square and triangular. Using this information, the least squares system $A^TAx=A^Tb$ is ...


1

As its documentation suggests in multiple places, rref is "mainly of academic interest" (read: "used only to explain Gaussian elimination to undergrads"), and is not a serious competitor of SVD-based algorithms in terms of stability. I recommend against it.


1

I get it. template <typename Number> // e.g. double or complex Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic> image_COD( const Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic>& M) { Eigen::CompleteOrthogonalDecomposition< Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic>> cod(M); const Eigen::...


1

EDIT: I just noticed a glitch in your code. You used selfadjoint and triangular. Try this: L.triangularView<Lower>().transpose().solve(b); The rest of my answer may still be useful, so I won't delete it. Presumably, $L$ uses the column-major storage order. If not, just swap row for column everywhere in this post. $L^T$ can be represented by casting $L$...


Only top voted, non community-wiki answers of a minimum length are eligible