matrix-multiplication

Fast multiplication of k x k boolean matrices, where 8 <= k <= 16

荒凉一梦 提交于 2019-12-09 16:04:21
问题 I want to find an as fast as possible way of multiplying two small boolean matrices, where small means, 8x8, 9x9 ... 16x16. This routine will be used a lot, so it needs to be very efficient, so please don't suggest that the straightforward solution should be fast enough. For the special cases 8x8, and 16x16 I already have fairly efficient implementations, based on the solution found here, where we treat the entire matrix as an uint64_t or uint64_t[4] respectively. On my machine this is

Fastest way to calculate minimum euclidean distance between two matrices containing high dimensional vectors

谁都会走 提交于 2019-12-09 04:53:35
问题 I started a similar question on another thread, but then I was focusing on how to use OpenCV. Having failed to achieve what I originally wanted, I will ask here exactly what I want. I have two matrices. Matrix a is 2782x128 and Matrix b is 4000x128, both unsigned char values. The values are stored in a single array. For each vector in a, I need the index of the vector in b with the closest euclidean distance. Ok, now my code to achieve this: #include <windows.h> #include <stdlib.h> #include

Matrix-multiplication using BLAS from Common Lisp

我是研究僧i 提交于 2019-12-09 04:11:35
Let's say I have two matrices (in the form of a Common Lisp array) foo and bar such that: (defvar foo #2A((2 1 6) (7 3 4))) (defvar bar #2A((3 1) (6 5) (2 3))) I would like to perform a matrix multiplication using BLAS without using wrappers such as Matlisp, GSLL, LLA, & co. so that I get an array with the result: #2A((24 25) (47 34)) Which steps should I take to perform such operation? My understanding is that I should call the BLAS matrix multiplication function from the REPL and pass it my arguments foo and bar. In R, I can easily do it like this: foo %*% bar How can I do it in Common Lisp?

Multiply each column of a matrix by another matrix

那年仲夏 提交于 2019-12-08 19:17:01
问题 I have a M x N matrix. I want to multiply each of the N columns by a M x M matrix. The following does this in a loop, but I have no idea how to vectorize it. u=repmat(sin(2*pi*f*t),[n 1]); W = rand(n); answer = size(u); for i=1:size(u,2) answer(:,i) = W*u(:,i); end 回答1: You simply need to multiply the two matrices: answer = W*u; Think about it: in every iteration of your loop you multiply a matrix by a vector. The result of that operation is a vector, which you save into your answer in column

Is there a good double-precision small matrix SIMD library for x86?

我的未来我决定 提交于 2019-12-08 15:48:43
问题 I'm looking for a SIMD library focused small (4x4) matrix operations for graphics. There's lots of single precision ones out there, but I need to support both single and double precision. I've looked at Intel's IPP MX library, but I'd prefer something with source. I'm very interested in SSE3+ implementations of these particular operations: Mat4 * Mat4 Mat4 * Vec4 Mat4 * Array of Mat4 Mat4 * Array of Vec4 Mat4 inversion (nice to have) EDIT: No "premature optimization" answers please. Anyone

C# calling Intel MKL cblas_dgemm_batch

岁酱吖の 提交于 2019-12-08 12:39:43
问题 I can call Intel MKL cblas_dgem from C#, see the following code: [DllImport("custom_mkl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = false)] internal static extern void cblas_dgemm( int Order, int TransA, int TransB, MKL_INT M, MKL_INT N, MKL_INT K, double alpha, [In] double[,] A, MKL_INT lda, [In] double[,] B, MKL_INT ldb, double beta, [In, Out] double[,] C, MKL_INT ldc); and void cblas_dgemm (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE transa,

How do you multiply a matrix by itself?

隐身守侯 提交于 2019-12-08 10:38:20
问题 This is what i have so far but I do not think it is right. for (int i = 0 ; i < 5; i++) { for (int j = 0; j < 5; j++) { matrix[i][j] += matrix[i][j] * matrix[i][j]; } } 回答1: I don't think you can multiply a matrix by itself in-place. for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { product[i][j] = 0; for (k = 0; k < 5; k++) { product[i][j] += matrix[i][k] * matrix[k][j]; } } } Even if you use a less naïve matrix multiplication (i.e. something other than this O(n 3 ) algorithm), you still

Matrix-multiplication using BLAS from Common Lisp

拜拜、爱过 提交于 2019-12-08 06:45:51
问题 Let's say I have two matrices (in the form of a Common Lisp array) foo and bar such that: (defvar foo #2A((2 1 6) (7 3 4))) (defvar bar #2A((3 1) (6 5) (2 3))) I would like to perform a matrix multiplication using BLAS without using wrappers such as Matlisp, GSLL, LLA, & co. so that I get an array with the result: #2A((24 25) (47 34)) Which steps should I take to perform such operation? My understanding is that I should call the BLAS matrix multiplication function from the REPL and pass it my

Different between rotating the camera vs rotating the scene point (only the point, not the entire scene)?

有些话、适合烂在心里 提交于 2019-12-08 05:33:49
问题 I think rotating the camera and taking the photo of a scene would yield the same result with keeping the camera stable and rotating the scene in reverse way. Assume that the original camera rotation matrix is R1. Rotating the camera means that we apply another rotation matrix R12 (so R2=R12*R1 is the new rotation matrix). Assume that X is the realworld coordinate of scene point. Rotating the scene point in the reverse way means that we apply the reverse rotation matrix R12^-1 to X (this might

Null Space Binary Matrix : Java

最后都变了- 提交于 2019-12-08 04:49:58
问题 Here is my question: How to calcul the Kernel of a Binary Matrix ?? To calcul the Kernel (or Null Space if you prefer) in Java, it's pretty simple in the Real Space, there is already a lot of classes, so don't need to invent the wheel again, we just have to use them ! double[][] data = new double[3][3]; // ... fill the Matrix SimpleMatrix m = new SimpleMatrix(data); SimpleSVD svd = m.svd(); SimpleMatrix nullSpace = svd.nullSpace(); nullSpace.print(); (Theses classes came from : http:/