File: EVALSYS.c

package info (click to toggle)
qepcad 1.74%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,848 kB
  • sloc: ansic: 27,242; cpp: 2,995; makefile: 1,287; perl: 91
file content (53 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*======================================================================
                      L <- EVALSYS(S,t,R)

Eval System at rational number 

Inputs:
  S = (S_1,...,S_r), S_i a list of i-variate saclib pols
      defining a system of equations.
  t an integer, 1 <= t <= r
  R a rational number

Outputs:
  L : a system that is equivalent to S with R substituted for x_t.
  NOTE: if Q is a polynomial in the system of positive
  degree in x_s, where s > t, then Q will be represented
  in L as an s-variate polynomial, despite the fact that
  we know a priori that "x_t" will not exist in Q.
======================================================================*/
#include "qepcad.h"

Word EVALSYS(Word S, BDigit t, Word R)
{
  Word r, L, i, S_i, Ap, a, A, is, As;
  
Step1: /* Construct the skelaton of L, the answer. */
  r = LENGTH(S);
  L = NIL;
  for(i = 1; i <= r; i++)
    if (i < t)
      L = COMP(LELTI(S,i),L);
    else
      L = COMP(NIL,L);
  L = CINV(L);

Step2: /* Sub R -> x_t for all levels >= t */
  for(i = t; i <= r; i++)
  {
    for(S_i = LELTI(S,i); S_i != NIL; S_i = RED(S_i))
    {
      /* Make substitution */
      Ap = IPRNEVAL(i,FIRST(S_i),t,R);
      if (Ap == 0) continue;

      IPSRP(i,Ap,&a,&A);
      PSIMREP(i,A,&is,&As);
      if (is == 0) { L = 1; goto Return; }
      SLELTI(L,is,COMP(As,LELTI(L,is)));
    }
  }

Return: /* Prepare to return */
  return L;
}