Does this help? https://lists.gnu.org/archive/html/help-gsl/2005-02/msg00012.html
If you get an error or a zero, the matrix cannot be inverted. Maybe you are asking "Isn't there a simpler way?" and I think the answer is "No." I can look at your matrix and see that it does not have full rank because columns 0 and 1 are perfectly correlated. But the condition that must apply to have full rank is more complex: No linear combination of columns can be perfectly correlated with any other linear combination. That's not hard to test with a 3x3 matrix, but it becomes impractical with a larger matrix. You could compute correlations between all pairs of columns and if any correlation is 1.0 then the matrix does not have full rank (and if it's very close to 1.0, then you will have stability issues). But there are matricies that will pass that test that do not have full rank. So that test is probably somewhat cheaper computationally, but has a known false negative rate and is not a good test. -Alan On 1/19/2021 4:05 PM, Patrick Dupre wrote: > This is perfectly correct. > > My question is how do I detect singular matrix since > gsl_eigen_nonsymmv > does not do it? > > >> Your matrix is singular (the first two columns are perfectly correlated, >> so your matrix does not have full rank). >> >> The standard test of singularity is that the determinant cannot be >> computed (you try to calculate it, and you get zero or a numerical >> error). This post describes the problem and a shortcut: >> >> https://stackoverflow.com/questions/13145948/how-to-find-out-if-a-matrix-is-singular >> >> -Alan >> >> >> On 1/19/2021 2:51 PM, Patrick Dupre wrote: >>> gsl_eigen_nonsymmv_workspace >>> has no member n_evals >>> >>> issue: >>> >>> Diagonalizing >>> double data_3 [] = { 0.0, 0.0, 1.0, >>> 0.0, 0.0, 0.0, >>> 0.0, 0.0, 0.0 } ; >>> >>> I get >>> eigenvalue = 0 +0i >>> eigenvector = >>> 1 +0i >>> 0 +0i >>> 0 +0i >>> eigenvalue = 0 +0i >>> eigenvector = >>> 0 +0i >>> 1 +0i >>> 0 +0i >>> eigenvalue = 0 +0i >>> eigenvector = >>> -1 +0i >>> 0 +0i >>> 3.00625e-292 +0i >>> >>> >>> which is wrong. >>> The last eigenvector is not correct because this matrix is not >>> diagonalizable. >>> >>> I need to identify such matrices. >>> >>> >>> =========================================================================== >>> Patrick DUPRÉ | | email: pdu...@gmx.com >>> Laboratoire interdisciplinaire Carnot de Bourgogne >>> 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE >>> Tel: +33 (0)380395988 >>> =========================================================================== >>> >>> >>>> Sent: Tuesday, January 19, 2021 at 6:56 PM >>>> From: "Patrick Alken" <patrick.al...@colorado.edu> >>>> To: help-gsl@gnu.org >>>> Subject: Re: eigensystem >>>> >>>> What do you mean by handle it? According to the documentation, if the >>>> function cannot compute all eigenvalues, an error code is returned. In >>>> the case of gsl_eigen_nonsymm, the number of converged eigenvalues is >>>> stored in w->n_evals. >>>> >>>> Patrick >>>> >>>> On 1/19/21 10:33 AM, Patrick Dupre wrote: >>>>> Hello, >>>>> >>>>> Is there a way to handle the possible error of gsl_eigen_nonsymmv ? >>>>> >>>>> For example, when the matrix is not diagonalizable. >>>>> >>>>> Thanks >>>>> >>>>> =========================================================================== >>>>> Patrick DUPRÉ | | email: pdu...@gmx.com >>>>> Laboratoire interdisciplinaire Carnot de Bourgogne >>>>> 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE >>>>> Tel: +33 (0)380395988 >>>>> =========================================================================== >>>>> >>>>> >>>> >> -- >> >> Alan D. Mead, Ph.D. >> President, Talent Algorithms Inc. >> >> science + technology = better workers >> >> http://www.alanmead.org >> >> The irony of this ... is that the Internet is >> both almost-infinitely expandable, while at the >> same time constrained within its own pre-defined >> box. And if that makes no sense to you, just >> reflect on the existence of Facebook. We have >> the vastness of the internet and yet billions >> of people decided to spend most of them time >> within a horribly designed, fake-news emporium >> of a website that sucks every possible piece of >> personal information out of you so it can sell it >> to others. And they see nothing wrong with that. >> >> -- Kieren McCarthy, commenting on why we are not >> all using IPv6 >> >> -- Alan D. Mead, Ph.D. President, Talent Algorithms Inc. science + technology = better workers http://www.alanmead.org The irony of this ... is that the Internet is both almost-infinitely expandable, while at the same time constrained within its own pre-defined box. And if that makes no sense to you, just reflect on the existence of Facebook. We have the vastness of the internet and yet billions of people decided to spend most of them time within a horribly designed, fake-news emporium of a website that sucks every possible piece of personal information out of you so it can sell it to others. And they see nothing wrong with that. -- Kieren McCarthy, commenting on why we are not all using IPv6