File: FINDRATCOORD.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 (42 lines) | stat: -rw-r--r-- 888 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
/*======================================================================
                      FINDRATCOORD(S;t,R,P)

Find rational coordinate

Inputs:
  S : a list (S_1,...,S_r), S_i a list of primitive irreducible 
      i-variate saclib pols

Outputs:
  t : a BDigit
  R : a rational number
  P : SACLIB polynomial
  If some element of some S_i is a x_i + b, a,b \in Z, then 
  t = i, R = -b/a and P = a x_i + b (as an element of Z[x_1,...,x_t]).
  Otherwise t = 0.
======================================================================*/
#include "qepcad.h"

void FINDRATCOORD(Word S, Word* t_, Word *R_, Word *P_)
{
  Word r, i, L, R;
  r = LENGTH(S);
  for(i = 1; i <= r; i++)
  {
    for(L = LELTI(S,i); L != NIL; L = RED(L))
    {
      R = IPRSOL(i,FIRST(L));
      if (R != NIL)
      {
	*t_ = i;
	*R_ = R;
	*P_ = FIRST(L);
	return;
      }
    }
  }
  
  *t_ = 0;
  return;
}