class LdaUtil {

    static DenseMatrix dirichletExpectation(DenseMatrix alpha) {
        DenseMatrix rowSum = sumByCol(alpha);
        DenseMatrix digAlpha = digamma(alpha);
        DenseMatrix digRowSum = digamma(rowSum);
        for (int j = 0; j < alpha.numCols(); j++) {
            for (int i = 0; i < alpha.numRows(); i++) {
                digAlpha.set(i, j, digAlpha.get(i, j) - digRowSum.get(0, i));
            }
        }
        return digAlpha;
    }

}