matrix

numpy.matmul in Theano

强颜欢笑 提交于 2020-01-04 09:38:15
问题 TL;DR I want to replicate the functionality of numpy.matmul in theano . What's the best way to do this? Too Short; Didn't Understand Looking at theano.tensor.dot and theano.tensor.tensordot , I'm not seeing an easy way to do a straightforward batch matrix multiplication. i.e. treat the last two dimensions of N dimensional tensors as matrices, and multiply them. Do I need to resort to some goofy usage of theano.tensor.batched_dot ? Or *shudder* loop them myself without broadcasting!? 回答1: The

Number of submatrix of size AxB in a matrix of size MxN

你离开我真会死。 提交于 2020-01-04 08:27:00
问题 I am following https://taninamdar.files.wordpress.com/2013/11/submatrices3.pdf to find total number of sub matrix of a matrix.But am stuck how to find how many sub matrix of a given size is present in a matrix. Also 0<=A<=M and 0<=B<=N. where AxB(submatrix size) and MxN(matrix size). 回答1: I didn't go through the pdf (math and I aren't friends), however simple logic is enough here. Simply, try to reduce the dimension: How many vectors of length m can you put in a vector of length n ? Answer: n

Performing many small matrix operations in parallel in OpenCL

旧城冷巷雨未停 提交于 2020-01-04 06:52:55
问题 I have a problem that requires me to do eigendecomposition and matrix multiplication of many (~4k) small (~3x3) square Hermitian matrices. In particular, I need each work item to perform eigendecomposition of one such matrix, and then perform two matrix multiplications. Thus, the work that each thread has to do is rather minimal, and the full job should be highly parallelizable. Unfortunately, it seems all the available OpenCL LAPACKs are for delegating operations on large matrices to the GPU

Algorithm Complexity and Efficiency, Exponential operation java

牧云@^-^@ 提交于 2020-01-04 06:35:41
问题 I have a list of strings. I have a set of numbers: {1, 2, 3, 4} and I need to generate all combinations(?) (strings) to check against my list, Combinations: (1, 2, 3, 4), (1234), (1, 2, 3, 4), (123, 4), (12, 34), (1, 2, 34), (1, 234), (1, 23, 4), (1, 23), (1, 2, 3), (1 2), ((1 2), (3 4))...etc. This problem grows larger as my set of numbers gets larger. Is it right that this is a bad problem to use recursion for? (that is what I have now) However, aren't the space requirements stricter for an

Is python capable of doing MATLAB equivalent matrix operations?

久未见 提交于 2020-01-04 06:26:57
问题 I have implemented codes in MATLAB that operates on 216x216 matrices that contain numeric data and sometime strings. The operations that I do on these matrices are mostly like filter matrices above a certain threshold, find all the matrix indexes that are above some value, Find a list of values above say X and then find consecutive differences between them, some string replace manipulations. Do matrix dot products etc. I need to access thousands of files to generate these matrices(dlmread I

Is python capable of doing MATLAB equivalent matrix operations?

≡放荡痞女 提交于 2020-01-04 06:26:11
问题 I have implemented codes in MATLAB that operates on 216x216 matrices that contain numeric data and sometime strings. The operations that I do on these matrices are mostly like filter matrices above a certain threshold, find all the matrix indexes that are above some value, Find a list of values above say X and then find consecutive differences between them, some string replace manipulations. Do matrix dot products etc. I need to access thousands of files to generate these matrices(dlmread I

iPhone OpenGL : Using gluUnProject (port) and detecting clicking on an object

天大地大妈咪最大 提交于 2020-01-04 06:13:42
问题 please help, this is my 4th question about this, I trying so hard I tried everything! All I want to do is detect clicking on a object(cube) in a 3D World (3D world created). This does it http://blog.nova-box.com/2010/05/iphone-ray-picking-glunproject-sample.html but has a completely different app structure and does a lot with render buffers etc. I am trying to use using gluUnProject (someone has ported it). On touch CGPoint pos = [[touches anyObject] locationInView:self.view]; glGetIntegerv(

Converting a vector in R into a lower triangular matrix in specific order

做~自己de王妃 提交于 2020-01-04 05:55:51
问题 I have a vector where the order of the elements are important, say x <- c(1,2,3,4) I would like to arrange my vector into a lower triangular matrix with a specific order where each row contains the preceding element of the vector. My goal is to obtain the following matrix lower_diag_matrix [,1] [,2] [,3] [,4] [1,] 4 0 0 0 [2,] 3 4 0 0 [3,] 2 3 4 0 [4,] 1 2 3 4 I know I can fill the lower triangular area using lower_diag_matrix[lower.tri(lower_diag_matrix,diag = T)]<-some_vector but I can't

Returning Column Name from Matrix based on value in R

只谈情不闲聊 提交于 2020-01-04 05:43:54
问题 I have a matrix that I want to extract column names based on the value. In this case I want the name of any column that contains a value less than or equal to 2 (doesnt matter what row that value is located in). set.seed(42) DF <- matrix(sample(1:9,9),ncol=3,nrow=3) DF <- as.data.frame.matrix(DF) this is what I have tried, (it seems to work if there is only 1 row in the matrix) test<-colnames(DF)[which(DF<=2),] test would then represent the column names containing values <= 2 回答1: 1 Run

R - How to make 2 adjacency matrices compatible to eachother

跟風遠走 提交于 2020-01-04 05:04:34
问题 I have 2 adjacency matrices with different dimesnsions. I want to make their dimensions compatible so that when I replace any column of one matrix from any column of second matrix then I don't get the following error message: Error: number of items to replace is not a multiple of replacement length Here are my matrices: > mat1 Tommy Roy Addy Sam Tommy 0 1 0 -1 Roy -1 -1 1 0 Addy 1 0 -1 0 Sam 0 0 -1 1 > mat2 Mike Roy Addy Sam Dan Mike 0 1 0 -1 0 Roy -1 -1 1 0 1 Addy 1 0 -1 0 -1 Sam 0 0 -1 1 0