Transposes an individual block inside a block matrix.
3048
private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
                                       int indexA , int indexC ,
                                       int width , int height )
    {
        for( int i = 0; i < height; i++ ) {
            int rowIndexC = indexC + i;
            int rowIndexA = indexA + width*i;
            int end = rowIndexA + width;
            for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
                A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
            }
        }
    }
134277
public static DMatrixRMaj convert(DMatrixRBlock src , DMatrixRMaj dst ) {
        if( dst != null ) {
            dst.reshape(src.getNumRows(),src.getNumCols());
        } else {
            dst = new DMatrixRMaj(src.numRows,src.numCols);
        }

        for( int i = 0; i < src.numRows; i += src.blockLength ) {
            int blockHeight = Math.min( src.blockLength , src.numRows - i);

            for( int j = 0; j < src.numCols; j += src.blockLength ) {
                int blockWidth = Math.min( src.blockLength , src.numCols - j);

                int indexSrc = i*src.numCols + blockHeight*j;
                int indexDstRow = i*dst.numCols + j;

                for( int k = 0; k < blockHeight; k++ ) {
                    System.arraycopy(src.data,indexSrc,dst.data,indexDstRow,blockWidth);
                    indexSrc += blockWidth;
                    indexDstRow += dst.numCols;
                }
            }
        }

        return dst;
    }
341544
def transpose(self, permutation: Optional[List[int]] = None) -> 'TensorFluent':
        '''
        '''
        if permutation == []:
            return self
        t = tf.transpose(self.tensor, permutation) if permutation != [] else self.tensor
        scope = self.scope.as_list()
        batch = self.batch
        return TensorFluent(t, scope, batch=batch)
1364487
public Matrix3d transpose(Matrix3d dest) {
        dest.set(m00, m10, m20,
                 m01, m11, m21,
                 m02, m12, m22);
        return dest;
    }
1213799
public static void transposeSquare( BMatrixRMaj mat )
    {
        if( mat.numCols != mat.numRows )
            throw new IllegalArgumentException("Must be sqare");

        int index = 1;
        int indexEnd = mat.numCols;
        for( int i = 0; i < mat.numRows;
             i++ , index += i+1 , indexEnd += mat.numCols ) {
            int indexOther = (i+1)*mat.numCols + i;
            for( ; index < indexEnd; index++, indexOther += mat.numCols) {
                boolean val = mat.data[ index ];
                mat.data[ index ] = mat.data[ indexOther ];
                mat.data[indexOther] = val;
            }
        }
    }
262135
def swap_across(idx, idy, mat_a, mat_r, perm):
    """"""
    # Temporary permutation matrix for swaping 2 rows or columns.
    size = mat_a.shape[0]
    perm_new = numpy.eye(size, dtype=int)

    # Modify the permutation matrix perm by swaping columns.
    perm_row = 1.0*perm[:, idx]
    perm[:, idx] = perm[:, idy]
    perm[:, idy] = perm_row

    # Modify the permutation matrix p by swaping rows (same as
    # columns because p = pT).
    row_p = 1.0 * perm_new[idx]
    perm_new[idx] = perm_new[idy]
    perm_new[idy] = row_p

    # Permute mat_a and r (p = pT).
    mat_a = numpy.dot(perm_new, numpy.dot(mat_a, perm_new))
    mat_r = numpy.dot(mat_r, perm_new)
    return mat_a, mat_r, perm
1005046
public function transpose() : self
    {
        if ($this->m > 1) {
            $b = array_map(null, ...$this->a);
        } else {
            $b = [];

            for ($i = 0; $i < $this->n; $i++) {
                $b[] = array_column($this->a, $i);
            }
        }

        return self::quick($b);
    }
9653
function transpose(matrix) {
	// For NxN matrix
	var n = matrix[0].length;
	var temp;

	// Walk through columns
	for (var i = 0, j = 0; i < n; i++) {
		j = i;
		// Walk through rows
		while (j < n) {
			if (i !== j) {
				temp = matrix[i][j];
				matrix[i][j] = matrix[j][i];
				matrix[j][i] = temp;
			}
			j++;
		}
	}
}
340835
public static RowMajorSparseMatrix block(Matrix a, Matrix b, Matrix c, Matrix d) {
        return CRSMatrix.block(a, b, c, d);
    }
