"= the julia library HomotopyContinuation is SLOW. This code is easy to entend and is actually pretty fast, and does not use 77 other libraries and packages, just four, and plotting is optional =" using DynamicPolynomials using LinearAlgebra using DataStructures
Protected: AI/ML-1. Neural nets in Julia
There is no excerpt because this is a protected post.
Libraries, packages, and namespaces
I have already illustrated how to create packages or libraries in R, let’s have a look at the process in lisp and C.All computer language implementations and installations include many libraries or collections of ready-to-use functions and data types. These
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 *
Root finding
#include<stdio.h> float a,b,c; float func(float (*pf)(float x), float x, float y); float f( float z); main(){ a=2.0; b=3.0; c=func(f,a,b); printf("%f\n",c); } float func(float(*pf)(float x), float x, float y){ float c; c=(*pf)(x); c=y*c; return(c); } float f(float z){ return(1.0/(z*z)); } (defun
Protected: Autodifferentiation with dual numbers
There is no excerpt because this is a protected post.
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
Integer relations-I. Brun’s algorithm
; common lisp ; Brun's method for integer relations ; Make sure you use double-floats! (defun Brun (lst iters) (setf foo (copy-list lst)) (setf n (1- (length foo))) (setf b (loop for i from 0 to n collect (loop for
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
Algorithms for numerical integration.
(defpackage :quadrature (:use :common-lisp) (:nicknames "quadr") (:documentation "Basic numerical integration functions (JRS 2015)") (:export :Trapezoid :Romberg :Clenshaw :Gaussian :LagGauss)) ; ;; to use, make it the current package (in-package :quadrature) (defun Trapezoid (fcn n a b) "Trapezoid rule integration n