[BACK]Return to dist.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / engine

Diff for /OpenXM_contrib2/asir2000/engine/dist.c between version 1.27 and 1.28

version 1.27, 2004/02/03 23:31:57 version 1.28, 2004/02/05 08:28:53
Line 45 
Line 45 
  * 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.26 2003/08/22 08:14:45 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.27 2004/02/03 23:31:57 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
   
Line 111  int has_sfcoef_p(P f)
Line 111  int has_sfcoef_p(P f)
 void initd(struct order_spec *spec)  void initd(struct order_spec *spec)
 {  {
         switch ( spec->id ) {          switch ( spec->id ) {
                   case 3:
                           cmpdl = cmpdl_composite;
                           dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int));
                           break;
                 case 2:                  case 2:
                         cmpdl = cmpdl_matrix;                          cmpdl = cmpdl_matrix;
                         dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int));                          dp_dl_work = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int));
Line 1513  int cmpdl_order_pair(int n,DL d1,DL d2)
Line 1517  int cmpdl_order_pair(int n,DL d1,DL d2)
                                 error("cmpdl_order_pair : invalid order"); break;                                  error("cmpdl_order_pair : invalid order"); break;
                 }                  }
                 t1 += l; t2 += l; head += l;                  t1 += l; t2 += l; head += l;
           }
           return 0;
   }
   
   int cmpdl_composite(int nv,DL d1,DL d2)
   {
           int n,i,j,k,start,s,len;
           int *dw;
           struct sparse_weight *sw;
           struct weight_or_block *worb;
           int *w,*t1,*t2;
   
           n = dp_current_spec->ord.composite.length;
           worb = dp_current_spec->ord.composite.w_or_b;
           w = dp_dl_work;
           for ( i = 0, t1 = d1->d, t2 = d2->d; i < nv; i++ )
                   w[i] = t1[i]-t2[i];
           for ( i = 0; i < n; i++, worb++ ) {
                   len = worb->length;
                   switch ( worb->type ) {
                           case IS_DENSE_WEIGHT:
                                   dw = worb->body.dense_weight;
                                   for ( j = 0, s = 0; j < len; j++ )
                                           s += dw[j]*w[j];
                                   if ( s > 0 ) return 1;
                                   else if ( s < 0 ) return -1;
                                   break;
                           case IS_SPARSE_WEIGHT:
                                   sw = worb->body.sparse_weight;
                                   for ( j = 0, s = 0; j < len; j++ )
                                           s += sw[j].value*w[sw[j].pos];
                                   if ( s > 0 ) return 1;
                                   else if ( s < 0 ) return -1;
                                   break;
                           case IS_BLOCK:
                                   start = worb->body.block.start;
                                   switch ( worb->body.block.order ) {
                                           case 0:
                                                   for ( j = 0, k = start, s = 0; j < len; j++, k++ ) {
                                                           s += MUL_WEIGHT(w[k],k);
                                                   }
                                                   if ( s > 0 ) return 1;
                                                   else if ( s < 0 ) return -1;
                                                   else {
                                                           for ( j = k-1; j >= start && w[j] == 0; j-- );
                                                           if ( j >= start )
                                                                   return w[j] < 0 ? 1 : -1;
                                                   }
                                                   break;
                                           case 1:
                                                   for ( j = 0, k = start, s = 0; j < len; j++, k++ ) {
                                                           s += MUL_WEIGHT(w[k],k);
                                                   }
                                                   if ( s > 0 ) return 1;
                                                   else if ( s < 0 ) return -1;
                                                   else {
                                                           for ( j = 0, k = start;  j < len && w[j] == 0; j++, k++ );
                                                           if ( j < len )
                                                                   return w[j] > 0 ? 1 : -1;
                                                   }
                                                   break;
                                           case 2:
                                                   for ( j = 0, k = start;  j < len && w[j] == 0; j++, k++ );
                                                   if ( j < len )
                                                           return w[j] > 0 ? 1 : -1;
                                                   break;
                                   }
                                   break;
                   }
         }          }
         return 0;          return 0;
 }  }

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>