print matrix according to viterbi alignment like
          fs
     -------------
    e|x| | | |
    s| |x| | |
     | | | |x|
     | | |x| |
     -------------
771452
def show_matrix(es, fs, t, a):
    '''
    
    '''

    max_a = viterbi_alignment(es, fs, t, a).items()
    m = len(es)
    n = len(fs)
    return matrix(m, n, max_a, es, fs)
1303190
public void printCoordinate(int[] row, int[] column, float[] dataR,
            float[] dataI) {
        printCoordinate(row, column, dataR, dataI, 0);
    }
290271
public static DMatrixRMaj convert(DMatrix6x6 input , DMatrixRMaj output ) {
        if( output == null)
            output = new DMatrixRMaj(6,6);

        output.reshape(input.getNumRows(),input.getNumCols());

        output.data[0] = input.a11;
        output.data[1] = input.a12;
        output.data[2] = input.a13;
        output.data[3] = input.a14;
        output.data[4] = input.a15;
        output.data[5] = input.a16;
        output.data[6] = input.a21;
        output.data[7] = input.a22;
        output.data[8] = input.a23;
        output.data[9] = input.a24;
        output.data[10] = input.a25;
        output.data[11] = input.a26;
        output.data[12] = input.a31;
        output.data[13] = input.a32;
        output.data[14] = input.a33;
        output.data[15] = input.a34;
        output.data[16] = input.a35;
        output.data[17] = input.a36;
        output.data[18] = input.a41;
        output.data[19] = input.a42;
        output.data[20] = input.a43;
        output.data[21] = input.a44;
        output.data[22] = input.a45;
        output.data[23] = input.a46;
        output.data[24] = input.a51;
        output.data[25] = input.a52;
        output.data[26] = input.a53;
        output.data[27] = input.a54;
        output.data[28] = input.a55;
        output.data[29] = input.a56;
        output.data[30] = input.a61;
        output.data[31] = input.a62;
        output.data[32] = input.a63;
        output.data[33] = input.a64;
        output.data[34] = input.a65;
        output.data[35] = input.a66;

        return output;
    }
772292
def _print_bits(self,norm=2.3, height=8.0):
        
        bits   = []
        tots   = []
        str    = []
        for i in range(self.width):
            D = {}
            tot = 0
            for letter in ['A', 'C', 'T', 'G']:
                if self.logP:
                    Pij = pow(2.0, self.logP[i][letter])
                else:
                    Pij = pow(2.0, self.ll[i][letter]) * self.background[letter]
                if Pij > 0.01:
                    '''Old'''
                    D[letter] = Pij * self.ll[i][letter]
                    #'''new'''
                    #Q = self.background[letter]
                    #D[letter] = ( Pij * math.log(Pij) - Pij * math.log(Q) ) / math.log(2.0)
                    '''for both old and new'''
                    tot = tot + D[letter]
            bits.append(D)
            tots.append(tot)
        for i in range(self.width):
            s = []
            _l = bits[i].keys()
            _l.sort(lambda x,y,D=bits[i]: cmp(D[y],D[x]))
            for key in _l:
                for j in range(int(bits[i][key] / norm * height)):
                    s.append(key)
            str.append(''.join(s))
        fmt = '%%%ds'%height
        print '#  %s'%('-'*self.width)
        for h in range(int(height)):
            sys.stdout.write("#  ")
            for i in range(self.width):
                sys.stdout.write((fmt%str[i])[h])
            if h == 0:
                sys.stdout.write(' -- %4.2f bits\n'%norm)
            elif h == height-1:
                sys.stdout.write(' -- %4.2f bits\n'%(norm/height))
            else:
                sys.stdout.write('\n')
        print '#  %s'%('-'*self.width)
        print '#  %s'%self.oneletter
600535
def Ry_matrix(theta):
    """"""
    return np.array([
        [np.cos(theta), 0, np.sin(theta)],
        [0, 1, 0],
        [-np.sin(theta), 0, np.cos(theta)]
    ])
1144756
def printSequences(x, formatString="%d"):
  
  [seqLen, numElements] = x.shape
  for i in range(seqLen):
    s = ""
    for j in range(numElements):
      s += formatString % x[i][j]
    print s
1102274
def print_matrix(self, one_vs_all=False, class_name=None):
        
        classes = self.classes
        table = self.table
        if one_vs_all:
            [classes, table] = one_vs_all_func(
                classes, table, self.TP, self.TN, self.FP, self.FN, class_name)
        print(table_print(classes, table))