231979
def flatten(self):
        
        blocksize = self.get_array()[0][0].get_width()
        width = self.get_width() * blocksize

        columnsNew = [[] for dummy in xrange(width)]

        for row in self.get_array():
            index = 0
            for submatrix in row:
                for column in submatrix.get_array(False):
                    columnsNew[index] += column
                    index += 1

        columnsFlat = sum(columnsNew, [])
        return Matrix(width, len(columnsNew[0]), columnsFlat, rowBased=False)
155603
@Override
    public DoubleMatrix transpose()
    {
        int m = rows();
        int n = columns();
        ItemSupplier s = supplier;
        DoubleMatrix tr = getInstance(n, m);
        ItemConsumer c = tr.consumer;
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                c.set(j, i, s.get(i, j));
            }
        }
        return tr;
    }
249844
def convert_transpose(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    axes = attrs.get("axes", ())
    if axes:
        axes = tuple(map(int, re.findall(r'\d+', axes)))

        transpose_node = onnx.helper.make_node(
            "Transpose",
            input_nodes,
            [name],
            perm=axes,
            name=name
        )
    else:
        transpose_node = onnx.helper.make_node(
            "Transpose",
            input_nodes,
            [name],
            name=name
        )

    return [transpose_node]
405829
function transpose(out, a) {
  // If we are transposing ourselves we can skip a few steps but have to cache some values
  if (out === a) {
    var a1 = a[1]
    out[1] = a[2]
    out[2] = a1
  } else {
    out[0] = a[0]
    out[1] = a[2]
    out[2] = a[1]
    out[3] = a[3]
  }

  return out
}
483379
def _extract_blocks(x, block_h, block_w):
  
  (_, height, width, depth) = common_layers.shape_list(x)
  assert height % block_h == 0
  assert width % block_w == 0
  x = tf.reshape(x, [-1, height//block_h, block_h,
                     width//block_w, block_w, depth])
  return tf.transpose(x, [0, 1, 3, 2, 4, 5])
1340920
private static Matrix permuteMatrix(Matrix mat, int cpRows, int cpCols) {
		//fix up cp to be positive
		if(cpRows == 0 && cpCols == 0) {
			return mat.copy();
		}
		if(cpRows < 0) {
			cpRows = mat.getRowDimension()+cpRows;
		}
		if(cpRows < 0 || cpRows >= mat.getRowDimension()) {
			throw new ArrayIndexOutOfBoundsException( String.format(
					"Can't permute rows by %d: only %d rows.",
					cpRows, mat.getRowDimension() )
			);
		}

		if(cpCols < 0) {
			cpCols = mat.getColumnDimension()+cpCols;
		}
		if(cpCols < 0 || cpCols >= mat.getColumnDimension()) {
			throw new ArrayIndexOutOfBoundsException( String.format(
					"Can't permute cols by %d: only %d rows.",
					cpCols, mat.getColumnDimension() )
			);
		}

		int[] rows = new int[mat.getRowDimension()];
		for(int i=0;i<rows.length;i++) {
			rows[i] = (i+cpRows)%rows.length;
		}
		int[] cols = new int[mat.getColumnDimension()];
		for(int i=0;i<cols.length;i++) {
			cols[i] = (i+cpCols)%cols.length;
		}

		Matrix newMat = mat.getMatrix(rows, cols);
		assert(newMat.getRowDimension() == mat.getRowDimension());
		assert(newMat.getColumnDimension() == mat.getColumnDimension());
		assert(newMat.get(0, 0) ==
			mat.get(cpRows%mat.getRowDimension(), cpCols%mat.getColumnDimension()));


		return newMat;
	}
73549
def transform(self):
        
        t_matrix = Matrix(self._rows, self._columns)
        for col_i, col in enumerate(self.matrix):
            for row_i, entry in enumerate(col):
                t_matrix.set_value(row_i, col_i, entry)
        return t_matrix
1149120
def matrix_multiplication_blockwise(self, matrix, blocksize):
        
        #Create the blockwise version of self and matrix
        selfBlockwise = self.matrix_to_blockmatrix(blocksize)
        matrixBlockwise = matrix.matrix_to_blockmatrix(blocksize)

        return (selfBlockwise * matrixBlockwise).flatten()