[GRASS-dev] Re: i.cca eigenvector computation strangeness
Soeren Gebbert
soerengebbert at googlemail.com
Mon Aug 17 15:51:59 EDT 2009
Sorry, i have send accidentally an unfinished mail, so sorry for the typing
errors.
I intended to push the save button ... .
The rest of the mail is attached below.
2009/8/17 Soeren Gebbert <soerengebbert at googlemail.com>
> Hi,
> while including the ccmath library into grass and
> patching i.cca to use the new ccmath library eigen vector functions,
> i noticed, that the eigen vector computation of the original i.cca version
> differs from the expected values?
>
> First, the i.cca code looks wired. Like Fortran code ported to C while
> keeping the
> fortran style of counting (starting from 1). I removed the Fortran coding
> style and replaced
> the eigen vector computaion function from lib/gmath/jacobi.c with a ccmath
> version.
> As a side effect: it is now possible to compute a cca of subgroups of size
> much larger than 8.
>
> I verified the new eigen vector computation of i.cca (the ccmath version)
> with octave, so
> octave and i.cca computing now the same eigen vectors for a given matrix.
> But this eigen vectors differ from the original version of i.cca. The
> difference is in the
> sign of the vectors. And therefore the results of i.cca are looking
> different.
>
> Example:
>
> The following steps are made with the original and the ccmath version of
> i.cca:
>
> i.group group=LandSat
> input=LandsatTM_Blue,LandsatTM_Green,LandsatTM_IR1,LandsatTM_IR2,LandsatTM_IR3,LandsatTM_Red
> i.group group=LandSat subgroup=visible
> input=LandsatTM_Blue,LandsatTM_Green,LandsatTM_Red
> i.cluster group=LandSat subgroup=visible sigfile=sig.txt classes=4
> i.cca --v group=LandSat subgroup=visible signature=sig.txt output=test_cca
> r.info -r test_cca.1
> r.info -r test_cca.2
> r.info -r test_cca.3
>
Result of original i.cca:
...
1. eigen value: 12265.2 -- eigen vector: 0.159569 0.389926 -0.906915
2. eigen value: 308.024 -- eigen vector: -0.154224 -0.89756 -0.413039
3. eigen value: -1.29363e+06 -- eigen vector: -0.975065 0.205776 -0.0830864
Transform completed.
WARNING: The output cell map <test_cca.1> has values outside the 0-255
range.
WARNING: The output cell map <test_cca.2> has values outside the 0-255
range.
WARNING: The output cell map <test_cca.3> has values outside the 0-255
range.
r.info -r test_cca.1
min=-16
max=8
r.info -r test_cca.2
min=-32
max=0
r.info -r test_cca.3
min=-23
max=-3
Results of the new ccmath version:
...
1. eigen value: 12265.2 -- eigen vector: -0.159569 -0.389926 0.906915
2. eigen value: 308.024 -- eigen vector: 0.154224 0.89756 0.413039
3. eigen value: -1.29363e+06 -- eigen vector: 0.975065 -0.205776 0.0830864
Transform completed.
WARNING: The output cell map <test_cca.1> has values outside the 0-255
range.
r.info -r test_cca.1
min=-7
max=17
r.info -r test_cca.2
min=0
max=33
r.info -r test_cca.3
min=4
max=24
The difference is in the sign of the eigen vectors which results in
different raster map values.
I have verified every step between the old and the new version of i.cca. The
difference is only in the eigen vector computation.
So the big question is ... which result is correct???
The new one looks more reasonable to me, but well this is only one example
... .
Do i have found a bug in the numerical recipes eigen vector code, or is the
sign of eigen vectors not fixed and changes with the chosen algorithm?
Can i commit such changes to svn?
Any suggestions are welcome.
Best regards
Soeren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-dev/attachments/20090817/4f69fbb0/attachment.html
More information about the grass-dev
mailing list