Create a full data matrix starting form a symmetric matrix filled only in its subdiagonal elements.
551400
protected DoubleMatrix2D createFullDataMatrix(DoubleMatrix2D SubDiagonalSymmMatrix){
		int c = SubDiagonalSymmMatrix.columns();
		DoubleMatrix2D ret = F2.make(c, c);
		for(int i=0; i<c; i++){
			for(int j=0; j<=i; j++){
				ret.setQuick(i, j, SubDiagonalSymmMatrix.getQuick(i, j));
				ret.setQuick(j, i, SubDiagonalSymmMatrix.getQuick(i, j));
			}
		}
		return ret;
	}
814544
def build(self, x, h, mask=None):
        '''
        
        '''
        xw = tf.split(tf.matmul(x, self.w_matrix) + self.bias, 3, 1)
        hu = tf.split(tf.matmul(h, self.U), 3, 1)
        r = tf.sigmoid(xw[0] + hu[0])
        z = tf.sigmoid(xw[1] + hu[1])
        h1 = tf.tanh(xw[2] + r * hu[2])
        next_h = h1 * (1 - z) + h * z
        if mask is not None:
            next_h = next_h * mask + h * (1 - mask)
        return next_h
311851
def get_matrix(self, indices):
        """"""
        new = numpy.empty(self.samples1.shape)
        for idx in range(len(indices)):
            if indices[idx]:
                new[idx] = self.samples1[idx]
            else:
                new[idx] = self.samples2[idx]

        if self.poly:
            new = self.poly(*new)
        return new
380204
def to_matrix(self, n_qubits=-1):
        """"""
        if n_qubits == -1:
            n_qubits = self.max_n() + 1
        return sum(term.to_matrix(n_qubits) for term in self.terms)
1213153
def make_symmetric_matrix_from_upper_tri(val):
    
    idx = [0,3,4,1,5,2]
    val = np.array(val)[idx]
    mask = ~np.tri(3,k=-1,dtype=bool)
    out = np.zeros((3,3),dtype=val.dtype)
    out[mask] = val
    out.T[mask] = val
    return out
373605
public IMatrix sub(IMatrix b) {
        IMatrix result = new IMatrix(rows, columns);
        sub(b, result);
        return result;
    }
1366296
def get_full_psd_matrix(self):
    
    if self.matrix_m is not None:
      return self.matrix_h, self.matrix_m

    # Computing the matrix term
    h_columns = []
    for i in range(self.nn_params.num_hidden_layers + 1):
      current_col_elems = []
      for j in range(i):
        current_col_elems.append(
            tf.zeros([self.nn_params.sizes[j], self.nn_params.sizes[i]]))

    # For the first layer, there is no relu constraint
      if i == 0:
        current_col_elems.append(utils.diag(self.lambda_lu[i]))
      else:
        current_col_elems.append(
            utils.diag(self.lambda_lu[i] + self.lambda_quad[i]))
      if i < self.nn_params.num_hidden_layers:
        current_col_elems.append(tf.matmul(
            utils.diag(-1 * self.lambda_quad[i + 1]),
            self.nn_params.weights[i]))
      for j in range(i + 2, self.nn_params.num_hidden_layers + 1):
        current_col_elems.append(
            tf.zeros([self.nn_params.sizes[j], self.nn_params.sizes[i]]))
      current_column = tf.concat(current_col_elems, 0)
      h_columns.append(current_column)

    self.matrix_h = tf.concat(h_columns, 1)
    self.matrix_h = (self.matrix_h + tf.transpose(self.matrix_h))

    self.matrix_m = tf.concat(
        [
            tf.concat([tf.reshape(self.nu, (1, 1)), tf.transpose(self.vector_g)], axis=1),
            tf.concat([self.vector_g, self.matrix_h], axis=1)
        ],
        axis=0)
    return self.matrix_h, self.matrix_m
270641
function(fn) {
    var els = [], ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j;
    do { i = ki - ni;
      nj = kj;
      els[i] = [];
      do { j = kj - nj;
        els[i][j] = fn(this.elements[i][j], i + 1, j + 1);
      } while (--nj);
    } while (--ni);
    return Matrix.create(els);
  }
367170
public static Basic2DMatrix from1DArray(int rows, int columns, double[] array) {
        double[][] array2D = new double[rows][columns];

        for (int i = 0; i < rows; i++) {
            System.arraycopy(array, i * columns, array2D[i], 0, columns);
        }

        return new Basic2DMatrix(array2D);
    }
1311534
def _fill_diagonals(self, m):
        """"""
        assert m.shape == (self.nsites, N_CODON, N_CODON)
        for r in range(self.nsites):
            scipy.fill_diagonal(m[r], 0)
            m[r][self._diag_indices] -= scipy.sum(m[r], axis=1)
569420
function() {
            var m = this.m,
                a = m.a,
                b = m.b,
                c = m.c,
                d = m.d,
                e = m.e,
                f = m.f,
                k, aa, bb, cc, dd, ee, ff;
            k = a * d - b * c;
            aa = d / k;
            bb = -b / k;
            cc = -c / k;
            dd = a / k;
            ee = (c * f - e * d) / k;
            ff = (b * e - a * f) / k;
            return new Matrix(aa, bb, cc, dd, ee, ff);
        }
1321172
private void fillKsubMatrix( Coordinate[] controlPoints, GeneralMatrix L ) {
        double alfa = 0;
        int controlPointsNum = controlPoints.length;
        for( int i = 0; i < controlPointsNum; i++ ) {
            for( int j = i + 1; j < controlPointsNum; j++ ) {
                double u = calculateFunctionU(controlPoints[i], controlPoints[j]);
                L.setElement(i, j, u);
                L.setElement(j, i, u);
                alfa = alfa + (u * 2); // same for upper and lower part
            }
        }

        alfa = alfa / (controlPointsNum * controlPointsNum);
    }
1029866
public Matrix getMatrix(int i0, int i1, int j0, int j1)
    {
        Matrix X = new Matrix(i1 - i0 + 1, j1 - j0 + 1);
        double[][] B = X.getArray();
        try
        {
            for (int i = i0; i <= i1; i++)
            {
                for (int j = j0; j <= j1; j++)
                {
                    B[i - i0][j - j0] = A[i][j];
                }
            }
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            throw new ArrayIndexOutOfBoundsException("Submatrix indices");
        }
        return X;
    }
1011640
private static boolean[] createInitialR(CompRowMatrix A) {
            boolean[] R = new boolean[A.numRows()];

            int[] rowptr = A.getRowPointers();
            int[] colind = A.getColumnIndices();
            double[] data = A.getData();

            for (int i = 0; i < A.numRows(); ++i) {
                boolean hasOffDiagonal = false;

                for (int j = rowptr[i]; j < rowptr[i + 1]; ++j)
                    if (colind[j] != i && data[j] != 0) {
                        hasOffDiagonal = true;
                        break;
                    }

                R[i] = hasOffDiagonal;
            }

            return R;
        }
239828
@Override
    protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
        return new StatisticsMatrix(numRows,numCols);
    }
655070
def from_columns(columns):
        
        data = [
            [
                column[i]
                for i in range(len(column))
            ]
            for column in columns
        ]
        return Matrix(data)
753034
def _create_model_matrices(self):
        

        self.model_Y = self.data
        self.model_scores = np.zeros((self.X.shape[1], self.model_Y.shape[0]+1))