Converts parameter matrices into an array.
510090
def __unroll(self, rolled):
        """"""
        return np.array(np.concatenate([matrix.flatten() for matrix in rolled], axis=1)).reshape(-1)
277273
def to_numpy(self):
        
        import numpy as np
        cols, rows = self.GetNcols(), self.GetNrows()
        return np.matrix([[self(i, j)
            for j in range(cols)]
            for i in range(rows)])
418302
def matrix_params_from_table(table, transpose=False):
    
    classes = sorted(table.keys())
    map_dict = {k: 0 for k in classes}
    TP_dict = map_dict.copy()
    TN_dict = map_dict.copy()
    FP_dict = map_dict.copy()
    FN_dict = map_dict.copy()
    for i in classes:
        TP_dict[i] = table[i][i]
        sum_row = sum(list(table[i].values()))
        for j in classes:
            if j != i:
                FN_dict[i] += table[i][j]
                FP_dict[j] += table[i][j]
                TN_dict[j] += sum_row - table[i][j]
    if transpose:
        temp = FN_dict
        FN_dict = FP_dict
        FP_dict = temp
        table = transpose_func(classes, table)
    return [classes, table, TP_dict, TN_dict, FP_dict, FN_dict]
762924
def get_map_matrix(inputfile):
    
    matrix = read_input_file(inputfile)
    output = []
    for row in matrix:
        if row[3]:
            output.append([row[3], row[1], row[2]])
    return output
613224
function coordMatrixToCoordArray(coordMatrix) {
                var coodinatesArray = new Array(coordMatrix.length * coordMatrix[0].length);
                var k = 0;
                for (var i = 0; i < coordMatrix[0].length; ++i) {
                    for (var j = 0; j < coordMatrix.length; ++j) {
                        coodinatesArray[k] = coordMatrix[j][i];
                        ++k;
                    }
                }

                return coodinatesArray;
            }
937124
function arrayToMatrix (a) {
  return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] }
}
486847
def scipy_sparse_to_spmatrix(A):
    """"""
    coo = A.tocoo()
    SP = spmatrix(coo.data.tolist(), coo.row.tolist(), coo.col.tolist(), size=A.shape)
    return SP
118480
function subMatrix (data, numRows, numCols, row, col) {
  var sub = []

  for (var i = 0; i < numRows; i++) {
    for (var j = 0; j < numCols; j++) {
      if ((i !== row) && (j !== col)) {
        sub.push(data[matrixToArrayIndex(i, j, numCols)])
      }
    }
  }

  return sub
}
385345
def rippe_parameters(matrix, positions, lengths=None, init=None, circ=False):
    

    n, _ = matrix.shape

    if lengths is None:
        lengths = np.abs(np.diff(positions))

    measurements, bins = [], []
    for i in range(n):
        for j in range(1, i):
            mean_length = (lengths[i] + lengths[j]) / 2.
            if positions[i] < positions[j]:
                d = (((positions[j] - positions[i] -
                     lengths[i]) + mean_length) /
                     1000.)
            else:
                d = (((positions[i] - positions[j] -
                     lengths[j]) + mean_length) /
                     1000.)

            bins.append(np.abs(d))
            measurements.append(matrix[i, j])
    parameters = estimate_param_rippe(measurements, bins, init=init, circ=circ)
    print(parameters)
    return parameters[0]
19444
function(sbmA, sbmB) {
    // if not the same sizes
    if (sbmA.x != sbmB.x || sbmA.y != sbmB.y) {
      return
    }
    // create the matrix
    var mat = {}
    mat.x = sbmA.x
    mat.y = sbmA.y
    mat.data = []
    // populate
    for (var i = 0; i < mat.x; i++) {
      mat.data[i] = _.union(sbmA.data[i], sbmB.data[i]).sort()
    }
    // return matrix
    return mat
  }
643857
def to_sympy_matrix(value):
    
    if isinstance(value, sympy.Matrix):
        return value
    try:
        return sympy.Matrix(value)
    except ValueError as original_exception:
        if isinstance(value, list) and len(value) and all([not isinstance(x, list) for x in value]):
            # Let's try to convert the contents into a list
            # (this is required for 0.7.4 if we pass in a list of strings)
            # See `test_creation_of_column_matrix_from_list_of_strings` test
            list_of_lists_value = [[x] for x in value]
            try:
                m = sympy.Matrix(list_of_lists_value)
                return m
            except Exception:
                raise original_exception
        else:
            raise original_exception
1067559
function getData(matrix, array) {
  toArray(matrix, array);

  array.rows = matrix.rows;
  array.cols = matrix.cols;

  return array;
}
207355
def paramsarraybounds(self):
        """"""
        bounds = []
        for (i, param) in self._index_to_param.items():
            if isinstance(param, str):
                bounds.append(self.model.PARAMLIMITS[param])
            elif isinstance(param, tuple):
                bounds.append(self.model.PARAMLIMITS[param[0]])
            else:
                raise ValueError("Invalid param type")
        bounds = [(tup[0] + ALMOST_ZERO, tup[1] - ALMOST_ZERO) for tup in bounds]
        assert len(bounds) == len(self._index_to_param)
        return tuple(bounds)
306395
def matrix_to_blockmatrix(self, blocksize):
        
        if self.get_width() % blocksize or self.get_height() % blocksize:
            raise ValueError("Number of rows and columns have to be evenly dividable by blocksize")
        selfBlocks = []
        for columnIndex in range(0, self.get_width() - 1, blocksize):
            for rowIndex in range(0, self.get_height() - 1, blocksize):
                currentBlock = []
                for blockRows in self.get_array(False)[columnIndex:columnIndex + blocksize]:
                    currentBlock += blockRows[rowIndex:rowIndex + blocksize]
                selfBlocks.append(Matrix(blocksize, blocksize, currentBlock, rowBased=False))
        return Matrix(self.get_width() / blocksize, self.get_height() / blocksize, selfBlocks, rowBased=False)
870897
public static double[][] getMatrix(final double[][] m1, final int r0, final int r1, final int c0, final int c1) {
    assert r0 <= r1 && c0 <= c1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length && c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    final int rowdim = r1 - r0, coldim = c1 - c0;
    final double[][] X = new double[rowdim][coldim];
    for(int i = r0; i < r1; i++) {
      System.arraycopy(m1[i], c0, X[i - r0], 0, coldim);
    }
    return X;
  }
321835
public static DenseMatrix from1DArray(int rows, int columns, double[] array) {
        return Basic1DMatrix.from1DArray(rows, columns, array);
    }
136266
def toArray(self):
        
        if self.isTransposed:
            return np.asfortranarray(
                self.values.reshape((self.numRows, self.numCols)))
        else:
            return self.values.reshape((self.numRows, self.numCols), order='F')