I would like to cast some problems involving a symmetric hollow (diagonal entries equal to $0$) matrix in an equivalent form represented by the vectorization of the matrix. I know that if the matrix is only symmetric, then an effective way is to use the half-vectorization of the matrix and the use of duplication and elimination matrices. I would like to find something similar to the case of hollow symmetric matrices.
I have a real-valued function $f$ with argument a symmetric hollow matrix $\mathbf{A}$. Because all the information of the matrix is stored in the strictly lower (or upper) triangular part of the matrix, call it $\mathbf{A}_1$ , I guess there should be a way to rewrite the function by using the vectorization of the matrix $\mathbf{A}_1$, i.e. $\mathbf{a}=\mathbf{A}_1$.
For instance, considering a symmetric matrix $\mathbf{B}$:
$$ f(\mathbf{A})= \operatorname{trace}(\mathbf{A}\mathbf{B}) = 2 \mathbf{a}^{\top}\mathbf{b}$$
This is immediate with this particular function, but how can I generalize to other functions? For instance, what about $ f(\mathbf{A})= \operatorname{trace}(\mathbf{A}^\top\mathbf{A}\mathbf{B})$. Can in general also the product $\mathbf{A}\mathbf{A}$ be rewritten with a particular reshape of the vectors product?
Thank you
EDIT
If I have function $f(\mathbf{A})$, can I compute in this case gradient and Hessian in the hollow-half-vec space, and being able to compute back the associated matrices? As a related subquestion, is the $\operatorname{vechh(\cdot)}$ an invertible operation? Of course, once that I have $\mathbf{a}=\operatorname{vechh(\mathbf{A})}$ I can easily reshape the vector in a way to get back $\mathbf{A}$. However, how is this mathematically represented? I should be able to do something like:
$$ \mathbf{A}= \operatorname{vec}^{-1} (\mathbf{D}\mathbf{H}^{-1}\mathbf{a}) \mathbf{P}^\top= \operatorname{vec}^{-1} (\mathbf{D}\mathbf{H}^{-1}\mathbf{H}\mathbf{E}\operatorname{vec}(\mathbf{AP})) \mathbf{P}^\top $$
where $\mathbf{D}$,$ \mathbf{E}$ are the duplication and elimination matrices, respectively, and $\mathbf{H}^{-1}$ is the inverse of the "hollow" matrix $\mathbf{H}=[\mathbf{0}_{l\times n} \mathbf{I}_l]$.
As a case study, we could take $f(\mathbf{A})= \operatorname{trace}(\mathbf{A}\mathbf{B}) = 2 \mathbf{a}^{\top}\mathbf{b}$, with $\mathbf{A}$, $\mathbf{B}$ symmetric matrices, $\mathbf{A}$ hollow. It would be nice to have a methodology to express each function $f(\mathbf{A})$ in an equivalent form $f(\mathbf{a})$.