Optimize matrix multiplications Given:


*

*vectors $v1, v2$ $(n\times1)$ where entries in each vector are in the interval $[0,1]$. $v1$ and $v2$ can be sparse or dense

*a dense symmetric matrix $M$ $(n\times n)$ (actually a logic matrix where entries are $0$ or $1$) 

*a dense matrix $E$ $(n\times n)$ where $E(i,j) = 1-E(j,i)$ if $E(i,j) \neq 0$, $E(i,j) = 0$ if $i=j$ and $E(i,j$) is in the interval $[0,1[$. 
Is there a name for this type of matrix?
I would like to compute $s = Sum[(v1 * v2^{T})  .* M]$ where .* is the element-wise multiplication operation and Sum is the sum over all entries of the resulting matrix. ^$T$ is the transposition operation.
Given $s$ I would like to obtain  $x = Sum[(v1 \cdot v2^{T}) \cdot * E] / s$
Is there any computationally more efficient way to perform these multiplications and obtain $x$?
Thanks.

The $(i,j)$th entry of the outer product matrix $vw_T$ is, by the definition of matrix multiplication,
$$\sum_{k=1}^1 v_{ik}w^T_{kj} = v_{i1}w^T_{1j} = v_i w_j.$$
Therefore the $(i,j)$th entry of the entrywise product $vw^T * M$ is $v_iw_jM_{ij}$, and as Karakfa points out,
$$\sum_{i,j} (vw^T * M)_{ij} = \sum_{i,j} v_i w_j M_{ij} = \sum_i v_{i1} \sum_j M_{ij}w_{j1} = \sum_i v^T_{1i} (Mw)_{i1} = v^TMw.$$
Therefore you want to compute
$$x= \frac{v_1^T E v_2}{v_1 ^T M v_2},$$
which requires only two matrix-vector multiplications (and two much cheaper vector dot products, and a scalar division).
I don't see any way of taking advantage of $E$'s structure.
