From jsmpereira at gmail.com Fri Mar 15 09:59:41 2013 From: jsmpereira at gmail.com (=?ISO-8859-1?Q?Jos=E9_Santos?=) Date: Fri, 15 Mar 2013 09:59:41 +0000 Subject: [lisplab-devel] Eigenvalues Message-ID: Hi, After trying out GSLL, Clem, also FemLisp, Lisplab managed to get me the functionality I needed with the least trouble. I'm trying to get the connectivity of a graph (second smallest eigen value) from eigenvalues. Given the fully connected 4x4 adjacency matrix: #md(( 0.000 1.000 1.000 1.000 ) ( 1.000 0.000 1.000 1.000 ) ( 1.000 1.000 0.000 1.000 ) ( 1.000 1.000 1.000 0.000 )) I compute the diagonal matrix of the vector sum of the adjacency matrix and then subtract the adjacency matrix from it to get the laplacian matrix. I'm unable to call (lisplab:eigenvalues) on that matrix, despite being a #md matrix. I can see that the function calls for LISPLAB::MATRIX-FOREIGN-DGE. However other functions that call for the same type seem to work when called with #md, namely FFT1. As a workaround, I'm using this call to get the eigenvalues: (lisplab::dgeev (laplacian-matrix *adj-matrix* *diag-matrix*) nil nil) and I get: ( #md(( 4.000 ) (-1.1102d-16) ( 4.000 ) ( 4.000 )) NIL NIL) Is this appropriate? I'm curious however about different results I get from Matlab. I get the same results up until the call to >> eig(diag(sum(A)) - A) which gives me ans = 0.0000 4.0000 4.0000 4.0000 Any comment I can get on this would be awsome. Am I going about this right? What might I be missing? Sorry about the lengthy email. Thanks! Jos? Santos -------------- next part -------------- An HTML attachment was scrubbed... URL: From jivestgarden at gmail.com Tue Mar 19 19:58:59 2013 From: jivestgarden at gmail.com (=?ISO-8859-1?Q?J=F8rn_Inge_Vestg=E5rden?=) Date: Tue, 19 Mar 2013 20:58:59 +0100 Subject: [lisplab-devel] Eigenvalues In-Reply-To: References: Message-ID: Dear Jos? Santos What you describe looks like a bug in lisplab since eigenvalues should basically just call dgeev. The reason for for the bug is probably that lisplab has some functionality to switch between native and foreign implementations when both are present. In the case of eigenvalues, there is no native lisp implementation, but it might be that it thinks that it exists. The matlisp code is, as the name implies, basically taken from Matlisp. Unfortunately I have not put much emphasis on testing it and making high-level interface functions. Hence it is prone to get bugs. Best Regards J?rn Inge Vestg?rden 2013/3/15 Jos? Santos > Hi, > > After trying out GSLL, Clem, also FemLisp, Lisplab managed to get me > the functionality I needed with the least trouble. > > I'm trying to get the connectivity of a graph (second smallest eigen > value) from eigenvalues. > > Given the fully connected 4x4 adjacency matrix: > > #md(( 0.000 1.000 1.000 1.000 ) > ( 1.000 0.000 1.000 1.000 ) > ( 1.000 1.000 0.000 1.000 ) > ( 1.000 1.000 1.000 0.000 )) > > I compute the diagonal matrix of the vector sum of the adjacency matrix > and then > subtract the adjacency matrix from it to get the laplacian matrix. > > I'm unable to call (lisplab:eigenvalues) on that matrix, despite being a > #md matrix. > I can see that the function calls for LISPLAB::MATRIX-FOREIGN-DGE. However > other functions > that call for the same type seem to work when called with #md, namely FFT1. > > As a workaround, I'm using this call to get the eigenvalues: > > (lisplab::dgeev (laplacian-matrix *adj-matrix* *diag-matrix*) nil nil) and > I get: > > ( > #md(( 4.000 ) > (-1.1102d-16) > ( 4.000 ) > ( 4.000 )) > NIL NIL) > > Is this appropriate? > > I'm curious however about different results I get from Matlab. > I get the same results up until the call to > > >> eig(diag(sum(A)) - A) > > which gives me > > ans = > > 0.0000 > 4.0000 > 4.0000 > 4.0000 > > Any comment I can get on this would be awsome. Am I going about this right? > What might I be missing? > > Sorry about the lengthy email. > > Thanks! > Jos? Santos > > _______________________________________________ > lisplab-devel mailing list > lisplab-devel at common-lisp.net > http://lists.common-lisp.net/cgi-bin/mailman/listinfo/lisplab-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsmpereira at gmail.com Wed Mar 20 10:23:37 2013 From: jsmpereira at gmail.com (=?ISO-8859-1?Q?Jos=E9_Santos?=) Date: Wed, 20 Mar 2013 10:23:37 +0000 Subject: [lisplab-devel] Eigenvalues In-Reply-To: References: Message-ID: Hi J?rn, Thanks for the reply. After some more trial and error and Matlab vs Lisplab output, I managed to identify the value I'm interested in: the last in the Lisplab return value, which consistently matches the second value in the Matlab array. Thanks again. Sincerely, Jos? Santos On Tue, Mar 19, 2013 at 7:58 PM, J?rn Inge Vestg?rden < jivestgarden at gmail.com> wrote: > Dear Jos? Santos > What you describe looks like a bug in lisplab since eigenvalues should > basically just call dgeev. > > The reason for for the bug is probably that lisplab has some functionality > to switch between native and foreign implementations when both are present. > In the case of eigenvalues, there is no native lisp implementation, but it > might be that it thinks that it exists. > > The matlisp code is, as the name implies, basically taken from Matlisp. > Unfortunately I have not put much emphasis on testing it and making > high-level interface functions. Hence it is prone to get bugs. > > Best Regards > J?rn Inge Vestg?rden > > > > 2013/3/15 Jos? Santos > >> Hi, >> >> After trying out GSLL, Clem, also FemLisp, Lisplab managed to get me >> the functionality I needed with the least trouble. >> >> I'm trying to get the connectivity of a graph (second smallest eigen >> value) from eigenvalues. >> >> Given the fully connected 4x4 adjacency matrix: >> >> #md(( 0.000 1.000 1.000 1.000 ) >> ( 1.000 0.000 1.000 1.000 ) >> ( 1.000 1.000 0.000 1.000 ) >> ( 1.000 1.000 1.000 0.000 )) >> >> I compute the diagonal matrix of the vector sum of the adjacency matrix >> and then >> subtract the adjacency matrix from it to get the laplacian matrix. >> >> I'm unable to call (lisplab:eigenvalues) on that matrix, despite being a >> #md matrix. >> I can see that the function calls for LISPLAB::MATRIX-FOREIGN-DGE. >> However other functions >> that call for the same type seem to work when called with #md, namely >> FFT1. >> >> As a workaround, I'm using this call to get the eigenvalues: >> >> (lisplab::dgeev (laplacian-matrix *adj-matrix* *diag-matrix*) nil nil) >> and I get: >> >> ( >> #md(( 4.000 ) >> (-1.1102d-16) >> ( 4.000 ) >> ( 4.000 )) >> NIL NIL) >> >> Is this appropriate? >> >> I'm curious however about different results I get from Matlab. >> I get the same results up until the call to >> >> >> eig(diag(sum(A)) - A) >> >> which gives me >> >> ans = >> >> 0.0000 >> 4.0000 >> 4.0000 >> 4.0000 >> >> Any comment I can get on this would be awsome. Am I going about this >> right? >> What might I be missing? >> >> Sorry about the lengthy email. >> >> Thanks! >> Jos? Santos >> >> _______________________________________________ >> lisplab-devel mailing list >> lisplab-devel at common-lisp.net >> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/lisplab-devel >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: