Changeset b2fb0c in git


Ignore:
Timestamp:
May 25, 2012, 10:39:54 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
8b368ff67a7ef888aa2e3b02b2f425f07dc87cc1
Parents:
d058ea0445faa86f5ef796da196fbee35884b543
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-05-25 22:39:54+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:43+02:00
Message:
added HybridNF && related design changes!

add: introduced: SSFindReducer for HybridNF
chg: use SSFindReducer for SSReduceTerm
chg/fix: SSReduceTerm should not produce silly syzygies: m*gen(k) - m*gen(k) (it needs to know the 1st leading syzygy term!)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/schreyer.lib

    rd058ea rb2fb0c  
    10401040// -------------------------------------------------------- //
    10411041
    1042 /// TODO: save shortcut LM(m) * "t" -> ?
    1043 proc SSReduceTerm(poly m, def t, def L, def T, list #)
     1042/// TODO: save shortcut (syz: |-.->) LM(LM(m) * "t") -> syz?
     1043proc SSFindReducer(def product, def syzterm, def L, def T, list #)
    10441044{
    10451045  if( typeof( attrib(basering, "DEBUG") ) == "int" )
     
    10511051  }
    10521052
     1053
     1054  if( @DEBUG )
     1055  {
     1056    "SSFindReducer::Input: ";
     1057
     1058    "syzterm: ", syzterm;
     1059    "product: ", product;
     1060    "L: ", L;
     1061    "T: ", T;
     1062    if( size(#) > 0 )
     1063    {
     1064      "LSyz: ", #;
     1065    }
     1066  }
     1067
     1068
     1069  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
     1070  {
     1071    int @SYZCHECK = attrib(basering, "SYZCHECK");
     1072  } else
     1073  {
     1074    int @SYZCHECK = @DEBUG;
     1075  }
     1076 
     1077  if( @SYZCHECK && (syzterm != 0) )
     1078  {
     1079    def @@c = leadcomp(syzterm); int @@r = int(@@c);
     1080    def @@product = leadmonomial(syzterm) * L[@@r];
     1081
     1082    if( @@product != product)
     1083    {
     1084      "product: ", product, ", @@product: ", @@product;
     1085      "ERROR: 'syzterm' results in wrong product !!!???";
     1086      $
     1087    }
     1088  }
     1089
     1090//  def product = m * t;
     1091
     1092  bigint c = leadcomp(product); int r = int(c);
     1093
     1094  def a, b, bb;
     1095
     1096  vector nf = [0];
     1097
     1098  // looking for an appropriate diviser
     1099  for( int k = ncols(L); k > 0; k-- )
     1100  {
     1101    a = L[k];
     1102    // with the same mod. component
     1103    if( leadcomp(a) == c )
     1104    {
     1105      b = - (leadmonomial(product) / leadmonomial(L[k]));
     1106
     1107      // which divides the product: looking for the 1st appropriate one!
     1108      if( b != 0 )
     1109      {
     1110        bb = b * gen(k);
     1111       
     1112        if (size(bb + syzterm) == 0) // cannot allow something like: a*gen(i) - a*gen(i)
     1113        {
     1114          nf = [0];
     1115        } else
     1116        {
     1117          nf = bb;
     1118        }
     1119
     1120        // new syz. term should not be in <LS = #>
     1121        if( size(#) > 0 )
     1122        {
     1123          if( typeof(#[1]) == "module" )
     1124          {
     1125            nf = NF(bb, #[1]);
     1126          }
     1127        }
     1128
     1129        // while the complement (the fraction) is not reducible by leading syzygies
     1130        if( nf != 0 ) // nf must be == bb!!!
     1131        {
     1132          /// TODO: save shortcut LM(m) * T[i] -> ?
     1133
     1134          // choose ANY such reduction... (with the biggest index?)
     1135          break;
     1136        }
     1137      }
     1138    }
     1139  } 
     1140  if( @DEBUG )
     1141  {
     1142    "SSFindReducer::Output: ", nf;
     1143  }
     1144  return (nf);
     1145}
     1146
     1147
     1148
     1149
     1150
     1151/// TODO: save shortcut (syz: |-.->) LM(m) * "t" -> ?
     1152proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)
     1153{
     1154  if( typeof( attrib(basering, "DEBUG") ) == "int" )
     1155  {
     1156    int @DEBUG = attrib(basering, "DEBUG");
     1157  } else
     1158  {
     1159    int @DEBUG = !system("with", "ndebug");
     1160  }
     1161
     1162
    10531163  if( @DEBUG )
    10541164  {
    10551165    "SSReduce::Input: ";
    10561166
     1167    "syzterm: ", syzterm;
    10571168    "mult: ", m;
    10581169    "term: ", t;
     
    10651176//    "attrib(LS, 'isSB')", attrib(LS, "isSB");
    10661177  }
    1067  
    1068   vector s = 0;
    1069 
    1070   if( t == 0 )
    1071   {
    1072     return (s);
    1073   }
    1074 
    1075   def product = m * t;
    1076 
    1077   bigint c = leadcomp(t);
    1078   int r = int(c);
    1079  
    1080   def a, b, nf, bb;
    1081 
    1082   // looking for an appropriate reducer
    1083   for( int k = ncols(L); k > 0; k-- )
    1084   {
    1085     a = L[k];
    1086     // with the same mod. component
    1087     if( leadcomp(a) == c )
    1088     {
    1089       b = - (leadmonomial(product) / leadmonomial(L[k]));
    1090      
    1091       // which divides the product
    1092       if( b != 0 )
    1093       {
    1094 //        "b: ", b;
    1095         bb = b * gen(k);
    1096         nf = bb;
    1097 
    1098         if( size(#) > 0 )
    1099         {
    1100           if( typeof(#[1]) == "module" )
    1101           {
    1102             nf = NF(bb, #[1]);
    1103 //        "NF: ", nf;
    1104           }
    1105         }
    1106 
    1107         // while the complement (the fraction) is not reducible by leading syzygies
    1108         if( nf != 0 )
    1109         {
    1110           /// TODO: save shortcut LM(m) * T[i] -> ?
    1111 
    1112           // choose ANY such reduction... (with the biggest index?)
    1113           s = bb + SSTraverseTail(b, T[k], L, T, #);
    1114           break;
    1115         }
    1116       }
    1117     }
    1118   } 
     1178
     1179
     1180  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
     1181  {
     1182    int @SYZCHECK = attrib(basering, "SYZCHECK");
     1183  } else
     1184  {
     1185    int @SYZCHECK = @DEBUG;
     1186  }
     1187
     1188  if( @SYZCHECK && (syzterm != 0) )
     1189  {
     1190    def @@c = leadcomp(syzterm); int @@r = int(@@c);
     1191    poly @@m = leadmonomial(syzterm); def @@t = L[@@r];
     1192
     1193    if( (@@m != m) || (@@t != t))
     1194    {
     1195      "m: ", m, ", t: ", t;
     1196      "@@m: ", @@m, ", @@t: ", @@t;
     1197      "ERROR: 'syzterm' results in wrong m * t !!!";
     1198      $
     1199    }
     1200  }
     1201
     1202  vector s = [0];
     1203
     1204  if( size(t) > 0 )
     1205  {
     1206    def product = m * t;
     1207
     1208    s = SSFindReducer(product, syzterm, L, T, #);
     1209
     1210    if( size(s) != 0 )
     1211    {
     1212      poly b = leadmonomial(s);
     1213
     1214      def c = leadcomp(s); int k = int(c);
     1215
     1216      s = s + SSTraverseTail(b, T[k], L, T, #); // !!!   
     1217    }
     1218  }
     1219   
    11191220  if( @DEBUG )
    11201221  {
    11211222    "SSReduceTerm::Output: ", s;
    11221223  }
     1224 
    11231225  return (s);
    11241226}
     1227
    11251228
    11261229// TODO: store m * @tail -.-^-.-^-.--> ?
     
    11561259  {
    11571260    @l = lead(@tail);
    1158     s = s + SSReduceTerm(m, @l, L, T, #);
     1261    s = s + SSReduceTerm(m, @l, [0], L, T, #); // :(
    11591262    @tail = @tail - @l;
    11601263  }
     
    12141317  {
    12151318    @TAILREDSYZ = attrib(basering, "TAILREDSYZ");
    1216 //    @TAILREDSYZ;
    1217   }
     1319  }
     1320
     1321  int @HYBRIDNF = 0;
     1322  if( typeof( attrib(basering, "HYBRIDNF") ) == "int" )
     1323  {
     1324    @HYBRIDNF = attrib(basering, "HYBRIDNF");
     1325  }
     1326
     1327  module LL;
     1328  def a2; int r2; poly aa2; 
    12181329
    12191330  /// Get the critical leading syzygy terms
    12201331  if( @LEAD2SYZ ) // & 2nd syz. term
    12211332  {
    1222     def a2; int r2; poly aa2; 
    1223     module LL, LL2;
     1333    module LL2;
    12241334    (LL, LL2) = SSCompute2LeadingSyzygyTerms(L); // ++
    12251335  } else
    12261336  {
    1227     module LL = SSComputeLeadingSyzygyTerms(L);
    1228   }
    1229 
    1230   module TT, SYZ;
     1337    LL = SSComputeLeadingSyzygyTerms(L);
     1338  }
     1339
     1340  module TT, SYZ; def spoly;
    12311341
    12321342  if( size(LL) > 0 )
     
    12341344    list LS;
    12351345
    1236     if( @TAILREDSYZ )
     1346    if( @TAILREDSYZ)
    12371347    {
    12381348      LS = list(LL);
    12391349    }
    1240    
     1350
    12411351    vector @tail;
    12421352
     
    12471357      //    "A: ", a, " --->>>> ", aa, " **** [", r, "]: ";
    12481358
    1249       /// TODO: save shortcut (aa) * T[r] -> ?
    1250       @tail = SSTraverseTail(aa, T[r], L, T, LS);
    1251              
    1252       // get the 2nd syzygy term...
    1253      
    1254       if( @LEAD2SYZ ) // with the 2nd syz. term:
    1255       {     
    1256         a2 = LL2[k]; c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
    1257         @tail = @tail +
    1258              /// TODO: save shortcut (aa2) * T[r2] -> ?
    1259              a2 + SSTraverseTail(aa2, T[r2], L, T, LS);
     1359      // NF reduction:
     1360      if( !@HYBRIDNF )
     1361      {
     1362        /// TODO: save shortcut (aa) * T[r] -> ?
     1363        @tail = SSTraverseTail(aa, T[r], L, T, LS);
     1364  // //      @tail = SSTraverseTail(a, L, T, LS);
     1365
     1366        // get the 2nd syzygy term...
     1367
     1368        if( @LEAD2SYZ ) // with the 2nd syz. term:
     1369        {     
     1370          a2 = LL2[k]; c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
     1371
     1372          @tail = @tail + a2 +
     1373               /// TODO: save shortcut (aa2) * T[r2] -> ?
     1374               SSTraverseTail(aa2, T[r2], L, T, LS);
     1375  // //               SSTraverseTail(a2, L, T, LS);
     1376        } else
     1377        {
     1378          @tail = @tail +
     1379                  SSReduceTerm(aa, L[r], a, L, T, LS);
     1380  // //                  SSReduceTerm(a, L, T, LS);
     1381        }
    12601382      } else
    12611383      {
    1262         @tail = @tail + SSReduceTerm(aa, L[r], L, T, LS);
    1263       }     
     1384        spoly = aa * T[r];
     1385
     1386        if( @LEAD2SYZ )
     1387        {
     1388          a2 = LL2[k];
     1389        } else
     1390        {
     1391          a2 = SSFindReducer( aa * L[r], a, L, T, LS);
     1392        }
     1393
     1394        if ( (@SYZCHECK || @DEBUG) )
     1395        {
     1396          if( size(a2) == 0 ) // if syzterm == 0!!!!
     1397          {
     1398            "ERROR: could not find the 2nd syzygy term during the hybrid NF!!!";
     1399            $
     1400          }
     1401        }
     1402       
     1403        c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
     1404       
     1405        spoly = spoly + aa2 * T[r2];
     1406        @tail = a2;
     1407
     1408        while (size(spoly) > 0)
     1409        {
     1410          a2 = SSFindReducer( lead(spoly), [0], L, T, LS);
     1411          spoly = Tail(spoly);
     1412
     1413          if( size(a2) != 0)
     1414          {         
     1415            c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
     1416
     1417            spoly = spoly + aa2 * T[r2];
     1418            @tail = @tail + a2;
     1419          }
     1420        }
     1421       
     1422      }
    12641423     
    12651424      TT[k] = @tail;
     
    12681427  }
    12691428
    1270 /*
    1271   def opts = option(get); option(redSB); option(redTail);
    1272   module SYZ = std(syz(M));
    1273   option(set, opts); kill opts;
    1274  
    1275   module LL = lead(SYZ); // TODO: WRONG ORDERING!!!!!!!!
    1276   module TT = Tail(SYZ);
    1277 */
    1278  
    12791429  if( @DEBUG )
    12801430  {
     
    14991649
    15001650  ideal M = maxideal(1); M;
     1651
    15011652  def S = SSres(M, 0); setring S; S;
    15021653  MRES;
Note: See TracChangeset for help on using the changeset viewer.