Eigenvalue extraction with QR decomposition
# in julia, using CUDA to load onto the gpu # use the QR decomposition in the LinearAlgebra library using LinearAlgebra using CUDA # try it on a 256x256 array b=rand(256,256); b=b+b'; B=CuArray(b); for j in 1:600 QR=qr(B) B=QR.R *
Smart recursions: tail-call and Miller recursion
long f(long x){ return(faux(x,1)); } long faux(long x, long y){ /* here is simple iteration */ while (x != 0){ y=x*y; x=x-1;} return(y); } (defun binomial (n k) "Binomial coefficient" (if (or (< n k) (< k 0)) nil (binomaux
Very fast recursions with memoization
;; lisp again.... (defvar *facttable* (make-hash-table :test 'equal)) (setf (gethash 3 *facttable*) 6) (defun factl (n) "Memoized factorial function" (cond ((= n 0) 1) ((equal (gethash n *facttable*) nil) (let* ((x (* n (factl (- n 1))))) (setf (gethash n