; http://people.math.gatech.edu/~mbaker/pdf/cipolla2011.pdf
; this value is mutable because of variable rg.
(let ((ff (fileVal "finiteField"))(J (fileVal "Jacobi"))
      (rg (((fileVal "RC4") "froth") 'rbi)))
(lambda (a p)
(let ((rx (rg (- p 1))) (Fp (ff p)) (jt (J a p)))
    (if (< jt 0) 'none (if (= jt 0) 0 
    (let ((m+ (Fp 'm+)) (m- (Fp 'm-)) (m* (Fp 'm*)))
    (let y () (let* ((t (+ 1 (rx)))(w2 (m+ (m* t t) (m- a))))
      (if (= (J w2 p) 1) (y)
      (vector-ref ((((Fp 'fops) (list->vector (list (m- w2) 0 1))) 'fexpt)
         (list->vector (list t 1)) (arithmetic-shift (+ p 1) -1)) 0))))))))))

; (t 49 103) ; produces a complex vector!!
; t = 96, w2 = 0, final field val = (7, 51)
; The real part is right.
((fileVal "GFsqrt") 2 17)

(let* ((p ((fileVal "pias") 2000000000000000000000 3))
(rx ((((fileVal "RC4") "foth") 'rbi) (- p 1)))(sqrt (fileVal "GFsqrt")))
  (let w ((i 1000)) (or (zero? i) (and
    (let* ((r (rx)) (y (sqrt (modulo (* r r) p) p))) (or (= y r) (= y (- p r))))
    (w (- i 1))))))