[BACK]Return to dp-supp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Diff for /OpenXM_contrib2/asir2000/builtin/dp-supp.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/builtin/dp-supp.c,v 1.26 2003/11/27 07:53:53 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/builtin/dp-supp.c,v 1.27 2004/02/03 23:31:57 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "base.h"  #include "base.h"
Line 1359  int create_order_spec(VL vl,Obj obj,struct order_spec 
Line 1359  int create_order_spec(VL vl,Obj obj,struct order_spec 
                 return 0;                  return 0;
 }  }
   
   void print_composite_order_spec(struct order_spec *spec)
   {
           int nv,n,len,i,j,k,start;
           struct weight_or_block *worb;
   
           nv = spec->nv;
           n = spec->ord.composite.length;
           worb = spec->ord.composite.w_or_b;
           for ( i = 0; i < n; i++, worb++ ) {
                   len = worb->length;
                   printf("[ ");
                   switch ( worb->type ) {
                           case IS_DENSE_WEIGHT:
                                   for ( j = 0; j < len; j++ )
                                           printf("%d ",worb->body.dense_weight[j]);
                                   for ( ; j < nv; j++ )
                                           printf("0 ");
                                   break;
                           case IS_SPARSE_WEIGHT:
                                   for ( j = 0, k = 0; j < nv; j++ )
                                           if ( j == worb->body.sparse_weight[k].pos )
                                                   printf("%d ",worb->body.sparse_weight[k++].value);
                                           else
                                                   printf("0 ");
                                   break;
                           case IS_BLOCK:
                                   start = worb->body.block.start;
                                   for ( j = 0; j < start; j++ ) printf("0 ");
                                   switch ( worb->body.block.order ) {
                                           case 0:
                                                   for ( k = 0; k < len; k++, j++ ) printf("R ");
                                                   break;
                                           case 1:
                                                   for ( k = 0; k < len; k++, j++ ) printf("G ");
                                                   break;
                                           case 2:
                                                   for ( k = 0; k < len; k++, j++ ) printf("L ");
                                                   break;
                                   }
                                   for ( ; j < nv; j++ ) printf("0 ");
                                   break;
                   }
                   printf("]\n");
           }
   }
   
 /* order = [w_or_b, w_or_b, ... ] */  /* order = [w_or_b, w_or_b, ... ] */
 /* w_or_b = w or b                */  /* w_or_b = w or b                */
 /* w = [1,2,...] or [x,1,y,2,...] */  /* w = [1,2,...] or [x,1,y,2,...] */