843960
def viterbi_alignment(es, fs, t, a):
    '''
    
    '''
    max_a = collections.defaultdict(float)
    l_e = len(es)
    l_f = len(fs)
    for (j, e) in enumerate(es, 1):
        current_max = (0, -1)
        for (i, f) in enumerate(fs, 1):
            val = t[(e, f)] * a[(i, j, l_e, l_f)]
            # select the first one among the maximum candidates
            if current_max[1] < val:
                current_max = (i, val)
        max_a[j] = current_max[0]
    return max_a
255407
public static void printMatrix(byte[][] matrix, int maxX, int maxY, PrintStream stream) {
		for(int i = 0; i < maxX; i++) {
			for(int j = 0; j < maxY; j++) {
				stream.print(matrix[i][j] + " ");
			}
			stream.print("\n");
		}
		stream.println();
	}
1298914
def print_fold(column_to_fold, total_columns, skips):
    """"""
    format_str = '{:<2}' * (total_columns - 1)
    cols = []
    for i in range(column_to_fold):
        # print(i)
        if i in skips:
            cols.append("  ")
        else:
            cols.append("| ")
    for i in range(column_to_fold + 1, total_columns):
        # print(i)
        if i in skips:
            cols.append("  ")
        else:
            cols.append(" /")
    print(format_str.format(*cols))
414269
def alignfast(names, seqs):
    
    matfile = op.join(datadir, "blosum80.mat")
    cmd = "poa -read_fasta - -pir stdout {0} -tolower -silent -hb -fuse_all".format(matfile)
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
    s = ""
    for i, j in zip(names, seqs):
        s += "\n".join((i, j)) + "\n"
    return p.communicate(s)[0]
625225
function matrix(rows, columns, values) {
    // console.log(values);
    const res = [];
    let row = [];
    let real;
    values.forEach((v, i) => {
        if (i % 2 == 0) {
            real = v;
        } else {
            row.push({
                real: real,
                imag: v
            });
            if ((i + 1) / 2 % columns == 0) {
                res.push(row);
                row = [];
            }
        }
    });
    return res;
}
242889
function printMatrix2 (m) {
  const tStr = m.elements.map(formatPrintNumber);
  const matrixString = `
  +-                -+
  | ${tStr[0]}  ${tStr[2]} |
  | ${tStr[1]}  ${tStr[3]} |
  +-                -+`;
  return matrixString;
}
853098
public void printSparseFeatureMatrix(PrintWriter pw) {
    String sep = "\t";
    for (int i = 0; i < size; i++) {
      pw.print(labelIndex.get(labels[i]));
      int[] datum = data[i];
      for (int j : datum) {
        pw.print(sep + featureIndex.get(j));
      }
      pw.println();
    }
  }
650167
def pretty_print(n):
    """"""
    if type(n) != int:
        return n

    ret = []
    n = str(n)
    for i in range(len(n) - 1, -1, -1):
        ret.append(n[i])
        if (len(n) - i) % 3 == 0:
            ret.append(',')
    ret.reverse()
    return ''.join(ret[1:]) if ret[0] == ',' else ''.join(ret)
1358133
def vis(bs):
    
    bs = bytearray(bs)
    symbols_in_one_line = 8
    n = len(bs) // symbols_in_one_line
    i = 0
    for i in range(n):
        print(str(i*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[i*symbols_in_one_line:(i+1)*symbols_in_one_line]])) # for every 8 symbols line
    if not len(bs) % symbols_in_one_line == 0:
        print(str((i+1)*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[(i+1)*symbols_in_one_line:]])+"\n")
1257270
public function displayMatrix()
    {
        $this->setupMatrix();

        $oneSize = mb_strlen($this->compOne, 'UTF-8');
        $twoSize = mb_strlen($this->compTwo, 'UTF-8');

        $out = '  ' . $this->compOne . PHP_EOL;
        for ($y = 0; $y <= $twoSize; $y += 1) {
            if ($y - 1 < 0) {
                $out .= ' ';
            } else {
                $out .= mb_substr($this->compTwo, $y - 1, 1, 'UTF-8');
            }

            for ($x = 0; $x <= $oneSize; $x += 1) {
                $out .= $this->matrix[$x][$y];
            }

            $out .= PHP_EOL;
        }

        return $out;
    }