innergrad

Inner product of gradient evaluations stored as real matrices (arrays).

Contents

Syntax

res = innergrad(gus,gvs,seti)

Description

res = innergrad(gus,gvs,seti) computes the inner product of the gradient evalutations $\langle \mathrm{grad}(u), \mathrm{grad}(v)\rangle|$, which are stored as real matrices (arrays).

Input Arguments

Note: The name "gus" was choosen because gradient from u stored as real (squared, because $\bf{C} = \bf{R} \times \bf{R}$).

Output Argument

More About

We consider the inner product of p and q (e.g. p = grad(u), q = grad(v)):

$\langle p,q \rangle = \sum_{i,j} p_{i,j}^1 q_{i,j}^1 + p_{i,j}^2 + q_{i,j}^2$ in 2D

and $+ p_{i,j}^3 + q_{i,j}^3$ in 3D.

Note that the exponent is an index(!).

The real and imaginary parts are stored as real values in gus and guv, so add all parts (real and imag):

$\langle p,q \rangle = \sum_{i,j} \sum_{l=1}^{2\,\mathrm{dim}} p_{i,j}^l q_{i,j}^l$

Finally, scale it with factor dVinv.

Corresponding notation in [1]

The function innergrad is defined in [1, Sec. 4.5, eq. (59)] as

$\langle x, y \rangle_{\mathrm{tv},\bf{R}} :=  \langle x^{(1)}, y^{(1)} \rangle_{\mathrm{roi},\bf{R}} +  \langle x^{(2)}, y^{(2)} \rangle_{\mathrm{roi},\bf{R}}, \quad  x, y \in Y_{\mathrm{tv},\bf{R}}$

with the following definitions in [1, Sec. 4.5]:

References

See Also

Code

function res = innergrad(gus,gvs,seti)

% guz = seti.T(gus);
% gvz = seti.T(gvs);

add = 0;
for l = 1:2*seti.dim
    add = add + squeeze(gus(l,:,:) .* gvs(l,:,:));
end

if seti.dim == 2
    res = sum(sum(add))*seti.dVinv;
elseif seti.dim == 3
    res = sum(sum(sum(add)))*seti.dVinv;
end

end