matrix-multiplication

MATLAB: How to vector-multiply two arrays of matrices?

我是研究僧i 提交于 2019-11-28 10:10:16
I have two 3-dimensional arrays, the first two dimensions of which represent matrices and the last one counts through a parameterspace, as a simple example take A = repmat([1,2; 3,4], [1 1 4]); (but assume A(:,:,j) is different for each j ). How can one easily perform a per- j matrix multiplication of two such matrix-arrays A and B ? C = A; % pre-allocate, nan(size(A,1), size(B,2)) would be better but slower for jj = 1:size(A, 3) C(:,:,jj) = A(:,:,jj) * B(:,:,jj); end certainly does the job, but if the third dimension is more like 1e3 elements this is very slow since it doesn't use MATLAB's

Dynamic matrix multiplication with CUDA

不问归期 提交于 2019-11-28 10:07:40
问题 The idea of my simple program that I've been trying to write is to take input from the user to see how large of a matrix to multiply. I am looking to take the input x by x, I am not currently looking to multiply two different sizes at the moment. How would you guys suggest I go about accomplishing this? I'm sorry my question was not clear enough, I want to modify this kernel so that it can handle a matrix of any size(where the x and y are equivalents to keep it simple). Instead of multiples

fast matrix multiplication in Matlab

纵饮孤独 提交于 2019-11-28 09:21:08
问题 I need to make a matrix/vector multiplication in Matlab of very large sizes: "A" is an 655360 by 5 real-valued matrix that are not necessarily sparse and "B" is a 655360 by 1 real-valued vector. My question is how to compute: B'*A efficiently. I have notice a slight time improvement by computing A'*B instead, which gives a column vector. But still it is quite slow (I need to perform this operation several times in the program). With a little bit search I found an interesting Matlab toolbox

Why is matrix multiplication in .NET so slow?

倖福魔咒の 提交于 2019-11-28 09:08:21
I don't quite understand what makes matrix multiplication in C#/.NET (and even Java) so slow. Take a look at this benchmark ( source ): Trying to find an updated benchmark. C#'s integer and double performance is damn close to C++ compiled with MSVC++. 87% as fast for double and 99% as fast for 32-bit integer. Pretty damn good, I'd say. But then look at matrix multiplication. The gap widens to C# being about 19% as fast. This is a pretty huge discrepancy that I don't understand. Matrix multiplication is just a bunch of simple math. How is it getting so slow? Shouldn't it be roughly as fast as

Is there a Java library for better linear regression? (E.g., iteratively reweighted least squares) [closed]

夙愿已清 提交于 2019-11-28 07:01:58
问题 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 5 years ago . I am struggling to find a way to perform better linear regression. I have been using the Moore-Penrose pseudoinverse and QR decomposition with JAMA library, but the results are not satisfactory. Would ojAlgo be useful? I have been hitting accuracy limits that I know should not be there. The algorithm should be

Poor maths performance in C vs Python/numpy

若如初见. 提交于 2019-11-28 06:49:51
问题 Near-duplicate / related: How does BLAS get such extreme performance? (If you want fast matmul in C, seriously just use a good BLAS library unless you want to hand-tune your own asm version.) But that doesn't mean it's not interesting to see what happens when you compile less-optimized matrix code. how to optimize matrix multiplication (matmul) code to run fast on a single processor core Matrix Multiplication with blocks Out of interest, I decided to compare the performance of (inexpertly)

How to multiply a matrix in C#?

烂漫一生 提交于 2019-11-28 05:25:03
问题 I cannot get this method to work. It intends to multiply a matrix by a given one. Could someone help me to correct it please? class Matriz { public double[,] structure; //Other class methods public void multiplyBy(Matrix m) { if (this.structure.GetLength(1) == m.structure.GetLength(0)) { Matriz resultant = new Matriz(this.structure.GetLength(0), m.structure.GetLength(1)); for (int i = 0; i < this.structure.GetLength(0) - 1; i++) { for (int j = 0; j < m.structure.GetLength(1) - 1; j++) {

numpy matrix inversion rounding errors

自古美人都是妖i 提交于 2019-11-28 02:23:56
I am getting a very strange value for my (1,1) entry for my BinvA matrix I am just trying to invert B matrix and do a (B^-1)A multiplication. I understand that when I do the calculation by hand my (1,1) is supposed to be 0 but instead I get 1.11022302e-16. How can I fix it? I know floating point numbers can't be represented to full accuracy but why is this giving me such an inaccurate response and not rounding to 0 is there any way I can make it more accurate? Her is my code: import numpy as np A = np.array([[2,2],[4,-1]],np.int) A = A.transpose() B = np.array([[1,3],[-1,-1]],np.int) B = B

Improving the performance of Matrix Multiplication

偶尔善良 提交于 2019-11-28 01:46:24
问题 This is my code for speeding up matrix multiplication, but it is only 5% faster than the simple one. What can i do to boost it as much as possible? *The tables are being accessed for example as: C[sub2ind(i,j,n)] for the C[i, j] position. void matrixMultFast(float * const C, /* output matrix */ float const * const A, /* first matrix */ float const * const B, /* second matrix */ int const n, /* number of rows/cols */ int const ib, /* size of i block */ int const jb, /* size of j block */ int

Cache friendly method to multiply two matrices

家住魔仙堡 提交于 2019-11-28 00:56:32
问题 I intend to multiply 2 matrices using the cache-friendly method ( that would lead to less number of misses) I found out that this can be done with a cache friendly transpose function. But I am not able to find this algorithm. Can I know how to achieve this? 回答1: The word you are looking for is thrashing . Searching for thrashing matrix multiplication in Google yields more results. A standard multiplication algorithm for c = a*b would look like void multiply(double[,] a, double[,] b, double[,]