version 1.47, 2013/12/20 02:02:24 |
version 1.48, 2014/08/19 06:35:01 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.46 2013/11/05 02:55:03 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.47 2013/12/20 02:02:24 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 124 int has_sfcoef_p(P f) |
|
Line 124 int has_sfcoef_p(P f) |
|
} |
} |
} |
} |
|
|
extern N *current_top_weight_vector; |
extern Obj current_top_weight; |
static int current_top_weight_len; |
int current_top_weight_len; |
|
|
void initd(struct order_spec *spec) |
void initd(struct order_spec *spec) |
{ |
{ |
int len,i; |
int len,i,k,row; |
|
Q **mat; |
|
|
switch ( spec->id ) { |
switch ( spec->id ) { |
case 3: |
case 3: |
Line 176 void initd(struct order_spec *spec) |
|
Line 177 void initd(struct order_spec *spec) |
|
} |
} |
break; |
break; |
} |
} |
if ( current_top_weight_vector ) { |
if ( current_top_weight ) { |
cmpdl_tie_breaker = cmpdl; |
cmpdl_tie_breaker = cmpdl; |
cmpdl = cmpdl_top_weight; |
cmpdl = cmpdl_top_weight; |
for ( len = 0, i = 0; i < spec->nv; i++ ) |
if ( OID(current_top_weight) == O_VECT ) { |
if ( current_top_weight_vector[i] ) |
mat = (Q **)&BDY((MAT)current_top_weight); |
len = MAX(PL(current_top_weight_vector[i]),len); |
row = 1; |
|
} else { |
|
mat = (Q **)BDY((MAT)current_top_weight); |
|
row = ((MAT)current_top_weight)->row; |
|
} |
|
for ( k = 0, len = 0; k < row; k++ ) |
|
for ( i = 0; i < spec->nv; i++ ) |
|
if ( mat[k][i] ) |
|
len = MAX(PL(NM(mat[k][i])),len); |
current_top_weight_len = len; |
current_top_weight_len = len; |
} |
} |
dp_current_spec = spec; |
dp_current_spec = spec; |
Line 1656 int cmpdl_top_weight(int n,DL d1,DL d2) |
|
Line 1665 int cmpdl_top_weight(int n,DL d1,DL d2) |
|
{ |
{ |
int *w; |
int *w; |
N sum,wm,wma,t; |
N sum,wm,wma,t; |
N *a; |
Q **mat; |
|
Q *a; |
struct oN tn; |
struct oN tn; |
int len,i,sgn,tsgn; |
int len,i,sgn,tsgn,row,k; |
int *t1,*t2; |
int *t1,*t2; |
|
|
w = (int *)ALLOCA(n*sizeof(int)); |
w = (int *)ALLOCA(n*sizeof(int)); |
Line 1668 int cmpdl_top_weight(int n,DL d1,DL d2) |
|
Line 1678 int cmpdl_top_weight(int n,DL d1,DL d2) |
|
sum = (N)W_ALLOC(len); sgn = 0; |
sum = (N)W_ALLOC(len); sgn = 0; |
wm = (N)W_ALLOC(len); |
wm = (N)W_ALLOC(len); |
wma = (N)W_ALLOC(len); |
wma = (N)W_ALLOC(len); |
a = current_top_weight_vector; |
if ( OID(current_top_weight) == O_VECT ) { |
for ( i = 0; i < n; i++ ) { |
mat = (Q **)&BDY((VECT)current_top_weight); |
if ( !a[i] || !w[i] ) continue; |
row = 1; |
tn.p = 1; |
} else { |
if ( w[i] > 0 ) { |
mat = (Q **)BDY((MAT)current_top_weight); |
tn.b[0] = w[i]; tsgn = 1; |
row = ((MAT)current_top_weight)->row; |
} else { |
|
tn.b[0] = -w[i]; tsgn = -1; |
|
} |
|
_muln(a[i],&tn,wm); |
|
if ( !sgn ) { |
|
sgn = tsgn; |
|
t = wm; wm = sum; sum = t; |
|
} else if ( sgn == tsgn ) { |
|
_addn(sum,wm,wma); |
|
if ( !PL(wma) ) |
|
sgn = 0; |
|
t = wma; wma = sum; sum = t; |
|
} else { |
|
sgn *= _subn(sum,wm,wma); |
|
t = wma; wma = sum; sum = t; |
|
} |
|
} |
} |
if ( sgn > 0 ) return 1; |
for ( k = 0; k < row; k++ ) { |
else if ( sgn < 0 ) return -1; |
a = mat[k]; |
else return (*cmpdl_tie_breaker)(n,d1,d2); |
for ( i = 0; i < n; i++ ) { |
|
if ( !a[i] || !w[i] ) continue; |
|
tn.p = 1; |
|
if ( w[i] > 0 ) { |
|
tn.b[0] = w[i]; tsgn = 1; |
|
} else { |
|
tn.b[0] = -w[i]; tsgn = -1; |
|
} |
|
_muln(NM(a[i]),&tn,wm); |
|
if ( !sgn ) { |
|
sgn = tsgn; |
|
t = wm; wm = sum; sum = t; |
|
} else if ( sgn == tsgn ) { |
|
_addn(sum,wm,wma); |
|
if ( !PL(wma) ) |
|
sgn = 0; |
|
t = wma; wma = sum; sum = t; |
|
} else { |
|
sgn *= _subn(sum,wm,wma); |
|
t = wma; wma = sum; sum = t; |
|
} |
|
} |
|
if ( sgn > 0 ) return 1; |
|
else if ( sgn < 0 ) return -1; |
|
} |
|
return (*cmpdl_tie_breaker)(n,d1,d2); |
} |
} |
|
|
GeoBucket create_bucket() |
GeoBucket create_bucket() |