This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Dot Product Optimization Question

Tags: None
(comma "," separated)
RLovelett
Registered Member
Posts
11
Karma
0

Dot Product Optimization Question

Thu Sep 22, 2011 3:12 pm
I have a matrix (coeff) where each column of the matrix represents some polynomial coefficients. I have another array of the polynomial variable values (variables). I perform the dot product of a single column of coeff with variables to arrive at my solution. I am trying to optimize the calculation for speed.

Unlike the example below, coeff sometimes has 1024 rows and variables 1024 elements. When the matrix gets this large the calculations start slowing down.

From the documentation it seems that Eigen does not support multithreading (OpenMP) for Vector calculations.

  • Is there another approach you can think of that would take advantage of multiple threads?
  • Suggestions on alternative ways to tackle the same problem?

Code: Select all
MatrixXd coeff(4,4); // In reality this is dynamic that is why MatrixXd
coeff << D1, D2, D3, D4,
         C1, C2, C3, C4,
         B1, B2, B3, B4,
         A1, A2, A3, A4;
size_t sizeOfVariables = 4;
double variables[4] = {1, x, x^2, x^3};

// D1*1 + C1*x + B1*x^2 + A1*x^3
coeff.col(0).dot(Map<VectorXd>(variables, sizeOfVariables));
di4jc8732
Registered Member
Posts
11
Karma
0
How about taking transpose of the coefficient matrix and using regular matrix/vector product? And if you have multiple polynomial values, matrix/matrix product is automatically parallelized.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]