This commit is contained in:
Gaspard Jankowiak 2025-02-12 11:04:31 +01:00
commit 65c394743b
3 changed files with 2 additions and 34 deletions

View file

@ -29,19 +29,6 @@ end
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)
return TP([1, 2, 3], A, [1, 2], B, [3])
end
@ -76,14 +63,14 @@ end
end
φ = x -> x[1] * x[2]^2
∇φ = x -> [x[2]^2; 2x[1]*x[2]]
∇φ = x -> [x[2]^2; 2x[1] * x[2]]
= x -> [
0 2x[2];
2x[2] 2*x[1]
]
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], (x), [2, 3])
x = 2rand(2) .- 0.5