fcn(policy, m, s);
    dd = length(M); dMds = reshape(dMds,dd,d,d); df = zeros(dd,d*(d+1)/2);
    <span class="keyword">for</span> i=1:dd;
        dMdsi(:,:) = dMds(i,:,:); dMdsi = dMdsi + dMdsi'-diag(diag(dMdsi));
        df(i,:) = dMdsi(tril(ones(d))==1);
    <span class="keyword">end</span>
<span class="keyword">end</span>
f = M;

<span class="keyword">function</span> [f, df] = conT4(s, policy, m)                                  <span class="comment">% dSds</span>
d = length(m);
v(tril(ones(d))==1) = s;