matrix-multiplication

How to do (m,n,k) * (n,k) = (m,k) in matlab?

拥有回忆 提交于 2019-12-12 03:45:58
问题 I have found this relevant question: Multiply columns of a matrix with 2d matrix slices of a 3d matrix in MatLab I have the same problem but in my case m can vary for each slice. Is there a way to do that with mtimesx ? Because m varies, my 3d tensor is stored as a list of cells, each containing a matrix. Also my 2d matrix is rather a list of cells each containing a vector. Is there a way I can do this multiplication without a for loop? 回答1: Since your data is already stored in cellarrays,

How to scale Bitmap drawn on the Canvas while saving rotation and translation specified with Matrix

老子叫甜甜 提交于 2019-12-12 03:36:16
问题 Sample Image Hi everyone. I am new to Image manipulation in android using matrix. I am working on an app which displays Bitmap #1 on the screen of the device. Bitmap #1 is really big, about 2592 X 1456, but scaled down to fit the screen size of the device for displaying purposes only. Then I have drawn the lips Bitmap (#2) on Bitmap #1 Canvas, using matrix (with rotate, scale, translation), as image above is showing. Precisely what I want to achieve is to save a copy of the final Bitmap,

Matrix Multiplication using divide and conquer approach [closed]

橙三吉。 提交于 2019-12-12 01:39:07
问题 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 3 years ago . I am a beginner in programming and just learned new concepts and started writing code for matrix multiplication but I got confused in pointers and others so I am uploading my code here in seek of guidelines. #include <stdio.h> #include <stdlib.h> int **matrixMultiply(int A[][8], int B[][8], int row); int main()

Simplifying looped numpy operations

我的梦境 提交于 2019-12-12 01:27:38
问题 I am trying to learn to efficiently implement various neural nets in python and am currently trying to implement this model . However, I am having trouble using numpy operations to implement the summation. I have been following this existing implementation and am trying to simplify it, but it's not entirely clear to me what all of the array operations being performed are achieving. My interpretation is that the C's are multiplied through each of the columns of R and summed. However, my einsum

Matrix Multiplication with threads

我只是一个虾纸丫 提交于 2019-12-11 20:19:04
问题 I want to multiplication matrix.When I use Parallel.For,single thread is slower than multi thread.But when I use two threads, single thread is faster than two threads. I want to multiplication matrix with use two threads. What is my error ? I don't understand. Thank you for your answers.. class carp { double[,] a = new double[300, 300]; double[,] b = new double[300, 300]; double[,] c = new double[300, 300]; int indis = 0; public carp(double[,] a, double[,] b, double[,] c,int i) { this.a = a;

How to build & store this large lower triangular matrix for matrix-vector multiplication?

大兔子大兔子 提交于 2019-12-11 15:44:11
问题 I need to create a lower triangular matrix with a special structure then do a matrix-vector multiplication. The matrix is parameterized by a value k . It main diagonal is a vector of k ^ 0 , i.e. 1; the first sub-diagonal is a vector of k ^ 1 , and the i -th sub-diagonal holds k ^ i . Here is a 5 x 5 example with k = 0.9 : structure(c(1, 0.9, 0.81, 0.729, 0.6561, 0, 1, 0.9, 0.81, 0.729, 0, 0, 1, 0.9, 0.81, 0, 0, 0, 1, 0.9, 0, 0, 0, 0, 1), .Dim = c(5L, 5L)) # [,1] [,2] [,3] [,4] [,5] #[1,] 1

Multiplication/Division of 2d numpy arrays to produce 3d array

混江龙づ霸主 提交于 2019-12-11 14:58:57
问题 I am looking for a fast (ie vectorized) method to replace the following loop. I have 2 numpy arrays with dimensions: (20738,14) and (31,14). I need to multiply them element-wise to get an array of (20738,31,14). I've been experimenting with various configurations of broadcasting, but can't seem to get the desired result. v_mu_3d = np.zeros((v.shape[0], ALT_LEN, NEST_LEN)) for k in range(NEST_LEN): v_mu_3d[:,:,k] = v * MU[:,k] v_mu_3d = np.exp(v_mu_3d) A similar operation is the following: p2

sparse sparse product A^T*A optim in Eigen lib

非 Y 不嫁゛ 提交于 2019-12-11 13:35:43
问题 In the case of multiple of same matrix matA, like matA.transpose()*matA, You don't have to compute all result product, because the result matrix is symmetric(so only if the m>n), in my specific case is always symmetric! square. So its enough the compute only for. ex. lower triangular part and rest only copy..... because the results of the multiple 2nd and 3rd row, resp.col, is the same like 3rd and 2nd.....And etc.... So my question is , exist way how to tell Eigen, to compute only lower part

What is the difference between Floyd-Warshall and matrix multiplication graph algorithms?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:26:40
问题 I have to solve the following problem: Write a program that, given a directed graph with costs and two vertices, finds a lowest cost walk between the given vertices, or prints a message if there are negative cost cycles in the graph. The program shall use the matrix multiplication algorithm. I implemented the matrix multiplication algorithm as it is defined: a pseudo-matrix multiplication, where addition is replaced by minimization and multiplication with addition. But by doing this, I ended

Matrix multiplication in java

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 08:28:19
问题 I wanted to do matrix multiplication in Java, and the speed needs to be very good. I was thinking of calling R through java to achieve this. I had a couple of Qs though: Is calling R using Java a good idea? If yes, are there any code samples that can be shared? What are the other ways that can be considered to do matrix multiplication in Java? Update: My colleague who quit the firm was a C# programmer, who was forced to write Java code that involved matrix multiplication. -- He has written