Questions tagged [transpose]

Transposition is an operation that applies to matrices wherein the rows and columns are swapped

The transpose of a matrix A is written as A'. The transpose of matrix A is another matrix B in which the element in the ith row and the jth column of A is in the jth row and the ith column of B. For example:

Suppose A =

[[11, 12, 13],
 [21, 22, 23],
 [31, 32, 33]]

Then, A' =

[[11, 21, 31],
 [12, 22, 32],
 [13, 23, 33]]

In scientific software for statistical computing and graphics, function t transposes a matrix.

3257 questions
13
votes
7 answers

Transpose of a vector using numpy

I am having an issue with Ipython - Numpy. I want to do the following operation: x^T.x with and x^T the transpose operation on vector x. x is extracted from a txt file with the instruction: x = np.loadtxt('myfile.txt') The problem is that if i…
Alexandre Willame
  • 433
  • 1
  • 4
  • 17
13
votes
3 answers

Fast memory transpose with SSE, AVX, and OpenMP

I need a fast memory transpose algorithm for my Gaussian convolution function in C/C++. What I do now is convolute_1D transpose convolute_1D transpose It turns out that with this method the filter size has to be large (or larger than I expected)…
user2088790
13
votes
6 answers

How to Transpose / Rotate Multi-dimensional Array?

I'm trying to create a function that takes in any array and transpose it so that rows turns to columns and columns to rows. Not sure what I've done wrong or missing but keep getting this message once the array is pass through.... TypeError: Cannot…
13
votes
1 answer

SQLite Transform Columns to Comma Delimited String

I have a table with rows of data and need to create a comma delimited string for all the rows for a column. Can this be achieved just using the the SELECT statement in SQLite or I have to get the data into Cursor and build the string by iterating…
Vincy
  • 1,078
  • 1
  • 9
  • 16
12
votes
3 answers

Transpose a 1-dimensional array in Numpy without casting to matrix

My goal is to to turn a row vector into a column vector and vice versa. The documentation for numpy.ndarray.transpose says: For a 1-D array, this has no effect. (To change between column and row vectors, first cast the 1-D array into a matrix…
Ian
  • 5,704
  • 6
  • 40
  • 72
12
votes
2 answers

Why reading rows is faster than reading columns?

I am analysing a dataset having 200 rows and 1200 columns, this dataset is stored in a .CSV file. In order to process, I read this file using R's read.csv() function. R takes ≈ 600 seconds to read this dataset. Later I got an idea and I transposed…
user2273202
12
votes
3 answers

How to turn a Pandas column into array and transpose it?

I have a Pandas dataframe called 'training_set' that resembles the screenshot below: I try to turn the 'label' column into array and transpose it. I tried doing Y_train=np.asarray(training_set['label']) but what I got is a horizontal array that…
Stanleyrr
  • 858
  • 3
  • 12
  • 31
12
votes
3 answers

How to transpose a 3D matrix?

I have a 3D matrix x_test of size (100, 33, 66) and I want to change its dimensions to (100, 66, 33). What is the most efficient way to do this using python3.5? I look for something along those lines: y = x_test.transpose()
Ajees
  • 151
  • 1
  • 1
  • 10
12
votes
1 answer

Difference between cv::Mat::t () and cv::transpose()

What is the difference in opencv between these two transposes? Using cv::Mat::t(): cv::Mat a; a = a.t(); Using cv::transpose(): cv::Mat a; cv::transpose(a,a); I'm interested in particular about efficiency.
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
12
votes
2 answers

How to use CONCAT in QUERY?

I have a table: A | B | C BEN | MOSKOW | YES ANTON | IRKUTSK | NO VIKTOR | PARIS | YES BEN | PARIS | YES ANTON | TORONTO | NO DON | TORONTO | YES ANNA | IRKUTSK | YES BEN | MOSKOW …
12
votes
3 answers

How does numpy.transpose work for this example?

I have difficulty understanding how numpy.transpose actually works. For example a_value = array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) and when I do np.transpose(a_value, (2, 1, 0)) I…
London guy
  • 27,522
  • 44
  • 121
  • 179
12
votes
3 answers

How to transpose matrix?

I have made 8x8 matrix using c#, and now I need to transpose the matrix. Can you help me to transpose the matrix? This is my matrix public double[,] MatriksT(int blok) { double[,] matrixT = new double[blok, blok]; for (int j = 0; j < blok ;…
Reza Agustina
  • 125
  • 1
  • 1
  • 7
12
votes
4 answers

Finding dot product in r

I am trying to find the dot product of two matrices in R. In the q matrix, which must be transposed, I have three different q values that I randomly generated earlier, and in the z matrix three randomly generated z values that serve as coordinates…
Jonathan O'Farrell
  • 327
  • 1
  • 2
  • 12
12
votes
4 answers

How to unpivot in BigQuery?

Not sure what functions to call, but transpose is the closest thing I can think of. I have a table in BigQuery that is configured like this: but I want to query a table that is configured like this: What does the SQL code look like for creating…
Ben Leathers
  • 184
  • 1
  • 2
  • 9
12
votes
3 answers

How can I transpose different sized ruby arrays?

I have an array: arr=[[1,2,3],[4,5],[6]], I have the following code: arr.transpose but it doesn't work,how to solve it? I am getting [[1,2,3],[4,5],[6]].transpose IndexError: element size differs (2 should be 3) from (irb):13:in…
bluexuemei
  • 233
  • 3
  • 12