source: git/factory/facFqFactorizeUtil.cc @ 7efef7

spielwiese
Last change on this file since 7efef7 was e4fe2b, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
FIX: Fixed huge BUG in cf_gmp.h CHG: starting to cleanup factory
  • Property mode set to 100644
File size: 4.1 KB
RevLine 
[7bf145]1/*****************************************************************************\
[806c18]2 * Computer Algebra System SINGULAR
[7bf145]3\*****************************************************************************/
4/** @file facFqFactorizeUtil.cc
[806c18]5 *
[7bf145]6 * This file provides utility functions for multivariate factorization
7 *
8 * @author Martin Lee
9 *
10 * @internal @version \$Id$
11 *
12 **/
13/*****************************************************************************/
14
[e4fe2b]15#include "config.h"
[7bf145]16
17#include "canonicalform.h"
18#include "cf_map.h"
19
[806c18]20static inline
[7bf145]21void appendSwap (CFList& factors1, const CFList& factors2, const int
[806c18]22                  swapLevel1, const int swapLevel2, const Variable& x)
[7bf145]23{
[806c18]24  for (CFListIterator i= factors2; i.hasItem(); i++)
25  {
26    if (swapLevel1)
[7bf145]27    {
28      if (swapLevel2)
[806c18]29        factors1.append (swapvar (swapvar (i.getItem(), x,
[7bf145]30                         Variable (swapLevel2)), Variable (swapLevel1), x));
31      else
[806c18]32        factors1.append (swapvar (i.getItem(), Variable (swapLevel1), x));
[7bf145]33    }
[806c18]34    else
[7bf145]35    {
36      if (swapLevel2)
[806c18]37        factors1.append (swapvar (i.getItem(), x, Variable (swapLevel2)));
38      else
39        factors1.append (i.getItem());
[7bf145]40    }
41  }
42  return;
43}
44
[d52c12]45
[7bf145]46void swap (CFList& factors, const int swapLevel1, const int swapLevel2, const
[806c18]47           Variable& x)
[7bf145]48{
[806c18]49  for (CFListIterator i= factors; i.hasItem(); i++)
50  {
51    if (swapLevel1)
[7bf145]52    {
53      if (swapLevel2)
[806c18]54        i.getItem()= swapvar (swapvar (i.getItem(), x, Variable (swapLevel2)),
[7bf145]55                              Variable (swapLevel1), x);
56      else
[806c18]57        i.getItem()= swapvar (i.getItem(), Variable (swapLevel1), x);
[7bf145]58    }
[806c18]59    else
[7bf145]60    {
61      if (swapLevel2)
[806c18]62        i.getItem()= swapvar (i.getItem(), x, Variable (swapLevel2));
[7bf145]63    }
64  }
65  return;
66}
67
[806c18]68void appendSwapDecompress (CFList& factors1, const CFList& factors2,
[7bf145]69                             const CFMap& N, const int swapLevel, const
[806c18]70                             Variable& x)
[7bf145]71{
[806c18]72  for (CFListIterator i= factors1; i.hasItem(); i++)
[7bf145]73  {
[806c18]74    if (swapLevel)
[7bf145]75      i.getItem()= swapvar (i.getItem(), Variable (swapLevel), x);
76    i.getItem()= N(i.getItem());
77  }
[806c18]78  for (CFListIterator i= factors2; i.hasItem(); i++)
[7bf145]79  {
[806c18]80    if (!i.getItem().inCoeffDomain())
[7bf145]81      factors1.append (N (i.getItem()));
82  }
83  return;
84}
85
[806c18]86void appendSwapDecompress (CFList& factors1, const CFList& factors2,
87                             const CFMap& N, const int swapLevel1,
88                             const int swapLevel2, const Variable& x)
[7bf145]89{
[806c18]90  for (CFListIterator i= factors1; i.hasItem(); i++)
[7bf145]91  {
[806c18]92    if (swapLevel1)
[7bf145]93    {
[806c18]94      if (swapLevel2)
[7bf145]95        i.getItem()=
96        N (swapvar (swapvar (i.getItem(), Variable (swapLevel2), x), x,
97                    Variable (swapLevel1)));
[806c18]98      else
[7bf145]99        i.getItem()= N (swapvar (i.getItem(), x, Variable (swapLevel1)));
100    }
[806c18]101    else
[7bf145]102    {
103      if (swapLevel2)
104        i.getItem()= N (swapvar (i.getItem(), Variable (swapLevel2), x));
105      else
106        i.getItem()= N (i.getItem());
107    }
108  }
[806c18]109  for (CFListIterator i= factors2; i.hasItem(); i++)
110  {
111    if (!i.getItem().inCoeffDomain())
[7bf145]112      factors1.append (N (i.getItem()));
113  }
114  return;
115}
116
[806c18]117int* liftingBounds (const CanonicalForm& A, const int& bivarLiftBound)
[7bf145]118{
119  int j= A.level() - 1;
120  int* liftBounds= new int [j];
121  liftBounds[0]= bivarLiftBound;
[806c18]122  for (int i= 1; i < j; i++)
[7bf145]123  {
[806c18]124    liftBounds[i]= degree (A, Variable (i + 2)) + 1 +
[7bf145]125                            degree (LC (A, 1), Variable (i + 2));
126  }
127  return liftBounds;
128}
129
[d52c12]130CanonicalForm shift2Zero (const CanonicalForm& F, CFList& Feval, const CFList& evaluation)
[7bf145]131{
132  CanonicalForm A= F;
133  int k= A.level();
134  for (CFListIterator i= evaluation; i.hasItem(); i++, k--)
135    A= A (Variable (k) + i.getItem(), k);
136  CanonicalForm buf= A;
137  Feval= CFList();
138  Feval.append (buf);
139  for (k= A.level(); k > 2; k--)
140  {
141    buf= mod (buf, Variable (k));
142    Feval.insert (buf);
143  }
144  return A;
145}
146
147CanonicalForm reverseShift (const CanonicalForm& F, const CFList& evaluation)
148{
149  int l= evaluation.length() + 1;
150  CanonicalForm result= F;
151  CFListIterator j= evaluation;
152  for (int i= l; i > 1; i--, j++)
153  {
154    if (F.level() < i)
155      continue;
156    result= result (Variable (i) - j.getItem(), i);
157  }
158  return result;
159}
160
161
Note: See TracBrowser for help on using the repository browser.