transpose

SQL server: Transpose Rows to Columns (n:m relationship)

ぃ、小莉子 提交于 2019-12-05 19:06:16
After trying it myself for some hours now I need to ask for help. I only did some basic SQL until now. I want to solve the following: (I have translated a couple of things for you to understand the context) I have three tables: Workers (Mitarbeiter in German - mitID) | mitID | Name | FamName | DOB | abtIDref | |-------|--------|---------|------------|----------| | 1 | Frank | Sinatra | 12.12.1915 | 1 | | 2 | Robert | Downey | 4.4.1965 | 2 | INFO: abtIDref is an 1:n relation for the Workplace , but not involved here Skills (Faehigkeiten in German - faeID) | faeID | Descr | time | cost | |------

CUDA In-place Transpose Error

那年仲夏 提交于 2019-12-05 18:03:11
I'm implementing a CUDA program for transposing an image. I created 2 kernels. The first kernel does out of place transposition and works perfectly for any image size. Then I created a kernel for in-place transposition of square images. However, the output is incorrect. The lower triangle of the image is transposed but the upper triangle remains the same. The resulting image has a stairs like pattern in the diagonal and the size of each step of the stairs is equal to the 2D block size which I used for my kernel. Out-of-Place Kernel: Works perfectly for any image size if src and dst are

Unexpectedly transposed flipped output from R “image” function

别来无恙 提交于 2019-12-05 01:49:35
问题 Say I have a matrix: m<-matrix(1:5,4,5) m [,1] [,2] [,3] [,4] [,5] [1,] 1 5 4 3 2 [2,] 2 1 5 4 3 [3,] 3 2 1 5 4 [4,] 4 3 2 1 5 Now, when I do image(m) I get unexpected output. And so I need to do: image(t(m)[,4:1]) to get it the "right" way. What is the point? 回答1: Others have pointed out that what you are seeing is consistent with the documentation, here are a couple of thoughts of the why it does it that way. The image function was not originally designed to plot images/graphics, but to

How to transpose matrix using uBLAS?

◇◆丶佛笑我妖孽 提交于 2019-12-05 01:40:35
I am a newbie in C++ Boost uBLAS library so I have a noob question - how to transpose a matrix using this library? I could not find question here: http://www.boost.org/doc/libs/1_44_0/libs/numeric/ublas/doc/html/index.html C = boost::numeric::ublas::trans(A); Documented (poorly) under Overview of Matrix and Vector Operations . 来源: https://stackoverflow.com/questions/4097153/how-to-transpose-matrix-using-ublas

Pivoting rows into columns in SQL Server

假装没事ソ 提交于 2019-12-04 19:43:25
I have a set of data that looks like this: Before FirstName LastName Field1 Field2 Field3 ... Field27 --------- -------- ------ ------ ------ ------- Mark Smith A B C D John Baptist X T Y G Tom Dumm R B B U However, I'd like the data to look like this: After FirstName LastName Field Value --------- -------- ----- ----- Mark Smith 1 A Mark Smith 2 B Mark Smith 3 C Mark Smith 4 D John Baptist 1 X John Baptist 2 T John Baptist 3 Y John Baptist 4 G Tom Dumm 1 R Tom Dumm 2 B Tom Dumm 3 B Tom Dumm 4 U I have looked at the PIVOT function. It may work. I am not too sure. I couldn't make sense of how

PySpark Dataframe cast two columns into new column of tuples based value of a third column

纵饮孤独 提交于 2019-12-04 18:49:13
As the subject describes, I have a PySpark Dataframe that I need to cast two columns into a new column that is a list of tuples based the value of a third column. This cast will reduce or flatten the dataframe by a key value, product id in this case, and the result os one row per key. There are hundreds of millions of rows in this dataframe, with 37M unique product ids. Therefore I need a way to do the transformation on the spark cluster without bringing back any data to the driver (Jupyter in this case). Here is an extract of my dataframe for just 1 product: +-----------+-------------------+-

Cache Memory Optimization Array Transpose: C

China☆狼群 提交于 2019-12-04 11:38:57
问题 typedef int array[2][2]; void transpose(array dst, array src) { int i, j; for (j = 0; j < 2; j++) { for (i = 0; i < 2; i++) { dst[i][j] = src[j][i]; } } } src array starts at address 0 and the dst array starts at address 0x10. L1 data cache, direct map, write-allocate, 8 byte block size. cache total size is 16 data bytes. What is the hit or miss on each entry of src and dst array? The answer is: src: [0][0] -> miss, [0][1] -> miss, [1][0] -> miss, [1][1] -> hit dst: [0][0] -> miss, [0][1] ->

transpose 1D array of leading dimension N

南楼画角 提交于 2019-12-04 11:02:16
how can i transpose an 1d array of leading dimension N, without extra space ? any language is fine Yane Boltrel Yan'son My solution for 1D in-place Matrix transposition mn = M*N; /* M rows and N columns */ q = mn - 1; i = 0; /* Index of 1D array that represents the matrix */ do { k = (i*M) % q; while (k>i) k = (M*k) % q; if (k!=i) Swap(k, i); } while ( ++i <= (mn -2) ); /* Update row and column */ matrix.M = N; matrix.N = M; Transposing a non-square matrix in-place represented as a linear array is a bit of a trick. Here is a REXX program that performs an in-place transpose of a 2D matrix

Transposing in dplyr

浪子不回头ぞ 提交于 2019-12-04 10:52:17
问题 I have the following data.frame df = structure(list(HEADER = c("HOME_TRPM", "AWAY_TRPM", "HOME_TEAM","AWAY_TEAM"), price = c("0.863104076023855", "-0.845186446996287","CHA", "NOP")), .Names = c("HEADER", "price"), row.names = c(NA, 4L), class = "data.frame") df #> HEADER price #> 1 HOME_TRPM 0.863104076023855 #> 2 AWAY_TRPM -0.845186446996287 #> 3 HOME_TEAM CHA #> 4 AWAY_TEAM NOP which I want to transpose. How can I do it in dplyr without using t()? I tried df %>% tidyr::spread(HEADER , price

How to unpivot in BigQuery?

老子叫甜甜 提交于 2019-12-04 08:00:44
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 this table? Thanks! Use the UNION of tables (with ',' in BigQuery), plus some column aliasing: SELECT Location, Size, Quantity FROM ( SELECT Location, 'Small' as Size, Small as Quantity FROM [table] ), ( SELECT Location, 'Medium' as Size, Medium as Quantity FROM [table] ), ( SELECT Location, 'Large' as Size, Large as Quantity FROM [table] ) @Felipe, I