matrix

CSS Transform square into thinner rhombus

泄露秘密 提交于 2020-01-01 04:08:05
问题 How to create a rhombus: (as shown in red) by transforming a square using css? Only points B and C must move. Original size of square is 25px by 25px. I'm trying to achieve this result and would later rotate it 45 degrees so that it would look like a diamond. I think this can be done using the transform:matrix(); P.S. I want to try as much as possible to not use explorercanvas, since I'm trying to minimize script tags in the html. 回答1: -webkit-transform: rotate(45deg) skew(20deg, 20deg)

R image function in R

╄→尐↘猪︶ㄣ 提交于 2020-01-01 03:17:06
问题 I am using the attached image function in R. I prefer to use this as oppose to heatmap for speed, since I use it for huge matrices (~ 400000 by 400). The problem in my function is the dynamic range for the color palette, its only blue and yellow in my case. I have tried several changes to the colorramp line but none gave me the desired output. The last color ramp option I tried was using a nice package in R called ColorRamps, which give reasonable results is: library("colorRamps") ColorRamp =

Sliding max window and its average for multi-dimensional arrays

烈酒焚心 提交于 2020-01-01 02:45:09
问题 I have a 60 x 21 x 700 matrix, where the 60 x 21 represent a pressure output x number of frames . I want to find the 2 x 2 window that generates the maximum average pressure per frame and store it in a new variable so that it can be plotted. For example, if the matrix looked something like this: 01 02 02 01 01 02 01 01 02 02 02 03 04 04 03 01 02 06 10 05 02 02 08 09 05 The max window and its average for a 2 x 2 window would be - 06 10 08 09 = 8.25 So far in my search for a solution I've only

How do I compute the linear index of a 3D coordinate and vice versa?

北城余情 提交于 2019-12-31 22:26:29
问题 If I have a point (x, y z), how do I find the linear index, i for that point? My numbering scheme would be (0,0,0) is 0, (1, 0, 0) is 1, . . ., (0, 1, 0) is the max-x-dimension, .... Also, if I have a linear coordinate, i, how do I find (x, y, z)? I can't seem to find this on google, all the results are filled with other irrelevant stuff. Thank you! 回答1: There are a few ways to map a 3d coordinate to a single number. Here's one way. some function f(x,y,z) gives the linear index of coordinate

How to find same-value rectangular areas of a given size in a matrix most efficiently?

假如想象 提交于 2019-12-31 22:25:14
问题 My problem is very simple but I haven't found an efficient implementation yet. Suppose there is a matrix A like this: 0 0 0 0 0 0 0 4 4 2 2 2 0 0 4 4 2 2 2 0 0 0 0 2 2 2 1 1 0 0 0 0 0 1 1 Now I want to find all starting positions of rectangular areas in this matrix which have a given size. An area is a subset of A where all numbers are the same. Let's say width=2 and height=3. There are 3 areas which have this size: 2 2 2 2 0 0 2 2 2 2 0 0 2 2 2 2 0 0 The result of the function call would be

How to find same-value rectangular areas of a given size in a matrix most efficiently?

隐身守侯 提交于 2019-12-31 22:23:43
问题 My problem is very simple but I haven't found an efficient implementation yet. Suppose there is a matrix A like this: 0 0 0 0 0 0 0 4 4 2 2 2 0 0 4 4 2 2 2 0 0 0 0 2 2 2 1 1 0 0 0 0 0 1 1 Now I want to find all starting positions of rectangular areas in this matrix which have a given size. An area is a subset of A where all numbers are the same. Let's say width=2 and height=3. There are 3 areas which have this size: 2 2 2 2 0 0 2 2 2 2 0 0 2 2 2 2 0 0 The result of the function call would be

How to find same-value rectangular areas of a given size in a matrix most efficiently?

假如想象 提交于 2019-12-31 22:23:33
问题 My problem is very simple but I haven't found an efficient implementation yet. Suppose there is a matrix A like this: 0 0 0 0 0 0 0 4 4 2 2 2 0 0 4 4 2 2 2 0 0 0 0 2 2 2 1 1 0 0 0 0 0 1 1 Now I want to find all starting positions of rectangular areas in this matrix which have a given size. An area is a subset of A where all numbers are the same. Let's say width=2 and height=3. There are 3 areas which have this size: 2 2 2 2 0 0 2 2 2 2 0 0 2 2 2 2 0 0 The result of the function call would be

Matlab Table / Dataset type optimization

笑着哭i 提交于 2019-12-31 21:40:09
问题 I am searching some optimized datatypes for "observations-variables" table in Matlab, that can be fast and easily accessed by columns (through variables) and by rows (through observations). Here is сomparison of existing Matlab datatypes: Matrix is very fast, hovewer, it has no built-in indexing labels/enumerations for its dimensions, and you can't always remember variable name by column index. Table has very bad performance, especially when reading individual rows/columns in a for loop (I

Numpy efficient big matrix multiplication

99封情书 提交于 2019-12-31 10:51:59
问题 To store big matrix on disk I use numpy.memmap. Here is a sample code to test big matrix multiplication: import numpy as np import time rows= 10000 # it can be large for example 1kk cols= 1000 #create some data in memory data = np.arange(rows*cols, dtype='float32') data.resize((rows,cols)) #create file on disk fp0 = np.memmap('C:/data_0', dtype='float32', mode='w+', shape=(rows,cols)) fp1 = np.memmap('C:/data_1', dtype='float32', mode='w+', shape=(rows,cols)) fp0[:]=data[:] fp1[:]=data[:]

Numpy efficient big matrix multiplication

限于喜欢 提交于 2019-12-31 10:50:08
问题 To store big matrix on disk I use numpy.memmap. Here is a sample code to test big matrix multiplication: import numpy as np import time rows= 10000 # it can be large for example 1kk cols= 1000 #create some data in memory data = np.arange(rows*cols, dtype='float32') data.resize((rows,cols)) #create file on disk fp0 = np.memmap('C:/data_0', dtype='float32', mode='w+', shape=(rows,cols)) fp1 = np.memmap('C:/data_1', dtype='float32', mode='w+', shape=(rows,cols)) fp0[:]=data[:] fp1[:]=data[:]