parent b5b0a9cb
 ... @@ -646,6 +646,58 @@ CONTAINS ... @@ -646,6 +646,58 @@ CONTAINS #endif #endif SUBROUTINE DO_LONG_TEST implicit none integer,parameter :: nzero = 10 integer,parameter :: nieps = 30 integer,parameter :: ncmpl = 30 integer,parameter :: perweight(4) = (/ 100, 500, 5000, 15000 /) real(kind=prec), parameter :: rrange = 1.5 type(inum), dimension(nzero+nieps+ncmpl) :: basis type(inum), dimension(size(perweight)) :: args type(inum), parameter :: ione = inum((1._prec,0._prec), di0) integer i, j, w, seed integer(kind=1) i0 real(kind=prec) :: v complex(kind=prec) :: ans(2), geval seed = 112312 basis(1:nzero) = izero do i=nzero+1,nzero+nieps if (ran2(seed).gt.0.5) then i0 = +1_1 else i0 = -1_1 endif v = 2*rrange*(ran2(seed) - 0.5) basis(i) = inum(cmplx(v,kind=prec), i0) enddo do i=nzero+nieps+1,nzero+nieps+ncmpl v = 2*rrange*(ran2(seed) - 0.5) basis(i) = toinum(v*exp(i_*2*pi*ran2(seed))) enddo do w=1,size(perweight) print*,"Testing ",perweight(w)," GPLs with w=",w do i=1,perweight(w) args(1:w) = basis((/ (1+int(size(basis)*ran2(seed)),j=1,w) /)) ans(1) = geval([args(1:w),ione], w+1) ans(2) = G(args(1:w),ione) if(abs(ans(1)-ans(2)) > tol) goto 123 enddo enddo return 123 continue print*,"Failed with delta",abs(ans(1)-ans(2)) print*,"Offending G was",args(1:w) print*,ans END SUBROUTINE FUNCTION RAN2(randy) FUNCTION RAN2(randy) ! This is the usual "random" ! This is the usual "random" ... ...
• Owner

A way to calculate the basis in Mathematica is the following

Ran2[n_, seed_] := Mod[seed PowerMod[7^5, n, 2^31 - 1], 2^31 - 1]/2^31.

seed = 112312;
nzero = 10;
nieps = 30;
ncmpl = 30;
perweight = {100, 500, 30000, 50000};
rrange = 1.5;

basis = Join[
ConstantArray[0, nzero],
2 rrange (Ran2[Range[2, 2 nieps, 2], seed] - 1/2) + i0 (
2 HeavisideTheta[# - 0.5] - 1 & /@ Ran2[Range[1, 2 nieps, 2], seed]
),
2 rrange (Ran2[Range[1, 2 ncmpl, 2] + 60, seed] - 1/2)
E^(2 Pi I Ran2[Range[2, 2 ncmpl, 2] + 60, seed])
]

The arguments sampled can be calculated as

w = 1; offset = 120;
Partition[
basis[[
1 + Floor[
Length[basis] Ran2[Range[offset + 1, offset + w perweight[[w]]]]]
]],
w
];

w = 2; offset = 120 + (w - 1) perweight[[w - 1]];
Partition[...]
w = 3; offset = 120 + (w - 2) perweight[[w - 2]] + (w - 1) perweight[[w - 1]];
Partition[...]
Edited by ulrich_y
• mentioned in commit ab33be23

Toggle commit list
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!