transpose

What's the difference between two way to input Matlab Complex Matrices

£可爱£侵袭症+ 提交于 2019-11-29 15:51:45
Here's two ways to enter the command in Matlab. I don't think there's any difference between them. However, the result is really different. So I wonder what's I missed in this situation. Here's the first input: >> A = [(-0.025+0.01i) -0.025; 3 (1-2i)]; >> B = [(5.7955+1.5529i) 0]'; >> I=inv(A)*B The output is like this: I = 1.0e+02 * -0.7063 - 1.2723i -1.1030 + 1.6109i Here's the second input: >> A = [(-0.025+0.01i) -0.025;3 (1-2i)]; >> B = [(5.7955+1.5529i);0]; >> I=inv(A)*B And the Matlab give me the result below: I = 2.44764705882354 - 145.499411764706i -176.067882352941 + 84.3624705882353i

Transposing CSV data in Perl

只谈情不闲聊 提交于 2019-11-29 15:24:44
I am a Perl beginner and currently working on a Perl script to automate some of our tasks. One script that I'm working on involves extracting performance data from our system, storing it in CSV files and generating Excel graphs. After a few days of working on this script, I have managed to get the extracted data into CSV, but now, I am having hard time in trying to transpose the data! I have seen this thread (thanks to dalton for the script): stackoverflow thread , but I can't seem to apply it in my case. Basically, my CSV file contains a daily data per row, with the columns as the hours of

Searching for unique values in dataframe and creating a table with them

回眸只為那壹抹淺笑 提交于 2019-11-29 15:11:45
Since I started using R< not long ago, I've found this site very useful in helping me build my scripts. I have yet again came across a challenge for which I can't seem to find an answer anywhere. Here is my problem: In my data I have a column which contains a different URL in each row. In each of those URL's there is a particular piece of information I want to extract. Currently I do it in excel because I've been told it's impossible to do in R and that no function exists to do it. The URL will look like this example format and it will be found in the "source" column http://www.googleclick.com

Transpose a row into columns with MySQL without using UNIONS?

此生再无相见时 提交于 2019-11-29 12:31:43
I have a table that is similar to the following below: id | cat | one_above | top_level | 0 'printers' 'hardware' 'computers' I want to be able to write a query, without using unions , that will return me a result set that transposes this table's columns into rows. What this means, is that I want the result to be: id | cat | 0 'printers' 0 'hardware' 0 'computers' Is this possible in MySQL? I can not drop down to the application layer and perform this because I'm feeding these into a search engine that will index based on the id. Various other DBMS have something like PIVOT and UNPIVOT. I

Removing duplicate rows from data frame in R

雨燕双飞 提交于 2019-11-29 12:04:34
I have two columns, would like to retain only the non commutative rows.For the data below my output should contain one combination of (1 2). i.e. for my query (1 2) is same as (2 1). Is there a simple way to do it in R. Already tried transposing. and retaining the upper traingular matrix. but it becomes a pain re transposing back the data. A B prob 1 2 0.1 1 3 0.2 1 4 0.3 2 1 0.3 2 3 0.1 2 4 0.4 My final output should be: A B prob 1 2 0.1 1 3 0.2 1 4 0.3 2 3 0.1 2 4 0.4 We can use data.table . Convert the 'data.frame' to 'data.table' ( setDT(df1) ), grouped by the pmin(A, B) and pmax(A,B) , if

How does numpy.transpose work for this example?

限于喜欢 提交于 2019-11-29 09:27:50
问题 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 get array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]]) How can I derive this transpose manually? I need to understand the formula or the steps intuitively in the above case so I can generalize it for higher dimensions. 回答1: As given in the documentation - numpy.transpose(a, axes=None) axes : list of ints, optional By

Fast memory transpose with SSE, AVX, and OpenMP

孤人 提交于 2019-11-29 07:53:08
问题 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) or the transpose takes longer than the convolution (e.g. for a 1920x1080 matrix the convolution takes the same time as the transpose for a filter size of 35). The current transpose algorithm I am using uses loop blocking/tiling along with SSE and

How can I transpose different sized ruby arrays?

泄露秘密 提交于 2019-11-29 06:37:43
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 `transpose' from (irb):13 from /home/durrant my solution: arr.reduce(&:zip).map(&:flatten) output: [[1, 4, 6], [2, 5, nil], [3, nil, nil]] A similar answer was posted (but deleted) an hour earlier: arr = [[1, 2, 3], [4, 5], [6]] arr[0].zip(*arr[1..-1]) #=> [[1, 4, 6], [2, 5, nil], [3, nil, nil]] The above is equivalent to: [1, 2, 3].zip([4, 5], [6]) This approach

How do I transpose a tibble() in R [duplicate]

限于喜欢 提交于 2019-11-29 04:07:47
This question already has an answer here: Transposing data frames 1 answer In R the t() function is really meant for matrices. When I try to transpose my tibble with t() I end up with a matrix. A matrix can't be made into a tibble with tibble() . I end up spending time storing column names as variables and attaching them as I try to re-make a transposed version of my tibble. Question: What is the simplest way to transpose a tibble where the first column should become the column names of the new tibble and the old column names become the first column of my new tibble. As Sotos has mentioned it,

How would you transpose a binary matrix?

旧城冷巷雨未停 提交于 2019-11-29 02:02:42
I have binary matrices in C++ that I repesent with a vector of 8-bit values. For example, the following matrix: 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 is represented as: const uint8_t matrix[] = { 0b01010101, 0b00110011, 0b00001111, }; The reason why I'm doing it this way is because then computing the product of such a matrix and a 8-bit vector becomes really simple and efficient (just one bitwise AND and a parity computation, per row), which is much better than calculating each bit individually. I'm now looking for an efficient way to transpose such a matrix, but I haven't been able to