Fastest possible vector linear superposition?

Dear friends,

I would please like your help for the following problem: I need to have the fastest possible addition of vectors in order to speed up my code. I understand I can do this element by element, i.e (assuming values are inserted at some stage).

1
2
3
4
5
6
7
8
9
vector<double> vector1,vector2,result;
double a,b;

... // Inserting values in vectors and coefficients

for(int i=0;i<vector1.size();i++)
     {
     result[i]=a*vector1[i]+b*vector2[i];
     }


Is there a fastest way for this (perhaps some Linear Algebra package?, Usage of pointers in some way I don't know?).

I wish to use this in order to store image-like data into vectors and then perform statistical analysis with them (Markov Chain Monte Carlo).

Thank you very much for your time.
Foivos
Last edited on
Hi!

I found Blitz++ and uBLAS (boost library) that have very efficient vector and matrix operations.

:).
Topic archived. No new replies allowed.