forked from ke456/bivariate_seq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bivariate.cpp
More file actions
74 lines (57 loc) · 1.66 KB
/
Copy pathtest_bivariate.cpp
File metadata and controls
74 lines (57 loc) · 1.66 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "bivariate_lin_seq.h"
#include <NTL/BasicThreadPool.h>
#include <NTL/lzz_pX.h>
NTL_CLIENT
int main(){
// set this to be the prime you want to work over
long p = 2013265921;
zz_p::init(p);
SetNumThreads(4);
// this are "bivariate" polynomials
Vec<zz_pX> num;
Vec<zz_pX> den;
zz_pX P;
/**** NUMERATOR ********************************/
// encode num: 1-x
SetCoeff(P,0,1);
SetCoeff(P,1,-1);
num.append(P);
P = zz_pX(0);
/**** DENOMINATOR *******************************/
// encode den: (1+x)^2 + (-x)y + y^2
// (1+x)^2
SetCoeff(P,0,1);
SetCoeff(P,1,2);
SetCoeff(P,2,1);
den.append(P); P=zz_pX(0);
// (-x)
SetCoeff(P,1,-1);
den.append(P); P=zz_pX(0);
// 1
SetCoeff(P,0,1);
den.append(P);
cout << "num: " << num << endl;
cout << "den: " << den << endl;
// this creates the object
bivariate_lin_seq bls{num,den,2,2};
long D,N,DD,NN,m;
cout << "Enter x-coordinate of index to center around: ";
cin >> NN;
cout << "Enter y-coordinate of index to center around: ";
cin >> DD;
cout << "Enter the index range to compute: ";
cin >> m;
cout << endl;
printf("Terms (%ld,%ld) to (%ld,%ld):\n\n",NN-m,DD-m,NN+m,DD+m);
zz_pX n,d; // this is num/den for the output
for(D=DD-m; D < DD+m+1; D++){
bls.find_row(n,d,D);
Vec<zz_p> init = get_init(deg(d), n, d);
Vec<zz_p> coeffs;
coeffs.SetLength(2*m+1);
for(N=NN-m; N < NN+m+1; N++){
coeffs[N-NN+m] = get_elem(N, reverse(d), init);
}
cout << coeffs << endl;
}
}