source: git/factory/facFqFactorizeUtil.cc @ e2c181

spielwiese
Last change on this file since e2c181 was 6deedd, checked in by Martin Lee <martinlee84@…>, 12 years ago
modified some helper functions and removed unneccessary inclusion of config.h
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR
3\*****************************************************************************/
4/** @file facFqFactorizeUtil.cc
5 *
6 * This file provides utility functions for multivariate factorization
7 *
8 * @author Martin Lee
9 *
10 * @internal @version \$Id$
11 *
12 **/
13/*****************************************************************************/
14
15#include "config.h"
16
17#include "canonicalform.h"
18#include "cf_map.h"
19
20static inline
21void appendSwap (CFList& factors1, const CFList& factors2, const int
22                  swapLevel1, const int swapLevel2, const Variable& x)
23{
24  for (CFListIterator i= factors2; i.hasItem(); i++)
25  {
26    if (swapLevel1)
27    {
28      if (swapLevel2)
29        factors1.append (swapvar (swapvar (i.getItem(), x,
30                         Variable (swapLevel2)), Variable (swapLevel1), x));
31      else
32        factors1.append (swapvar (i.getItem(), Variable (swapLevel1), x));
33    }
34    else
35    {
36      if (swapLevel2)
37        factors1.append (swapvar (i.getItem(), x, Variable (swapLevel2)));
38      else
39        factors1.append (i.getItem());
40    }
41  }
42  return;
43}
44
45
46void swap (CFList& factors, const int swapLevel1, const int swapLevel2, const
47           Variable& x)
48{
49  for (CFListIterator i= factors; i.hasItem(); i++)
50  {
51    if (swapLevel1)
52    {
53      if (swapLevel2)
54        i.getItem()= swapvar (swapvar (i.getItem(), x, Variable (swapLevel2)),
55                              Variable (swapLevel1), x);
56      else
57        i.getItem()= swapvar (i.getItem(), Variable (swapLevel1), x);
58    }
59    else
60    {
61      if (swapLevel2)
62        i.getItem()= swapvar (i.getItem(), x, Variable (swapLevel2));
63    }
64  }
65  return;
66}
67
68void appendSwapDecompress (CFList& factors1, const CFList& factors2,
69                             const CFMap& N, const int swapLevel, const
70                             Variable& x)
71{
72  for (CFListIterator i= factors1; i.hasItem(); i++)
73  {
74    if (swapLevel)
75      i.getItem()= swapvar (i.getItem(), Variable (swapLevel), x);
76    i.getItem()= N(i.getItem());
77  }
78  for (CFListIterator i= factors2; i.hasItem(); i++)
79  {
80    if (!i.getItem().inCoeffDomain())
81      factors1.append (N (i.getItem()));
82  }
83  return;
84}
85
86void appendSwapDecompress (CFList& factors1, const CFList& factors2,
87                             const CFMap& N, const int swapLevel1,
88                             const int swapLevel2, const Variable& x)
89{
90  for (CFListIterator i= factors1; i.hasItem(); i++)
91  {
92    if (swapLevel1)
93    {
94      if (swapLevel2)
95        i.getItem()=
96        N (swapvar (swapvar (i.getItem(), Variable (swapLevel2), x), x,
97                    Variable (swapLevel1)));
98      else
99        i.getItem()= N (swapvar (i.getItem(), x, Variable (swapLevel1)));
100    }
101    else
102    {
103      if (swapLevel2)
104        i.getItem()= N (swapvar (i.getItem(), Variable (swapLevel2), x));
105      else
106        i.getItem()= N (i.getItem());
107    }
108  }
109  for (CFListIterator i= factors2; i.hasItem(); i++)
110  {
111    if (!i.getItem().inCoeffDomain())
112      factors1.append (N (i.getItem()));
113  }
114  return;
115}
116
117int* liftingBounds (const CanonicalForm& A, const int& bivarLiftBound)
118{
119  int j= A.level() - 1;
120  int* liftBounds= new int [j];
121  liftBounds[0]= bivarLiftBound;
122  for (int i= 1; i < j; i++)
123  {
124    liftBounds[i]= degree (A, Variable (i + 2)) + 1 +
125                            degree (LC (A, 1), Variable (i + 2));
126  }
127  return liftBounds;
128}
129
130CanonicalForm shift2Zero (const CanonicalForm& F, CFList& Feval, const CFList& evaluation, int l)
131{
132  CanonicalForm A= F;
133  int k= evaluation.length() + l - 1;
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, int l)
148{
149  int k= evaluation.length() + l - 1;
150  CanonicalForm result= F;
151  CFListIterator j= evaluation;
152  for (int i= k; j.hasItem() && (i > l - 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.