Computing scalar product using Mat object

Hello,

I was reading this response on another post, which mentions using a Mat object to compute a scalar product. For example, given:
real[int] v;
Mat J;
J(v, v);

then, as the response says, “J(v, v) computes a scalar product according to the domain decomposition of J.”

I’m curious as to why J(v,v) gives the scalar product? Is this a mathematical property, or is it more a feature of FreeFem / PETSc? Does this always work for any Mat object we create?

It’s just a notation. It works with any Mat as long as it comes from a domain-decomposed mesh (i.e., it was built using MatCreate()).

Thank you @prj for the response!
Is there any mathematical reasoning behind that notation? I just wasn’t sure if there was an intuitive way to understand why something like J(v,v) would give a scalar product.

You could think of it as the scalar product weighted by the partition of unity held by the Mat: v^{T} J\text{.D} v.