clean up
This commit is contained in:
parent
3b80b8c720
commit
65c394743b
3 changed files with 2 additions and 34 deletions
|
@ -132,8 +132,6 @@ end
|
||||||
x = σ * (2 * rand() - 0.5) + μ
|
x = σ * (2 * rand() - 0.5) + μ
|
||||||
p = [L, μ, σ]
|
p = [L, μ, σ]
|
||||||
|
|
||||||
@show diff_of_erf(p; x=x)
|
|
||||||
|
|
||||||
@test TaylorTest.check(diff_of_erf, J_diff_of_erf, p; x=x)
|
@test TaylorTest.check(diff_of_erf, J_diff_of_erf, p; x=x)
|
||||||
@test TaylorTest.check(J_diff_of_erf, H_diff_of_erf, p, [2, 3]; x=x)
|
@test TaylorTest.check(J_diff_of_erf, H_diff_of_erf, p, [2, 3]; x=x)
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,23 +38,6 @@ end
|
||||||
@test TaylorTest.check(J_gauss, H_gauss, p; x=x)
|
@test TaylorTest.check(J_gauss, H_gauss, p; x=x)
|
||||||
end
|
end
|
||||||
|
|
||||||
function check_symmetry(a)
|
|
||||||
R = true
|
|
||||||
if ndims(a) == 2
|
|
||||||
R = norm(a - a') < 1e-10
|
|
||||||
else
|
|
||||||
for i in axes(a, 1)
|
|
||||||
r = a[i, :, :]' == a[i, :, :]
|
|
||||||
R &= r
|
|
||||||
if !r
|
|
||||||
n = maximum(abs, a[i, :, :]' - a[i, :, :])
|
|
||||||
@warn "Tensor not symmetric at i=$i: $n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return R
|
|
||||||
end
|
|
||||||
|
|
||||||
@testset "Composed Gauss function" begin
|
@testset "Composed Gauss function" begin
|
||||||
p = 1 .+ 5rand(6)
|
p = 1 .+ 5rand(6)
|
||||||
|
|
||||||
|
|
|
@ -29,19 +29,6 @@ end
|
||||||
|
|
||||||
TP = TO.tensorproduct
|
TP = TO.tensorproduct
|
||||||
|
|
||||||
function check_symmetry(a)
|
|
||||||
R = true
|
|
||||||
for i in axes(a, 1)
|
|
||||||
r = a[i,:,:]' == a[i,:,:]
|
|
||||||
R &= r
|
|
||||||
if !r
|
|
||||||
n = maximum(abs, a[i,:,:]' - a[i,:,:])
|
|
||||||
@warn "Tensor not symmetric at i=$i: $n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return R
|
|
||||||
end
|
|
||||||
|
|
||||||
function prod(A, B)
|
function prod(A, B)
|
||||||
return TP([1, 2, 3], A, [1, 2], B, [3])
|
return TP([1, 2, 3], A, [1, 2], B, [3])
|
||||||
end
|
end
|
||||||
|
@ -76,14 +63,14 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
φ = x -> x[1] * x[2]^2
|
φ = x -> x[1] * x[2]^2
|
||||||
∇φ = x -> [x[2]^2; 2x[1]*x[2]]
|
∇φ = x -> [x[2]^2; 2x[1] * x[2]]
|
||||||
Hφ = x -> [
|
Hφ = x -> [
|
||||||
0 2x[2];
|
0 2x[2];
|
||||||
2x[2] 2*x[1]
|
2x[2] 2*x[1]
|
||||||
]
|
]
|
||||||
|
|
||||||
f = x -> v(x) * φ(x)
|
f = x -> v(x) * φ(x)
|
||||||
Jf = x -> φ(x) * Jv(x) + v(x)*∇φ(x)'
|
Jf = x -> φ(x) * Jv(x) + v(x) * ∇φ(x)'
|
||||||
Hf = x -> φ(x) * Hv(x) + symprod(Jv(x), ∇φ(x)) + TP(v(x), [1], Hφ(x), [2, 3])
|
Hf = x -> φ(x) * Hv(x) + symprod(Jv(x), ∇φ(x)) + TP(v(x), [1], Hφ(x), [2, 3])
|
||||||
|
|
||||||
x = 2rand(2) .- 0.5
|
x = 2rand(2) .- 0.5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue