text:
using Rubin
using Tests
using Elliptic
using HypergeometricFunctions
using Polylogarithms
using SpecialFunctions

@test integrate((1+d*x)^(1/2)*(1+-1*d*x)^(1/2)*(e+f*x)^3*(A+B*x+C*x^2), x) == :(1//16*d^-5*(B*f^3+2*C*d^2*e^3+3*C*e*f^2+8*A*d^4*e^3+6*A*e*d^2*f^2+6*B*f*d^2*e^2)*arcsin(d*x)+1//16*x*d^-4*(1+-1*d^2*x^2)^(1/2)*(B*f^3+2*C*d^2*e^3+3*C*e*f^2+8*A*d^4*e^3+6*A*e*d^2*f^2+6*B*f*d^2*e^2)+1//840*d^-6*f^-1*(1+-1*d^2*x^2)^3//2*(8*C*(-8*f^4+3*d^4*e^4+-30*d^2*e^2*f^2)+-56*f*d^2*(B*(d^2*e^3+6*e*f^2)+2*A*f*(f^2+6*d^2*e^2))+3*f*x*d^2*(-35*B*f^3+-41*C*e*f^2+6*C*d^2*e^3+-98*A*e*d^2*f^2+-14*B*f*d^2*e^2))+-1//7*C*d^-2*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^4+-1//70*d^-4*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^2*(-1*C*(-8*f^2+3*d^2*e^2)+7*f*d^2*(B*e+2*A*f))+1//42*d^-2*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^3*(-7*B*f+3*C*e))
@test integrate((1+d*x)^(1/2)*(1+-1*d*x)^(1/2)*(e+f*x)^2*(A+B*x+C*x^2), x) == :(1//16*d^-5*(C*(f^2+2*d^2*e^2)+2*d^2*(A*(f^2+4*d^2*e^2)+2*B*e*f))*arcsin(d*x)+1//16*x*d^-4*(1+-1*d^2*x^2)^(1/2)*(C*(f^2+2*d^2*e^2)+2*d^2*(A*(f^2+4*d^2*e^2)+2*B*e*f))+1//120*d^-4*f^-1*(1+-1*d^2*x^2)^3//2*(-16*f*(B*(f^2+d^2*e^2)+5*A*e*f*d^2)+8*C*(d^2*e^3+-4*e*f^2)+-3*f*x*(f^2*(5C+10*A*d^2)+-2*e*d^2*(C*e+-2*B*f)))+-1//6*C*d^-2*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^3+1//10*d^-2*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^2*(C*e+-2*B*f))
@test integrate((1+d*x)^(1/2)*(1+-1*d*x)^(1/2)*(e+f*x)*(A+B*x+C*x^2), x) == :(1//8*d^-3*(B*f+C*e+4*A*e*d^2)*arcsin(d*x)+-1//60*d^-4*f^-1*(1+-1*d^2*x^2)^3//2*(-4*C*(-2*f^2+3*d^2*e^2)+20*f*d^2*(A*f+B*e)+-3*f*x*d^2*(-5*B*f+3*C*e))+1//8*x*d^-2*(1+-1*d^2*x^2)^(1/2)*(B*f+C*e+4*A*e*d^2)+-1//5*C*d^-2*f^-1*(1+-1*d^2*x^2)^3//2*(e+f*x)^2)
@test integrate((1+d*x)^(1/2)*(1+-1*d*x)^(1/2)*(A+B*x+C*x^2), x) == :(-1//3*B*d^-2*(1+-1*d^2*x^2)^3//2+1//8*d^-3*(C+4*A*d^2)*arcsin(d*x)+-1//4*C*x*d^-2*(1+-1*d^2*x^2)^3//2+1//8*x*d^-2*(1+-1*d^2*x^2)^(1/2)*(C+4*A*d^2))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^-1*(A+B*x+C*x^2), x) == :(f^-2*(-1*f^2+d^2*e^2)^-1//2*(A*f^2+C*e^2+-1*B*e*f)*arctan((1+-1*d^2*x^2)^-1//2*(-1*f^2+d^2*e^2)^-1//2*(f+e*x*d^2))+-1*C*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)+-1*d^-1*f^-2*(C*e+-1*B*f)*arcsin(d*x))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^-2*(A+B*x+C*x^2), x) == :(C*d^-1*f^-2*arcsin(d*x)+-1*f^-2*(-1*f^2+d^2*e^2)^-3//2*(B*f^3+C*d^2*e^3+-2*C*e*f^2+-1*A*e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*e*d^2*(C*e+-5*B*f))+1//20*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^3*(C*e+-5*B*f))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^2*(A+B*x+C*x^2), x) == :(1//8*d^-5*(C*(3*f^2+4*d^2*e^2)+4*d^2*(A*(f^2+2*d^2*e^2)+2*B*e*f))*arcsin(d*x)+1//24*d^-4*f^-1*(1+-1*d^2*x^2)^(1/2)*(-16*f*(B*(f^2+d^2*e^2)+3*A*e*f*d^2)+4*C*(d^2*e^3+-8*e*f^2)+-1*f*x*(f^2*(9C+12*A*d^2)+-2*e*d^2*(C*e+-4*B*f)))+-1//4*C*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^3+1//12*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^2*(C*e+-4*B*f))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)*(A+B*x+C*x^2), x) == :((1/2)*d^-3*(B*f+C*e+2*A*e*d^2)*arcsin(d*x)+-1//6*d^-4*f^-1*(1+-1*d^2*x^2)^(1/2)*(-2*C*(-2*f^2+d^2*e^2)+6*f*d^2*(A*f+B*e)+-1*f*x*d^2*(C*e+-3*B*f))+-1//3*C*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^2)
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(A+B*x+C*x^2), x) == :((1/2)*d^-3*(C+2*A*d^2)*arcsin(d*x)+-1*B*d^-2*(1+-1*d^2*x^2)^(1/2)+-1//2*C*x*d^-2*(1+-1*d^2*x^2)^(1/2))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^-1*(A+B*x+C*x^2), x) == :(f^-2*(-1*f^2+d^2*e^2)^-1//2*(A*f^2+C*e^2+-1*B*e*f)*arctan((1+-1*d^2*x^2)^-1//2*(-1*f^2+d^2*e^2)^-1//2*(f+e*x*d^2))+-1*C*d^-2*f^-1*(1+-1*d^2*x^2)^(1/2)+-1*d^-1*f^-2*(C*e+-1*B*f)*arcsin(d*x))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^-2*(A+B*x+C*x^2), x) == :(C*d^-1*f^-2*arcsin(d*x)+-1*f^-2*(-1*f^2+d^2*e^2)^-3//2*(B*f^3+C*d^2*e^3+-2*C*e*f^2+-1*A*e*d^2*f^2)*arctan((1+-1*d^2*x^2)^-1//2*(-1*f^2+d^2*e^2)^-1//2*(f+e*x*d^2))+f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^-1*(-1*f^2+d^2*e^2)^-1*(A*f^2+C*e^2+-1*B*e*f))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(e+f*x)^-3*(A+B*x+C*x^2), x) == :((1/2)*(-1*f^2+d^2*e^2)^-5//2*(C*(2*f^2+d^2*e^2)+-1*d^2*(-1*A*(f^2+2*d^2*e^2)+3*B*e*f))*arctan((1+-1*d^2*x^2)^-1//2*(-1*f^2+d^2*e^2)^-1//2*(f+e*x*d^2))+(1/2)*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^-2*(-1*f^2+d^2*e^2)^-1*(A*f^2+C*e^2+-1*B*e*f)+-1//2*f^-1*(1+-1*d^2*x^2)^(1/2)*(e+f*x)^-1*(-1*f^2+d^2*e^2)^-2*(2*B*f^3+C*d^2*e^3+-4*C*e*f^2+B*f*d^2*e^2+-3*A*e*d^2*f^2))
@test integrate(x*(1+d*x)^-1//2*(1+-1*d*x)^-1//2*(a+b*x+c*x^2), x) == :((1/2)*b*d^-3*arcsin(d*x)+-1//6*d^-4*(1+-1*d^2*x^2)^(1/2)*(4c+6*a*d^2+3*b*x*d^2)+-1//3*c*d^-2*x^2*(1+-1*d^2*x^2)^(1/2))
@test integrate((1+d*x)^-1//2*(1+-1*d*x)^-1//2*(a+b*x+c*x^2), x) == :((1/2)*d^-3*(c+2*a*d^2)*arcsin(d*x)+-1*b*d^-2*(1+-1*d^2*x^2)^(1/2)+-1//2*c*x*d^-2*(1+-1*d^2*x^2)^(1/2))
@test integrate(x^-1*(1+d*x)^-1//2*(1+-1*d*x)^-1//2*(a+b*x+c*x^2), x) == :(-1*a*arctanh((1+-1*d^2*x^2)^(1/2))+b*d^-1*arcsin(d*x)+-1*c*d^-2*(1+-1*d^2*x^2)^(1/2))
@test integrate(x^-2*(1+d*x)^-1//2*(1+-1*d*x)^-1//2*(a+b*x+c*x^2), x) == :(-1*b*arctanh((1+-1*d^2*x^2)^(1/2))+c*d^-1*arcsin(d*x)+-1*a*x^-1*(1+-1*d^2*x^2)^(1/2))
@test integrate(x^-3*(1+d*x)^-1//2*(1+-1*d*x)^-1//2*(a+b*x+c*x^2), x) == :(-1*(c+(1/2)*a*d^2)*arctanh((1+-1*d^2*x^2)^(1/2))+-1*b*x^-1*(1+-1*d^2*x^2)^(1/2)+-1//2*a*x^-2*(1+-1*d^2*x^2)^(1/2))
@test integrate((a+b*x)^(1/2)*(e+f*x)^3*(a*c+-1*b*c*x)^(1/2)*(A+B*x+C*x^2), x) == :(1//16*x*b^-4*(a+b*x)^(1/2)*(a*c+-1*b*c*x)^(1/2)*(A*(8*b^4*e^3+6*e*a^2*b^2*f^2)+a^2*(a^2*f^2*(B*f+3*C*e)+2*b^2*e^2*(C*e+3*B*f)))+-1//840*b^-6*f^-1*(a+b*x)^(1/2)*(a*c+-1*b*c*x)^(1/2)*(a^2+-1*b^2*x^2)*(-8*b^4*e^2*(-7*f*(B*e+12*A*f)+3*C*e^2)+64*C*a^4*f^4+3*f*x*b^2*(a^2*f^2*(35*B*f+41*C*e)+-2*e*b^2*(-7*f*(B*e+7*A*f)+3*C*e^2))+16*a^2*b^2*f^2*(7*f*(A*f+3*B*e)+15*C*e^2))+-1//7*C*b^-2*f^-1*(a+b*x)^(1/2)*(e+f*x)^4*(a*c+-1*b*c*x)^(1/2)*(a^2+-1*b^2*x^2)+-1//70*b^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+-1*c*d*e*(-3*A*f+10*B*e))+a*b^2*(e*d^2*(-19*A*f+2*B*e)+-1*c*d*(10*C*e^2+11*A*f^2+-27*B*e*f)+-1*f*c^2*(-1*B*f+20*C*e))+-3*b*a^2*(-1*C*(d^2*e^2+3*c^2*f^2+c*d*e*f)+d*f*(-5*A*d*f+2*B*d*e+3*B*c*f))+C*d*f*a^3*(d*e+-1*c*f))*Elliptic.F(arcsin(d^(1/2)*(a+b*x)^(1/2)*(a*d+-1*b*c)^-1//2),f*d^-1*(b*e+-1*a*f)^-1*(b*c+-1*a*d))+2//15*b^-2*d^(1/2)*(b*(b*c+-1*a*d)^-1*(c+d*x))^(1/2)*(b*(b*e+-1*a*f)^-1*(e+f*x))^-1//2*(c+d*x)^-1//2*(e+f*x)^(1/2)*(a*d+-1*b*c)^-5//2*(b*e+-1*a*f)^-3*(-1*b^4*(c^2*(8*A*f^2+15*C*e^2+-10*B*e*f)+8*A*d^2*e^2+-1*c*d*e*(-7*A*f+10*B*e))+-1*a*b^3*(e*d^2*(-23*A*f+2*B*e)+-1*c*d*(10*C*e^2+23*A*f^2+-33*B*e*f)+-2*f*c^2*(-1*B*f+5*C*e))+-1*a^2*b^2*(C*(3*c^2*f^2+3*d^2*e^2+-13*c*d*e*f)+d*f*(-7*B*(c*f+d*e)+23*A*d*f))+2*C*a^4*d^2*f^2+b*d*f*a^3*(-7*C*(c*f+d*e)+3*B*d*f))*Elliptic.E(arcsin(d^(1/2)*(a+b*x)^(1/2)*(a*d+-1*b*c)^-1//2),f*d^-1*(b*e+-1*a*f)^-1*(b*c+-1*a*d)))

max_stars_repo_path: test/1 Algebraic functions/1.1 Binomial products/1.1.1 Linear/1.1.1.6 P(x) (a+b x)^m (c+d x)^n (e+f x)^p.jl


text:
using LinQu, Test, Random
import LinQu.data # data() is extended

struct IdentityGate <: QGate
	IdentityGate() = new()
end #struct

data(gate::IdentityGate) = [1 0; 0 1]

ext: jl


text:
module SmallLeastSquaresDemo

using VarianceReducedSG
using LinearAlgebra
using Random
using Test

# Square-norm gradient
sqgrad(x) = x

function setup_ls(N, n, mt)
	# Generate data
	A = randn(mt, n,N)
	x_star = randn(mt, N)

	y = A*x_star # No noise

	# Normalize and reformat
	norm_consts = [norm(A[i,:]) for i = 1:size(A,1)]
	data = [A[i,:]./norm_consts[i] for i = 1:size(A,1)]
	b = [y[i]/norm_consts[i] for i = 1:length(y)]

	# Initial guess
	x0 = randn(mt, N)

	return data, b, x0, x_star
end

function solve_and_test(alg, niter, loggers, nlogs, x_star)
	iterate!(alg, niter, loggers, nlogs)
	@test isapprox(primiterates(alg), x_star)

	iterate!(alg, niter)
	@test isapprox(primiterates(alg), x_star)

	iterate!(alg, niter, loggers, nlogs)
	@test isapprox(primiterates(alg), x_star)
end

################################################################################
# SAGA, SAG, SVAG
################################################################################
function SAGlike_test()
	N = 100
	n = 1000
	mt = MersenneTwister(123)

	data, b, x0, x_star = setup_ls(N,n,mt)

	# Gradients of square cost
	f(x,i) = sqgrad(x - b[i])
	f!(y,x,i) = (y .= data[i].*sqgrad(dot(data[i],x) - b[i]))

	# VR gradient
	vrg = VRGradient(f!, zeros(N), n)
	vrg_lin = LinearVRG(f, data, zeros(N))

	# Create Algorithms
	algs = [
		(SAGA(vrg, x0, 1/3, mt), "SAGA - VRGradient"),
		(SAGA(vrg_lin, x0, 1/3, mt), "SAGA - LinearVRG"),
		(SAGA(vrg_lin, x0, 1/3, mt, weights=.1 .+rand(mt,n)), "SAGA - LinearVRG - Importance"),
		(SAG(vrg, x0, 1/3, mt), "SAG - VRGradient"),
		(SAG(vrg_lin, x0, 1/3, mt), "SAG - LinearVRG"),
		(SAG(vrg, x0, 1/3, mt, weights=.1 .+rand(mt,n)), "SAG - VRGradient - Importance"),
		(SVAG(vrg, x0, 1/3, n/10, mt), "SVAG - VRGradient"),
		(SVAG(vrg_lin, x0, 1/3, n/10, mt), "SVAG - LinearVRG"),
		(SVAG(vrg_lin, x0, 1/3, n/10, mt, weights=.1 .+rand(mt,n)), "SVAG - LinearVRG - Importance"),
		(ASVAG(vrg, x0, 1/3, mt), "ASVAG - VRGradient"),
		(ASVAG(vrg_lin, x0, 1/3, mt), "ASVAG - LinearVRG"),
		(ASVAG(vrg_lin, x0, 1/3, mt, weights=.1 .+rand(mt,n)), "ASVAG - LinearVRG - Importance"),
		(ASVAG(vrg_lin, x0, 1/3, mt, enforce_step=true), "ASVAG - LinearVRG - Theoretical stepsize enforced"),
		]

	for (alg, descr) in algs
		# Create Loggers
		fprog(x,y) = norm(x - x_star)
		loggers = (
			ShowTime(),
			ShowFuncVal(fprog, "|| x - x^*||"),
			ShowNewLine("...")
			)

		println(descr)

		# Solve
		niter = n*500
		nlogs = 10
		solve_and_test(alg, niter, loggers, nlogs, x_star)
	end
end

################################################################################
# SVRG
################################################################################
function SVRG_test()
	N = 100
	n = 1000
	mt = MersenneTwister(123)

	data, b, x0, x_star = setup_ls(N,n,mt)

	# Gradients of square cost
	f(x,i) = sqgrad(x - b[i])
	f!(y,x,i) = (y .= data[i].*sqgrad(dot(data[i],x) - b[i]))

	# VR gradient
	vrg = VRGradient(f!, zeros(N), n)
	vrg_lin = LinearVRG(f, data, zeros(N))
	vrg_uni = UniformVRG(f!, zeros(N), n)

	# Create Algorithm
	stagelen = Int(ceil(n/2))
	algs = [
		(SVRG(vrg, x0, 1/3, stagelen, mt), "SVRG - VRGradient"),
		(SVRG(vrg_uni, x0, 1/3, stagelen, mt), "SVRG - UniformVRG"),
		(SVRG(vrg_lin, x0, 1/3, stagelen, mt), "SVRG - LinearVRG"),
		(SVRG(vrg_uni, x0, 1/3, stagelen, mt, weights=.1 .+rand(mt,n)), "SVRG - UniformVRG - Importance"),
		]

	for (alg, descr) in algs
		# Create Loggers
		fprog(x,y) = norm(x - x_star)
		loggers = (
			ShowFuncVal(fprog, "|| x - x^*||"),
			ShowIterations(),
			ShowNewLine()
			)

		println(descr)

		# Solve
		niter = 100*stagelen
		nlogs = 10
		solve_and_test(alg, niter, loggers, nlogs, x_star)
	end
end

################################################################################
# Loopless SVRG
################################################################################
function LSVRG_test()
	N = 100
	n = 1000
	mt = MersenneTwister(123)

	data, b, x0, x_star = setup_ls(N,n,mt)

	# Gradients of square cost
	f(x,i) = sqgrad(x - b[i])
	f!(y,x,i) = (y .= data[i].*sqgrad(dot(data[i],x) - b[i]))

	# VR gradient
	vrg = VRGradient(f!, zeros(N), n)
	vrg_lin = LinearVRG(f, data, zeros(N))
	vrg_uni = UniformVRG(f!, zeros(N), n)

	q = 10/n # Expected update frequency
	algs = [
		(LSVRG(vrg, x0, 1/3, q, mt), "LSVRG - VRGradient"),
		(LSVRG(vrg_uni, x0, 1/3, q, mt), "LSVRG - UniformVRG"),
		(LSVRG(vrg_lin, x0, 1/3, q, mt), "LSVRG - LinearVRG"),
		(LSVRG(vrg, x0, 1/3, q, mt, weights=.1 .+ rand(mt,n)), "LSVRG - VRGradient - Importance"),
		]

	for (alg, descr) in algs
		# Create Loggers
		fprog(x,y) = norm(x - x_star)
		loggers = (
			ShowIterations(),
			ShowFuncVal(fprog, "|| x - x^*||"),
			ShowNewLine()
			)

		println(descr)

		# Setup iterations counts
		niter = 1000/q
		nlogs = 10

		# Create Algorithm and solve
		solve_and_test(alg, niter, loggers, nlogs, x_star)
	end

	# Solve again for smaller expected update frequency
	q = .1/n
	niter = 100/q
	nlogs = 10

	# Create Loggers
	fprog(x,y) = norm(x - x_star)
	loggers = (
		ShowIterations(),
		ShowFuncVal(fprog, "|| x - x^*||"),
		ShowNewLine()
		)
	println("LSVRG - Low update frequency")
	alg = LSVRG(vrg, x0, 1/3, q, mt)
	solve_and_test(alg, niter, loggers, nlogs, x_star)
end

################################################################################
# Incoherent Loopless SVRG
################################################################################
function ILSVRG_test()
	N = 100
	n = 1000
	mt = MersenneTwister(123)

	data, b, x0, x_star = setup_ls(N,n,mt)

	# Gradients of square cost
	f(x,i) = sqgrad(x - b[i])
	f!(y,x,i) = (y .= data[i].*sqgrad(dot(data[i],x) - b[i]))

	# VR gradient
	vrg = VRGradient(f!, zeros(N), n)
	vrg_lin = LinearVRG(f, data, zeros(N))
	vrg_uni = UniformVRG(f!, zeros(N), n)

	q = 10/n # Expected update frequency
	algs = [
		(ILSVRG(vrg, x0, 1/3, q, mt), "ILSVRG - VRGradient"),
		(ILSVRG(vrg_lin, x0, 1/3, q/10, mt), "ILSVRG - LinearVRG"),
		(ILSVRG(vrg, x0, 1/3, 2*q, mt, weights=.1 .+ rand(mt,n)), "ILSVRG - VRGradient - Importance"),
		]

	for (alg, descr) in algs
		# Create Loggers
		fprog(x,y) = norm(x - x_star)
		loggers = (
			ShowIterations(),
			ShowFuncVal(fprog, "|| x - x^*||"),
			ShowNewLine()
			)

		println(descr)

		# Setup iterations counts
		niter = 1000/q
		nlogs = 10

		# Create Algorithm and solve
		solve_and_test(alg, niter, loggers, nlogs, x_star)
	end
end

################################################################################
# qSAGA
################################################################################
function QSAGA_test()
	N = 100
	n = 1000
	mt = MersenneTwister(123)

	data, b, x0, x_star = setup_ls(N,n,mt)

	# Gradients of square cost
	f(x,i) = sqgrad(x - b[i])
	f!(y,x,i) = (y .= data[i].*sqgrad(dot(data[i],x) - b[i]))

	# VR gradient
	vrg = VRGradient(f!, zeros(N), n)
	vrg_lin = LinearVRG(f, data, zeros(N))

	algs = [
		(QSAGA(vrg, x0, 1/3, 1, mt), "QSAGA - VRGradient - q=1"),
		(QSAGA(vrg_lin, x0, 1/3, 10, mt), "QSAGA - LinearVRG, q=10"),
		(QSAGA(vrg, x0, 1/3, 10, mt, weights=.1 .+ rand(mt,n)), "LSVRG - VRGradient - Importance - q=10"),
		]

	for (alg, descr) in algs
		# Create Loggers
		fprog(x,y) = norm(x - x_star)
		loggers = (
			ShowIterations(),
			ShowFuncVal(fprog, "|| x - x^*||"),
			ShowNewLine()
			)

		println(descr)

		# Setup iterations counts
		niter = 100*n
		nlogs = 10

		# Create Algorithm and solve
		solve_and_test(alg, niter, loggers, nlogs, x_star)
	end

	# Solve again but without replacement in the dual update
	niter = 50*n
	nlogs = 10

	# Create Loggers
	fprog(x,y) = norm(x - x_star)
	loggers = (
		ShowIterations(),
		ShowFuncVal(fprog, "|| x - x^*||"),
		ShowNewLine()
		)
	println("LSVRG - q = 20 - Without replacement")
	alg = QSAGA(vrg, x0, 1/3, 20, mt, replace=false)
	solve_and_test(alg, niter, loggers, nlogs, x_star)
	println("LSVRG - q = 20 - With replacement")
	alg = QSAGA(vrg, x0, 1/3, 20, mt, replace=true)
	solve_and_test(alg, niter, loggers, nlogs, x_star)
end

################################################################################
# Testsets
################################################################################
@testset "Least Squares" begin
	SAGlike_test()
	SVRG_test()
	LSVRG_test()
	ILSVRG_test()
	QSAGA_test()
end

end


text:
using Test
@testset "DAE" begin let
	using DifferentialEquations
	import DifferentiableBackwardEuler
	DBE = DifferentiableBackwardEuler

	function rober(u, p, t)
		du = zeros(eltype(u), 3)
		du[1] = -p[1] * u[1] + p[3] * u[2] * u[3]
		du[2] = p[1] * u[1] - p[3] * u[2] * u[3] - p[2] * u[2] ^2
		du[3] = sum(u) - 1
		return du
	end
	function rober_u(u, p, t)
		du_u = zeros(eltype(u), 3, 3)
		du_u[1, :] = [-p[1], p[3] * u[3], p[3] * u[2]]
		du_u[2, :] = [p[1], -p[3] *u[3] - 2 * p[2] * u[2], -p[3] * u[2]]
		du_u[3, :] = ones(eltype(u), 3)
		return du_u
	end
	function rober_p(u, p, t)
		du_p = zeros(eltype(u), 3, 3)
		du_p[1, :] = [-u[1], 0, u[2] * u[3]]
		du_p[2, :] = [u[1], -u[2] ^2, -u[2] * u[3]]
		du_p[3, :] = zeros(eltype(u), 3)
		return du_p
	end
	rober_t(u, p, t) = zero(u)

	M = [1. 0 0; 0 1. 0; 0 0 0]
	f = ODEFunction(rober, mass_matrix=M)
	u0 = [1.0, 0.0, 0.0]
	tspan = (0.0, 1e5)
	p = [0.04, 3e7, 1e4]
	prob_mm = ODEProblem(f, u0, tspan, p)
	sol = solve(prob_mm, ImplicitEuler(), reltol=1e-8, abstol=1e-8)
	dbe_sol = Array{Float64, 1}[u0]
	#test dae_step
	for i = 1:length(sol.t) - 1
		push!(dbe_sol, DBE.dae_step(dbe_sol[end], sol.t[i + 1] - sol.t[i], rober, rober_u, rober_p, rober_t, p, sol.t[i + 1], M))
		@test isapprox(dbe_sol[end], sol.u[i + 1]; atol=1e-5, rtol=1e-5)
	end
	#test dae_steps(..., ts, M)
	dbe_sol = DBE.dae_steps(u0, rober, rober_u, rober_p, rober_t, p, sol.t, M)
	@test isapprox(dbe_sol, sol[:, :]; atol=1e-5, rtol=1e-5)
	#test dae_steps(..., t0, tfinal, M)
	dbe_sol = DBE.dae_steps(u0, rober, rober_u, rober_p, rober_t, p, tspan[1], tspan[2], M; reltol=1e-8, abstol=1e-8)
	@test isapprox(dbe_sol, sol[:, :]; atol=1e-5, rtol=1e-5)

	function naivegradient(f, x0s...; delta::Float64=1e-8)
		f0 = f(x0s...)
		gradient = map(x->zeros(size(x)), x0s)
		for j = 1:length(x0s)
			x0 = copy(x0s[j])
			for i = 1:length(x0)
				x = copy(x0)
				x[i] += delta
				xs = (x0s[1:j - 1]..., x, x0s[j + 1:length(x0s)]...)
				fval = f(xs...)
				gradient[j][i] = (fval - f0) / delta
			end
		end
		return gradient
	end
	g(p, u0) = sum(DBE.dae_steps(u0, rober, rober_u, rober_p, rober_t, p, tspan[1], 1e2, M; reltol=1e-8, abstol=1e-8)[3, end])
	dgdp_zygote = Zygote.gradient(g, p, u0)
	dgdp_naive = naivegradient(g, p, u0; delta=1e-4)
	@test isapprox(dgdp_zygote[1], dgdp_naive[1]; atol=1e-3, rtol=1e-3)
	@test isapprox(dgdp_zygote[2], dgdp_naive[2]; atol=1e-3, rtol=1e-3)
end end#end begin and let


text:
export WSRK2, WSRK3

"""
    WickerSkamarockRungeKutta <: DistributedODEAlgorithm

Class of multirate algorithms developed in [WS1998](@cite) and [WS2002](@cite),
which can be used as slow methods in [`Multirate`](@ref).

These require two additional copies of the state vector ``u``.

Available implementations are:
- [`WSRK2`](@ref)
- [`WSRK3`](@ref)
"""
abstract type WickerSkamarockRungeKutta <: DistributedODEAlgorithm end

struct WickerSkamarockRungeKuttaTableau{Nstages, RT}
  "Time-scaling coefficients c"
  c::NTuple{Nstages, RT}
end

struct WickerSkamarockRungeKuttaCache{Nstages, RT, A}
  tableau::WickerSkamarockRungeKuttaTableau{Nstages, RT}
  U::A
  F::A
end
function cache(prob::DiffEqBase.ODEProblem, alg::WickerSkamarockRungeKutta; kwargs...)
  U = similar(prob.u0)
  F = similar(prob.u0)
  return WickerSkamarockRungeKuttaCache(tableau(alg, eltype(F)), U, F)
end

nstages(::WickerSkamarockRungeKuttaCache{Nstages}) where {Nstages} = Nstages

function init_inner(prob, outercache::WickerSkamarockRungeKuttaCache, dt)
  OffsetODEFunction(prob.f.f1, zero(dt), one(dt), one(dt), outercache.F)
end
function update_inner!(innerinteg, outercache::WickerSkamarockRungeKuttaCache,
  f_slow, u, p, t, dt, i)

  f_offset = innerinteg.prob.f
  tab = outercache.tableau
  U = outercache.U
  N = nstages(outercache)

  f_slow(f_offset.x, i == 1 ? u : U, p, t + tab.c[i]*dt)

  if i < N
    U .= u
    innerinteg.u = U
  else
    innerinteg.u = u
  end

  innerinteg.t = t
  innerinteg.tstop = i == N ? t+dt : t+tab.c[i+1]*dt
end

"""
    WSRK2()

The 2 stage, 2nd order RK2 scheme of [WS1998](@cite).
"""
struct WSRK2 <: WickerSkamarockRungeKutta
end
tableau(::WSRK2, RT) = WickerSkamarockRungeKuttaTableau((RT(0), RT(1//2)))

"""
    WSRK3()

The 3 stage, 2nd order (3rd order for linear problems) RK3 scheme of [WS2002](@cite).
"""
struct WSRK3 <: WickerSkamarockRungeKutta
end
tableau(::WSRK3, RT) = WickerSkamarockRungeKuttaTableau((RT(0), RT(1//3), RT(1//2)))


text:
using SimilaritySearch
using SimilarReferences
using Test

function test_vectors(create_index, dist, ksearch, nick)
    @testset "indexing vectors with $nick and $dist" begin
        n = 1000 # number of items in the dataset
        m = 100  # number of queries
        dim = 3  # vector's dimension

        db = [rand(Float32, dim) for i in 1:n]
        queries = [rand(Float32, dim) for i in 1:m]

        index = create_index(db)
        optimize!(index, recall=0.9, k=10, use_distances=false)
        perf = Performance(index.db, dist, queries, expected_k=10)
        p = probe(perf, index, use_distances=false)
        @show dist, p
        @test p.recall > 0.8

        @info "adding more items"
        for item in queries
            push!(index, item)
        end
        perf = Performance(index.db, dist, queries, expected_k=1)
        p = probe(perf, index, use_distances=false)
        @show dist, p
        @test p.recall > 0.999
        return p
    end
end

function test_sequences(create_index, dist, ksearch, nick)
    @testset "indexing sequences with $nick and $dist" begin
        n = 1000 # number of items in the dataset
        m = 100  # number of queries
        dim = 5  # the length of sequences
        V = collect(1:10)  # vocabulary of the sequences

        function create_item()
            s = rand(V, dim)
            if dist isa JaccardDistance || dist isa DiceDistance || dist isa IntersectionDistance
                sort!(s)
                s = unique(s)
            end

            return s
        end
        db = [create_item() for i in 1:n]
        queries = [create_item() for i in 1:m]

        @info "inserting items into the index"
        index = create_index(db)
        # optimize!(index, recall=0.9, k=10, use_distances=true)
        perf = Performance(index.db, dist, queries, expected_k=10)
        p = probe(perf, index, use_distances=true)
        @show dist, p
        @test p.recall > 0.6

        for item in queries
            push!(index, item)
        end
        perf = Performance(index.db, dist, queries, expected_k=1)
        p = probe(perf, index, use_distances=true)
        @show dist, p
        @test p.recall > 0.999
        return p
    end
end

@testset "indexing vectors" begin
    # NOTE: The following algorithms are complex enough to say we are testing it doesn't have syntax errors, a more grained test functions are required
    ksearch = 10
    σ = 127
    κ = 3

    for dist in [
        L2Distance(), # 1.0 -> metric, < 1.0 if dist is not a metric
        L1Distance(),
        LInfDistance(),
        # AngleDistance(),
        LpDistance(3),
        LpDistance(0.5)
    ]
        p = test_vectors((db) -> Knr(db, dist, numrefs=σ, k=κ), dist, ksearch, "KNR")
    end
end

@testset "indexing sequences" begin
    # NOTE: The following algorithms are complex enough to say we are testing it doesn't have syntax errors, a more grained test functions are required
    ksearch = 10
    σ = 127
    κ = 3

    # metric distances should achieve recall=1 (perhaps lesser because of numerical inestability)
    for dist in [
        JaccardDistance(),
        DiceDistance(),
        IntersectionDistance(),
        CommonPrefixDistance(),
        LevDistance(),
        LcsDistance(),
        HammingDistance(),
    ]
        p = test_sequences((db) -> Knr(db, dist, numrefs=σ, k=κ), dist, ksearch, "KNR")
    end
end


text:
using Test
using BlackScholesGreeks.GreekAnalyticalInv

@testset "GreekAnalyticalInv.jl" begin
    # Call value (in BTC)
    test_value = blackScholesInvValue(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_value ≈ 0.05685 atol=1e-5

    # Put value (in BTC)
    test_value = blackScholesInvValue(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_value ≈ 0.13007 atol=1e-5

    # Call delta
    test_delta = blackScholesInvDelta(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_delta ≈ 7.900e-6 atol=1e-9

    # Put delta
    test_delta = blackScholesInvDelta(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_delta ≈ -1.5944e-5 atol=1e-9

    # Call Gamma
    test_gamma = blackScholesInvGamma(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_gamma ≈ 5.42776e-10 atol=1e-14

    # Put Gamma
    test_gamma = blackScholesInvGamma(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_gamma ≈ 1.6025e-9 atol=1e-13

    # Call Vega
    test_vega = blackScholesInvVega(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_vega ≈ 0.0677572 atol=1e-6

    # Put Vega
    test_vega = blackScholesInvVega(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_vega ≈ 0.200047 atol=1e-6

    # Call Theta
    test_theta = blackScholesInvTheta(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_theta ≈ -0.298307 atol=1e-6

    # Put Theta
    test_theta = blackScholesInvTheta(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_theta ≈ -0.933885 atol=1e-6

    # Call Vanna
    test_vanna = blackScholesInvVanna(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_vanna ≈ -1.43429e-6 atol=1e-11

    # Put Vanna
    test_vanna = blackScholesInvVanna(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_vanna ≈ -4.37405e-6 atol=1e-11

    # Call Volga
    test_volga = blackScholesInvVolga(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_volga ≈ -0.050302 atol=1e-6

    # Put Volga
    test_volga = blackScholesInvVolga(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_volga ≈ 0.142393 atol=1e-6

    # Call Charm
    test_charm = blackScholesInvCharm(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_charm ≈ 7.53407e-6 atol=1e-11

    # Put Charm
    test_charm = blackScholesInvCharm(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_charm ≈ 2.16025e-5 atol=1e-10

    # Call Rho1
    test_rho1 = blackScholesInvRho(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_rho1 ≈ -0.0047588 atol=1e-7

    # Put Rho1
    test_rho1 = blackScholesInvRho(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_rho1 ≈ -0.0107769 atol=1e-7

    # Call Rho2
    test_rho2 = blackScholesInvRho2(true, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_rho2 ≈ -0.0292506 atol=1e-7

    # Put Rho2
    test_rho2 = blackScholesInvRho2(false, 45000.0, 46000.0, 30.0 / 365, 0.0025, 0.03, 0.75)
    @test test_rho2 ≈ 0.0589424 atol=1e-7
end

max_stars_repo_name: Stochastic-Adventure/BlackScholesGreeks

max_issues_repo_name: Stochastic-Adventure/BlackScholesGreeks

max_forks_repo_name: Stochastic-Adventure/BlackScholesGreeks


text:
using Test, PolynomialBases, FastGaussQuadrature

if !haskey(ENV, "JULIA_PKGEVAL") # sympy is not install on https://github.com/JuliaComputing/NewPkgEval.jl
    import SymPy
    x, α, β = SymPy.symbols("x, alpha, beta")

    @test 0 == SymPy.simplify( jacobi(x, 0, α, β) - 1 )
    # https://www.wolframalpha.com/input/?i=JacobiP%5B1,+alpha,+beta,+x%5D
    @test 0 == SymPy.simplify( jacobi(x, 1, α, β) - ( α-β+x*(2+α+β) ) / 2 )
    # https://www.wolframalpha.com/input/?i=JacobiP%5B2,+alpha,+beta,+x%5D
    @test 0 == SymPy.simplify( jacobi(x, 2, α, β) - (
                (α+1)*(α+2)/2 + (x-1)^2*(α+β+3)*(α+β+4)/8
                + (α+2)*(x-1)*(α+β+3)/2
            ) )
    # https://www.wolframalpha.com/input/?i=JacobiP%5B3,+alpha,+beta,+x%5D
    @test 0 == SymPy.simplify( jacobi(x, 3, α, β) - (
                (α+1)*(α+2)*(α+3)/6 + (x-1)^3*(α+β+4)*(α+β+5)*(α+β+6)/48
                + (α+3)*(x-1)^2*(α+β+4)*(α+β+5)/8 + (α+2)*(α+3)*(x-1)*(α+β+4)/4
            ) )

    @test_skip jacobi(x, 4, α, β)
end
@inferred jacobi(10., 4, 3, 2)

# Gauss Jacobi nodes and weights
for p in 0:10, α in range(-0.9, stop=4, length=50), β in range(-0.9, stop=4, length=50)
    x1, w1 = gaussjacobi(p+1, α, β)
    @inferred PolynomialBases.gauss_jacobi_nodes_and_weights(p, α, β)
    x2, w2 = PolynomialBases.gauss_jacobi_nodes_and_weights(p, α, β)
    @test x1 ≈ x2 atol=1.e-11
    @test w1 ≈ w2 atol=1.e-11
end

# Vandermonde matrices for Gauss Jacobi nodes and weights
# NOTE: Only some tests for low polynomial degrees since the Vandermonde matrix
#       becomes ill-conditioned for higher values of p.
for p in 0:8, α in range(-0.9, stop=4, length=50), β in range(-0.9, stop=4, length=50)
    basis1 = GaussJacobi(p, α, β)
    V1 = jacobi_vandermonde(basis1, α, β)

    basis2 = GaussLegendre(p+1)
    V2 = jacobi_vandermonde(basis2, α, β)

    R = interpolation_matrix(basis1.nodes, basis2)

    P = Matrix(I, p+2, p+1)

    @test R * V2 * P / V1 ≈ I
end


text:
using CUDA

codee = """
define dso_local i16 @"?addToTp@@YAG_N0G@Z"(i1 zeroext %0, i1 zeroext %1, i16 %2) #0 {
  %4 = alloca i16, align 2
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store i16 %2, i16* %4, align 2
  %7 = zext i1 %1 to i8
  store i8 %7, i8* %5, align 1
  %8 = zext i1 %0 to i8
  store i8 %8, i8* %6, align 1
  %9 = load i8, i8* %6, align 1
  %10 = trunc i8 %9 to i1
  %11 = zext i1 %10 to i32
  %12 = load i8, i8* %5, align 1
  %13 = trunc i8 %12 to i1
  %14 = zext i1 %13 to i32
  %15 = and i32 %11, %14
  %16 = load i16, i16* %4, align 2
  %17 = zext i16 %16 to i32
  %18 = add nsw i32 %17, %15
  %19 = trunc i32 %18 to i16
  store i16 %19, i16* %4, align 2
  ret i16 %19
}
"""

    # intrinsic = "llvm.nvvm.vote.$mode"
    # @eval begin
    #     @inline $fname(pred) =
    #         Base.llvmcall($("""
    #             declare i32 @$intrinsic(i1)
    #             define i32 @entry(i8) #0 {
    #                 %predicate = icmp eq i8 %0, 1
    #                 %ret = call i32 @$intrinsic(i1 %predicate)
    #                 ret i32 %ret
    #             }
    #             attributes #0 = { alwaysinline }""", "entry"),
    #         UInt32, Tuple{Bool}, pred)
    # end

    # # warp-synchronous
    # intrinsic = "llvm.nvvm.vote.$mode.sync"

    fname = Symbol("addToTp")
    @eval export $fname
   @eval begin
        @inline addToTp(boolGold, boolSegm,tp) =
            Base.llvmcall($("""
            $codee
                attributes #0 = { alwaysinline }""", "addToTp"),
            UInt32, Tuple{Bool, Bool, UInt32}, boolGold, boolSegm,tp)
    end
#    @eval begin
#         @inline addToTp(boolGold, boolSegm,tp) =
#             Base.llvmcall($("""
#             define i32 @addToTp(i32 %tp) #0 {
#                 ret i32 %tp
#             }
#                 attributes #0 = { alwaysinline }""", "addToTp"),
#             UInt32, Tuple{Bool, Bool, UInt32}, boolGold, boolSegm,tp)
#     end
addToTp(true,true,UInt32(1))

# using Test

# function do_the_call()
#     Base.llvmcall(
#         ("""declare double @jl_test_returns_float()
#             define double @entry() #0 {
#             0:
#                 %1 = call double @jl_test_returns_float()
#                 ret double %1
#             }
#             attributes #0 = { alwaysinline }
#         """, "entry"),Float64,Tuple{})
# end
# @test do_the_call() === 42.0

# @eval export $fname, $fname_sync
# using Test
# function zz(x::UInt16, y::UInt16)
#     Base.llvmcall("""%3 = add i16 %1, %0
#                 ret i16 %3""", UInt16, Tuple{UInt16, UInt16}, x, y)
# end
# @test zz(UInt16(1),UInt16(2))==UInt16(3)

using Test
function addToFp(boolGold::Bool, boolSegm::Bool,tp::UInt16)
    Base.llvmcall("""
    %4 = xor i8 %0, %1
    %5 = and i8 %4, %1
    %6 = zext i8 %5 to i16
    %7 = add i16 %2,%6
    ret i16 %7""", UInt16, Tuple{Bool,Bool, UInt16}, boolGold, boolSegm,tp)
end

@test addToFp(false,true,UInt16(2))==UInt16(3)
@test addToFp(true,true,UInt16(2))==UInt16(2)
@test addToFp(false,false,UInt16(2))==UInt16(2)
@test addToFp(true,false,UInt16(2))==UInt16(2)

function addToFn(boolGold::Bool, boolSegm::Bool,tp::UInt16)
    Base.llvmcall("""
    %4 = xor i8 %0, %1
    %5 = and i8 %4, %0
    %6 = zext i8 %5 to i16
    %7 = add i16 %2,%6
    ret i16 %7""", UInt16, Tuple{Bool,Bool, UInt16}, boolGold, boolSegm,tp)
end

@test addToFn(false,true,UInt16(2))==UInt16(2)
@test addToFn(true,true,UInt16(2))==UInt16(2)
@test addToFn(false,false,UInt16(2))==UInt16(2)
@test addToFn(true,false,UInt16(2))==UInt16(3)

x=UInt16(1)
zz(true,true,x)
x


text:
# Thompson sampling for Bayesian optimization of continuous functions

using GaussianProcesses, Optim, Distributions

mutable struct ThompsonSampler
    f
    dim
    X
    Y
    M
    lower
    upper
    ll
    lσ
    logNoise
    gp_iter
    x0
end

ThompsonSampler(f,X,Y,M,
                lower=fill(-Inf,size(X,1)),
                upper=fill(Inf,size(Y,1)),
                ll=zeros(size(X,1)),
                lσ=0.0,
                logNoise=-2.0,
                gp_iter=1000,
                x0=X[:,findmax(Y)[2]]) = ThompsonSampler(f,
                                                         size(X,1),
                                                         X,
                                                         Y,
                                                         M,
                                                         lower,
                                                         upper,
                                                         ll,
                                                         lσ,
                                                         logNoise,
                                                         gp_iter,
                                                         x0)

function step(t::ThompsonSampler)

    X = t.X
    Y = t.Y

    gp = GP(X,Y,MeanZero(),SE(t.ll,t.lσ),t.logNoise)
    optimize!(gp,iterations=t.gp_iter)

    f,g = spectral_sample(gp,t.M)

    β = optimize(f,g,t.lower,t.upper,t.x0,Fminbox())
    Optim.minimizer(β)
end

Base.start(t::ThompsonSampler) = t
function Base.next(t::ThompsonSampler,state)
    xn = step(t)
    append!(t,xn)

    xn,t
end
Base.done(t::ThompsonSampler,state) = false

function Base.append!(t::ThompsonSampler,xn)
    yn = t.f(xn) # This is the one call to the expensive function f

    t.X = hcat(t.X,xn)
    t.Y = vcat(t.Y,yn)

    t
end

Base.iteratorsize(::ThompsonSampler) = Base.IsInfinite()

function spectral_sample(gp,M)
    l2 = gp.k.iℓ2
    σ2 = gp.k.σ2
    σξ = exp(gp.logNoise)

    # This is the right probability density for the SE kernel
    dW=MvNormal(zeros(length(l2)),sqrt.(l2))
    db=Uniform(0,2π)

    W = rand(dW,M)
    b = rand(db,M)

    Φ = hcat([ϕ(gp.X[:,i],σ2,W,b) for i in 1:size(gp.X,2)]...)

    cK = GaussianProcesses.tolerant_PDMat(Φ*Φ' + σξ^2*I)

    μ = cK\(Φ*gp.y)

    θ = μ + σξ*inv(cK.chol[:U])*randn(length(μ))
    f = x->-ϕ(x,σ2,W,b)'θ # Minus sign because Optim will minimize this for us
    g = (G,x)->G[:] = -ϕ′(x,σ2,W,b)'θ
    f,g
end

ϕ(x,σ2,W,b) = sqrt(2*σ2/length(b)) * cos.(W'x + b)
ϕ′(x,σ2,W,b) = -sqrt(2*σ2/length(b)) * sin.(W'x + b).*W'
k(x,y,σ2,W,b) = 2*σ2/length(b)*cos.(W*x+b)'cos.(W*y+b)


text:
"""
    StepsizeCallback(; cfl=1.0)

Set the time step size according to a CFL condition with CFL number `cfl`
if the time integration method isn't adaptive itself.
"""
mutable struct StepsizeCallback{RealT}
  cfl_number::RealT
end

function Base.show(io::IO, cb::DiscreteCallback{<:Any, <:StepsizeCallback})
  @nospecialize cb # reduce precompilation time

  stepsize_callback = cb.affect!
  @unpack cfl_number = stepsize_callback
  print(io, "StepsizeCallback(cfl_number=", cfl_number, ")")
end

function Base.show(io::IO, ::MIME"text/plain", cb::DiscreteCallback{<:Any, <:StepsizeCallback})
  @nospecialize cb # reduce precompilation time

  if get(io, :compact, false)
    show(io, cb)
  else
    stepsize_callback = cb.affect!

    setup = [
             "CFL number" => stepsize_callback.cfl_number,
            ]
    summary_box(io, "StepsizeCallback", setup)
  end
end

function StepsizeCallback(; cfl::Real=1.0)

  stepsize_callback = StepsizeCallback(cfl)

  DiscreteCallback(stepsize_callback, stepsize_callback, # the first one is the condition, the second the affect!
                   save_positions=(false,false),
                   initialize=initialize!)
end

function initialize!(cb::DiscreteCallback{Condition,Affect!}, u, t, integrator) where {Condition, Affect!<:StepsizeCallback}
  cb.affect!(integrator)
end

# this method is called to determine whether the callback should be activated
function (stepsize_callback::StepsizeCallback)(u, t, integrator)
  return true
end

# This method is called as callback during the time integration.
@inline function (stepsize_callback::StepsizeCallback)(integrator)
  # TODO: Taal decide, shall we set the time step even if the integrator is adaptive?
  if !integrator.opts.adaptive
    t = integrator.t
    u_ode = integrator.u
    semi = integrator.p
    mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
    @unpack cfl_number = stepsize_callback
    u = wrap_array(u_ode, mesh, equations, solver, cache)

    dt = @timed timer() "calculate dt" cfl_number * max_dt(u, t, mesh,
                                                                  have_constant_speed(equations), equations,
                                                                  solver, cache)
    set_proposed_dt!(integrator, dt)
    integrator.opts.dtmax = dt
    integrator.dtcache = dt
  end

  # avoid re-evaluating possible FSAL stages
  u_modified!(integrator, false)
  return nothing
end

# Time integration methods from the DiffEq ecosystem without adaptive time stepping on their own
# such as `CarpenterKennedy2N54` require passing `dt=...` in `solve(ode, ...)`. Since we don't have
# an integrator at this stage but only the ODE, this method will be used there. It's called in
# many examples in `solve(ode, ..., dt=stepsize_callback(ode), ...)`.
function (cb::DiscreteCallback{Condition,Affect!})(ode::ODEProblem) where {Condition, Affect!<:StepsizeCallback}
  stepsize_callback = cb.affect!
  @unpack cfl_number = stepsize_callback
  u_ode = ode.u0
  t = first(ode.tspan)
  semi = ode.p
  mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
  u = wrap_array(u_ode, mesh, equations, solver, cache)

  return cfl_number * max_dt(u, t, mesh, have_constant_speed(equations), equations, solver, cache)
end

include("stepsize_dg1d.jl")
include("stepsize_dg2d.jl")
include("stepsize_dg3d.jl")


text:
# struct Simulation{DT <: Number, AT <: OffsetArray{DT,3}}
#     Δt::DT
#     nt::Int
#     x::AT

#     function Simulation(x₀::AbstractArray{DT,2}, Δt::DT, nt::Int) where {DT}
#         x = OffsetArray(zeros(DT, size(x₀)..., nt+1), axes(x₀)..., 0:nt)
#         x[:,:,0] .= x₀
#         new{DT, typeof(x)}(Δt, nt, x)
#     end
# end

struct Simulation{DT <: Number}
    Δt::DT
    nt::Int
    x::OffsetArray{DT,3,Array{DT,3}}

    function Simulation(x₀::AbstractArray{DT,2}, Δt::DT, nt::Int) where {DT}
        x = OffsetArray(zeros(DT, size(x₀)..., nt+1), axes(x₀)..., 0:nt)
        x[:,:,0] .= x₀
        new{DT}(Δt, nt, x)
    end
end

function run!(sim::Simulation)
    for n in 1:sim.nt
        for i in axes(sim.x, 2)
            sim.x[1,i,n] = sim.x[1,i,n-1] + sim.Δt * sim.x[2,i,n-1]
            sim.x[2,i,n] = sim.x[2,i,n-1] - sim.Δt * sin(sim.x[1,i,n-1])
        end
    end
    return sim.x
end

max_stars_repo_name: michakraus/JuliaAtHomeAssignments

max_issues_repo_name: michakraus/JuliaAtHomeAssignments

max_forks_repo_name: michakraus/JuliaAtHomeAssignments