Line 1376  int create_composite_order_spec(VL vl,LIST order,struc
Line 1422  int create_composite_order_spec(VL vl,LIST order,struc
         Obj a0;          Obj a0;
         NODE a;          NODE a;
         V v;          V v;
           Symbol sym;
           int start;
   
         /* l = number of vars in vl */          /* l = number of vars in vl */
         for ( l = 0, tvl = vl; tvl; tvl = NEXT(tvl), l++ );          for ( l = 0, tvl = vl; tvl; tvl = NEXT(tvl), l++ );
Line 1387  int create_composite_order_spec(VL vl,LIST order,struc
Line 1435  int create_composite_order_spec(VL vl,LIST order,struc
         spec->obj = (Obj)order;          spec->obj = (Obj)order;
         spec->nv = l;          spec->nv = l;
         spec->ord.composite.length = n;          spec->ord.composite.length = n;
         spec->ord.composite.w_or_b = (struct weight_or_block *)          w_or_b = spec->ord.composite.w_or_b = (struct weight_or_block *)
                 MALLOC(sizeof(struct weight_or_block)*n);                  MALLOC(sizeof(struct weight_or_block)*n);
         for ( t = wb, i = 0; t; t = NEXT(t) ) {          for ( t = wb, i = 0; t; t = NEXT(t), i++ ) {
                 a = BDY((LIST)BDY(wb));                  a = BDY((LIST)BDY(t));
                 len = length(a);                  len = length(a);
                 a0 = (Obj)BDY(a);                  a0 = (Obj)BDY(a);
                 if ( !a0 || OID(a0) == O_N ) {                  if ( !a0 || OID(a0) == O_N ) {
                         /* a is dense weight */                          /* a is a dense weight vector */
                         dw = (int *)MALLOC(sizeof(int)*len);                          dw = (int *)MALLOC(sizeof(int)*len);
                         for ( j = 0, p = a; j < len; p = NEXT(p), j++ )                          for ( j = 0, p = a; j < len; p = NEXT(p), j++ )
                                 dw[j] = QTOS((Q)BDY(p));                                  dw[j] = QTOS((Q)BDY(p));
Line 1402  int create_composite_order_spec(VL vl,LIST order,struc
Line 1450  int create_composite_order_spec(VL vl,LIST order,struc
                         w_or_b[i].length = len;                          w_or_b[i].length = len;
                         w_or_b[i].body.dense_weight = dw;                          w_or_b[i].body.dense_weight = dw;
                 } else if ( OID(a0) == O_P ) {                  } else if ( OID(a0) == O_P ) {
                           /* a is a sparse weight vector */
                           len >>= 1;
                         sw = (struct sparse_weight *)                          sw = (struct sparse_weight *)
                                 MALLOC(sizeof(struct sparse_weight)*len);                                  MALLOC(sizeof(struct sparse_weight)*len);
                         for ( j = 0, p = a; j < len; j++ ) {                          for ( j = 0, p = a; j < len; j++ ) {
                                 v = VR((P)BDY(a)); a = NEXT(a);                                  v = VR((P)BDY(p)); p = NEXT(p);
                                 for ( tvl = vl, k = 0; tvl && tvl->v != v;                                  for ( tvl = vl, k = 0; tvl && tvl->v != v;
                                         k++, tvl = NEXT(tvl) );                                          k++, tvl = NEXT(tvl) );
                                 if ( !tvl )                                  if ( !tvl )
                                         error("invalid variable name");                                          error("invalid variable name");
                                 sw[j].pos = k;                                  sw[j].pos = k;
                                 sw[j].value = QTOS((Q)BDY(a));                                  sw[j].value = QTOS((Q)BDY(p)); p = NEXT(p);
                         }                          }
                         w_or_b[i].type = IS_SPARSE_WEIGHT;                          w_or_b[i].type = IS_SPARSE_WEIGHT;
                         w_or_b[i].length = len;                          w_or_b[i].length = len;
                         w_or_b[i].body.sparse_weight = sw;                          w_or_b[i].body.sparse_weight = sw;
                 } else {                  } else if ( OID(a0) == O_SYMBOL ) {
                         error("not implemented yet");                          /* a is a block */
                 }                          sym = (Symbol)a0; a = NEXT(a); len--;
                           for ( start = 0, tvl = vl; tvl->v != VR((P)BDY(a));
                                   tvl = NEXT(tvl), start++ );
                           for ( p = NEXT(a), tvl = NEXT(tvl); p;
                                   p = NEXT(p), tvl = NEXT(tvl) )
                                   if ( tvl->v != VR((P)BDY(p)) ) break;
                           if ( p )
                                   error("a block must be contiguous");
                           w_or_b[i].type = IS_BLOCK;
                           w_or_b[i].length = len;
                           w_or_b[i].body.block.start = start;
                           if ( !strcmp(sym->name,"@grlex") )
                                   w_or_b[i].body.block.order = 0;
                           else if ( !strcmp(sym->name,"@glex") )
                                   w_or_b[i].body.block.order = 1;
                           else if ( !strcmp(sym->name,"@lex") )
                                   w_or_b[i].body.block.order = 2;
                           else
                                   error("invalid ordernam");
                   }
         }          }
           if ( 1 ) print_composite_order_spec(spec);
 }  }
   
 /*  /*

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

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