[Vegan-commits] r1854 - pkg/vegan/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 16 12:04:20 CEST 2011
Author: jarioksa
Date: 2011-09-16 12:04:20 +0200 (Fri, 16 Sep 2011)
New Revision: 1854
Modified:
pkg/vegan/src/nestedness.c
Log:
swapcount & rswapcount use new isDiag that finds both swappable value & change in fill
Modified: pkg/vegan/src/nestedness.c
===================================================================
--- pkg/vegan/src/nestedness.c 2011-09-16 09:48:48 UTC (rev 1853)
+++ pkg/vegan/src/nestedness.c 2011-09-16 10:04:20 UTC (rev 1854)
@@ -175,7 +175,7 @@
* way. The input is a 2x2 submatrix 'sm'.
*/
-double isDiag(double *sm)
+double isDiagOld(double *sm)
{
int i, sX;
double retval;
@@ -224,7 +224,7 @@
}
}
-double isDiagGot(double *sm, double *got)
+double isDiag(double *sm, int *got)
{
int i, sX;
double retval;
@@ -337,9 +337,9 @@
void swapcount(double *m, int *nr, int *nc, int *thin)
{
- int row[2], col[2], k, ij[4], changed,
+ int row[2], col[2], k, ij[4], changed, got,
pm[4] = {1, -1, -1, 1} ;
- double sm[4], ev, got;
+ double sm[4], ev;
GetRNGstate();
@@ -355,7 +355,7 @@
for (k = 0; k < 4; k ++)
sm[k] = m[ij[k]];
/* The largest value that can be swapped */
- ev = isDiagGot(sm, &got);
+ ev = isDiag(sm, &got);
if (ev != 0 && got == 0) {
/* Swap */
for (k = 0; k < 4; k++)
@@ -401,15 +401,8 @@
for (k = 0; k < 4; k ++)
sm[k] = m[ij[k]];
/* The largest value that can be swapped */
- ev = isDiag(sm);
+ ev = isDiag(sm, &change);
if (ev != 0) {
- /* Check the change in fills */
- for (k = 0, change=0; k < 4; k++) {
- if(sm[k] > 0)
- change--;
- if (sm[k] + pm[k]*ev > 0)
- change++;
- }
/* Fill does not change, but swap to bail out from
* non-swappable configurations */
if (change == 0) {
More information about the Vegan-commits
mailing list