source: git/factory/facFqFactorizeUtil.cc @ 72bfc8

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