[GRASS-SVN] r66752 - grass-addons/grass7/imagery/i.spec.sam
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Nov 5 11:42:37 PST 2015
Author: ychemin
Date: 2015-11-05 11:42:37 -0800 (Thu, 05 Nov 2015)
New Revision: 66752
Modified:
grass-addons/grass7/imagery/i.spec.sam/main.c
grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
Log:
fixed svd values and equivalent of v_output() replaced
Modified: grass-addons/grass7/imagery/i.spec.sam/main.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/main.c 2015-11-05 18:46:49 UTC (rev 66751)
+++ grass-addons/grass7/imagery/i.spec.sam/main.c 2015-11-05 19:42:37 UTC (rev 66752)
@@ -67,7 +67,6 @@
int row, col;
int band;
int i, j, error=0;
- vec_struct *svd_values; /*la.h defines vec_struct as a typedef mat_struct*/
/*char command[80]; rm by Yann temporarily see grayscale palette*/
float anglefield[255][255];
struct
@@ -126,7 +125,7 @@
if (j !=i)
{
b = G_matvect_get_row(A, j); /* compare with next col in A */
- spectangle = spectral_angle(b, Avector);
+ spectangle = spectral_angle(Avector, b);
anglefield[i][j]= spectangle;
G_vector_free(b);
}
@@ -162,13 +161,24 @@
* using singular value decomposition. IGARSS 1989: 12th Canadian
* symposium on Remote Sensing. Vol.4 pp.2069-2072
*/
- G_message("Singular values of Matrix A:");
- G_math_svdval( (double *) svd_values->vals, (double **) A->vals, A->cols, A->rows);
- if (error)
+ G_message("Singular values ouput vector init");
+ double *svdvalues = G_alloc_vector(A->cols);
+ G_message("Singular values of Matrix A: copy A into double **");
+ double **Avals = G_alloc_matrix(A->cols,A->rows);
+ int count=0;
+ for (i = 0; i < A->cols ; i++){
+ for (j = 0; j < A->rows ; j++){
+ Avals[i][j] = A->vals[count];
+ count++;
+ }
+ }
+ G_message("Singular values of Matrix A: run svdval");
+ if(G_math_svdval( svdvalues, Avals, A->cols, A->rows))
G_fatal_error("Error in singular value decomposition, exiting...\n");
+ G_message("/*Experimental: display values (replace v_output() in original version)*/");
/*Experimental: display values (replace v_output() in original version)*/
- for(i=0;i<svd_values->ldim;i++)
- G_message("%f", svd_values->vals[i]);
+ for(i=0;i<A->cols;i++)
+ G_message("%f", svdvalues[i]);
/* alright, start Spectral angle mapping */
nrows = Rast_window_rows();
Modified: grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/spec_angle.c 2015-11-05 18:46:49 UTC (rev 66751)
+++ grass-addons/grass7/imagery/i.spec.sam/spec_angle.c 2015-11-05 19:42:37 UTC (rev 66752)
@@ -39,15 +39,10 @@
/* multiply one A column with second */
vtmp1 = G_vector_init (Avector1->cols, Avector1->cols, RVEC);
- G_message("sa1");
vtmp1 = G_vector_product(Avector1, Avector2,vtmp1);
- G_message("sa2");
norm1 = G_vector_norm1(vtmp1); /* calculate 1-norm */
- G_message("sa3");
norm2 = G_vector_norm_euclid(Avector1); /* calculate 2-norm (Euclidean) */
- G_message("sa4");
norm3 = G_vector_norm_euclid(Avector2); /* calculate 2-norm (Euclidean) */
- G_message("sa5");
G_vector_free(vtmp1);
More information about the grass-commit
mailing list