matrix-multiplication

Multiply two 100-Digit Numbers inside Excel Using Matrix

ε祈祈猫儿з 提交于 2020-01-20 09:36:34
问题 I want to multiply two 100-Digit Numbers In Excel using matrix. The issue in Excel is that after 15-digit, it shows only 0. So, the output also need to be in a Matrix. 1st Number: "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" 2nd Number: "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" Output:

How to compute only the diagonal of a matrix product in Octave?

我怕爱的太早我们不能终老 提交于 2020-01-20 01:47:05
问题 Is there a way in Octave to compute and store only the diagonal of a matrix product? Basically like doing: vector = diag(A*B); I don't care about any of the values of A*B except those on the diagonal. The matrix sizes are around 80k x 12 and 12 x 80k , so even if I didn't care about the speed/extra memory it simply wont fit in RAM. Strange, since Octave is a package for huge data sets and diagonals are very important, so it should be possible. 回答1: The first element in the diagonal is the

OpenCV: Multiply Images in C++ and C

自古美人都是妖i 提交于 2020-01-17 05:37:11
问题 I've just used the multiply functions using C api (cvMul) and C++ api (mul and multiply). But I get a different result from the C function and the C++ ones Result of cvMul (it is a white image) Result of mul and multiply Here is the code I use for both implementations: C IplImage * gh = cvCreateImage(cvGetSize(input),IPL_DEPTH_32F,1) ; cvSobel(input,gh,1,0) ; IplImage * gh2 = cvCreateImage(cvGetSize(input),IPL_DEPTH_32F,1) ; cvMul(gh,gh,gh2) ; C++ Mat gh = Mat (input.size(), CV_32FC1); Sobel

matrix multiplication result value range

▼魔方 西西 提交于 2020-01-17 04:41:12
问题 Here is the initial question: About the output value range of LeGall 5/3 wavelet Today I found actually the transform can be seen as a matrix multiplication. It is easy to calculate the wavelet coefficients as a matrix (in order to estimate the value, all the Rounded down action is ignored which will not affect the estimation of the max value). The 1st level of DWT2 has two steps which is to perform the LeGall 5/3 filter on two directions. If we see the I as the input 8*8 matrix and A as the

OpenMP parallelization (Block Matrix Mult)

僤鯓⒐⒋嵵緔 提交于 2020-01-15 11:11:07
问题 I'm attempting to implement block matrix multiplication and making it more parallelized. This is my code : int i,j,jj,k,kk; float sum; int en = 4 * (2048/4); #pragma omp parallel for collapse(2) for(i=0;i<2048;i++) { for(j=0;j<2048;j++) { C[i][j]=0; } } for (kk=0;kk<en;kk+=4) { for(jj=0;jj<en;jj+=4) { for(i=0;i<2048;i++) { for(j=jj;j<jj+4;j++) { sum = C[i][j]; for(k=kk;k<kk+4;k++) { sum+=A[i][k]*B[k][j]; } C[i][j] = sum; } } } } I've been playing around with OpenMP but still have had no luck

parallelizing matrix multiplication through threading and SIMD

。_饼干妹妹 提交于 2020-01-13 08:13:10
问题 I am trying to speed up matrix multiplication on multicore architecture. For this end, I try to use threads and SIMD at the same time. But my results are not good. I test speed up over sequential matrix multiplication: void sequentialMatMul(void* params) { cout << "SequentialMatMul started."; int i, j, k; for (i = 0; i < N; i++) { for (k = 0; k < N; k++) { for (j = 0; j < N; j++) { X[i][j] += A[i][k] * B[k][j]; } } } cout << "\nSequentialMatMul finished."; } I tried to add threading and SIMD

Numpy matrix multiplication of 2d matrix to give 3d matrix

六月ゝ 毕业季﹏ 提交于 2020-01-13 05:49:08
问题 I have two numpy arrays, like A: = array([[0, 1], [2, 3], [4, 5]]) B = array([[ 6, 7], [ 8, 9], [10, 11]]) For each row of A and B, say Ra and Rb respectively, I want to calculate transpose(Ra)*Rb. So for given value of A and B, i want following answer: array([[[ 0, 0], [ 6, 7]], [[ 16, 18], [ 24, 27]], [[ 40, 44], [ 50, 55]]]) I have written the following code to do so: x = np.outer(np.transpose(A[0]), B[0]) for i in range(1,len(A)): x = np.append(x,np.outer(np.transpose(A[i]), B[i]),axis=0)

Unable to execute device kernel in CUDA

时光总嘲笑我的痴心妄想 提交于 2020-01-11 13:59:13
问题 I am trying to call a device kernel within a global kernel. My global kernel is a Matrix Multiplication and my device kernel is finding the maximum value and the index in each column of the product matrix. Following is the code : __device__ void MaxFunction(float* Pd, float* max) { int x = (threadIdx.x + blockIdx.x * blockDim.x); int y = (threadIdx.y + blockIdx.y * blockDim.y); int k = 0; int temp = 0; int temp_idx = 0; for (k = 0; k < wB; ++k) { if(Pd[x*wB + y] > temp){ temp = Pd[x*wB + y];

Matrix/Tensor Triple Product?

拥有回忆 提交于 2020-01-11 01:41:18
问题 An algorithm I'm working on requires computing, in a couple places, a type of matrix triple product. The operation takes three square matrices with identical dimensions, and produces a 3-index tensor. Labeling the operands A , B and C , the (i,j,k) -th element of the result is X[i,j,k] = \sum_a A[i,a] B[a,j] C[k,a] In numpy, you can compute this with einsum('ia,aj,ka->ijk', A, B, C) . Questions: Does this operation have a standard name? Can I compute this with a single BLAS call? Are there

Multiplying values from two different dictionaries together in Python

老子叫甜甜 提交于 2020-01-10 04:01:05
问题 I have two separate dictionaries with keys and values that I would like to multiply together. The values should be multiplied just by the keys that they have. i.e. dict1 = {'a': 1, 'b': 2, 'c': 3} dict2 = {'a': 15, 'b': 10, 'd': 17} dict3 = dict.items() * dict.items() print dict3 #### #dict3 should equal {'a': 15, 'b': 20} If anyone could help, that would be great. Thanks! 回答1: You can use a dict comprehension: >>> {k : v * dict2[k] for k, v in dict1.items() if k in dict2} {'a': 15, 'b': 20}