4 * Vector p3 is a linear combination of two vectors (p1 and p2) such that
5 * p3[pos] is zero. First element of each vector (p1,p2,p3) is a status
6 * element and is not changed in p3. The value of 'pos' may be 0 however.
7 * The parameter 'length' does not include status element one.
9 * This function was copied from the PolyLib source.
11 void Combine(Value
*p1
, Value
*p2
, Value
*p3
, int pos
, unsigned length
) {
14 Value abs_a1
,abs_a2
,neg_a1
;
16 /* Initialize all the 'Value' variables */
17 value_init(a1
); value_init(a2
); value_init(gcd
);
18 value_init(abs_a1
); value_init(abs_a2
); value_init(neg_a1
);
21 value_assign(a1
,p1
[pos
]);
24 value_assign(a2
,p2
[pos
]);
27 value_absolute(abs_a1
,a1
);
30 value_absolute(abs_a2
,a2
);
32 /* gcd = Gcd(abs(a1), abs(a2)) */
33 Gcd(abs_a1
,abs_a2
,&gcd
);
36 value_division (a1
,a1
,gcd
);
39 value_division (a2
,a2
,gcd
);
42 value_oppose(neg_a1
,a1
);
44 Vector_Combine(p1
+1,p2
+1,p3
+1,a2
,neg_a1
,length
);
45 Vector_Normalize(p3
+1,length
);
47 /* Clear all the 'Value' variables */
48 value_clear(a1
); value_clear(a2
); value_clear(gcd
);
49 value_clear(abs_a1
); value_clear(abs_a2
); value_clear(neg_a1
);