matrix

Memory efficient extraction of overlapping patches from matrix

拈花ヽ惹草 提交于 2019-12-29 09:20:07
问题 short story: This is a follow up question to: Fast Way to slice image into overlapping patches and merge patches to image How must I adapt the code provided in the answer to work not only on images of size x,y, where a pixel is described by a float, but described by a matrix of size 3,3? Further, how to adapt the code so that it returns a generator allowing me to iterate over all patches without having to save all of them in memory? long story: Given an image of shape (x,y), where each pixel

Matrix / coordinate transformation order

一笑奈何 提交于 2019-12-29 09:08:11
问题 I have two array of points: Point [] original; AND Point [] transformed; These transformed array is simply a copy of the original with transformations applied. Example: matrix.Rotate(5f); matrix.Scale(.8f, 1.1f); matrix.Translate(30f, 18f); matrix.TransformPoints(transformed); The original points ARE known. The transformation values ARE known. The order in which the transformations were applied is NOT known. How can I calculate / infer the order of transformations? EDIT There is only ONE

python difference between the two form of matrix x[i,j] and x[i][j]

核能气质少年 提交于 2019-12-29 09:06:21
问题 i want to understand the difference between x[i,j] and x[i][j] where x is a matrix x = np.zeros((N,M)) The answer that i found while doing the research is always about array with 2D dimension but in my case i have a matrix with two index to work with i and j and i need to manipulate the matrix according the index with a for loop. for i in range(1,N+1): for j in range(1,M+1): x[i-1][j-1]=random.uniform(5,10) so can you help me understand the difference between x[i,j] and x[i][j] and to be more

Matrix multiplication in scheme, List of lists

不羁岁月 提交于 2019-12-29 09:05:15
问题 I started to study Scheme and I do not understand some of it. I'm using DrRacket. I wrote the following code: (define mult_mat (λ (A B) (Trans_Mat (map (λ (x) (mul_Mat_vec A x)) (Trans_Mat B))))) That uses this functions: (define Trans_Mat (λ (A) (apply map (cons list A)))) (define mul_Mat_vec (λ (A v) (map (λ (x) (apply + (map * x v))) A))) In mult_mat , I multiply the matrix A in each vector of the transpose matrix B. It works fine. I found a code on the web that makes the multiplication in

Matrix multiplication in scheme, List of lists

折月煮酒 提交于 2019-12-29 09:05:10
问题 I started to study Scheme and I do not understand some of it. I'm using DrRacket. I wrote the following code: (define mult_mat (λ (A B) (Trans_Mat (map (λ (x) (mul_Mat_vec A x)) (Trans_Mat B))))) That uses this functions: (define Trans_Mat (λ (A) (apply map (cons list A)))) (define mul_Mat_vec (λ (A v) (map (λ (x) (apply + (map * x v))) A))) In mult_mat , I multiply the matrix A in each vector of the transpose matrix B. It works fine. I found a code on the web that makes the multiplication in

How to sort a matrix/data.frame by all columns

人盡茶涼 提交于 2019-12-29 08:58:29
问题 I have a matrix, e.g.: a = rep(0:1, each=4) b = rep(rep(0:1, each=2), 2) c = rep(0:1, times=4) mat = cbind(c,b,a) I need to sort all columns of this matrix. I know how to do this by sorting specific columns (i.e. a limited number of columns). mat[order(mat[,"c"],mat[,"b"],mat[,"a"]),] c b a [1,] 0 0 0 [2,] 0 0 1 [3,] 0 1 0 [4,] 0 1 1 [5,] 1 0 0 [6,] 1 0 1 [7,] 1 1 0 [8,] 1 1 1 However, I need a generic way of doing this without calling any column names, because I could have any number of

Plotting 3-D Matrix *values* in MATLAB

荒凉一梦 提交于 2019-12-29 08:54:05
问题 I have a 3D Matrix M(256x256x136) and each index(i,j,k) in M has a gray level value in it. I am interested in displaying M in some sort of a 3D plot in MATLAB, but am unable to do so. I cannot use plot3 because plot3 is for plotting points, not the values. Thanks 回答1: If I understand your question correctly, you want to plot the 3D point cloud with i , j , and k as 3D coordinates and the gray level as the point value. I would suggest using scatter3. 回答2: Sounds like you are looking for a

Compiling n submatrices into an NxN matrix in numpy

眉间皱痕 提交于 2019-12-29 08:22:44
问题 Working on a problem in matrix structural analysis. I am writing a program in Python (using Anaconda 3) to analyze a truss. Each individual truss member generates one 4x4 matrix, for a total of n 4x4 matrices. Then, these 4x4 matrices are compiled into an NxN matrix, arranged like so, for matrices A, B, C: As you can see, each successive submatrix is placed one row over and one row down from the preceding one. Further, because the size of the truss and the number of truss joints (nodes) is

Numpy elementwise product of 3d array

我是研究僧i 提交于 2019-12-29 05:23:26
问题 I have two 3d arrays A and B with shape (N, 2, 2) that I would like to multiply element-wise according to the N-axis with a matrix product on each of the 2x2 matrix. With a loop implementation, it looks like C[i] = dot(A[i], B[i]) Is there a way I could do this without using a loop? I've looked into tensordot, but haven't been able to get it to work. I think I might want something like tensordot(a, b, axes=([1,2], [2,1])) but that's giving me an NxN matrix. 回答1: It seems you are doing matrix

sparse matrix library for C++ [closed]

二次信任 提交于 2019-12-29 04:58:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . Is there any sparse matrix library that can do these: solve linear algebraic equations support operations like matrix-matrix/number multiplication/addition/subtraction,matrix transposition, get a row/column of a matrix,and so on matrix size could be 40k*40k or bigger,like 250k*250k fast can be used in Windows