I am just starting to work with the SSE intrinsic functions. Is there a better way to mupltiply a vector V by a scalar A than what I am doing below?

I would like to do the following u = u + (v*1.5 - vold*0.5)*delta_t;

where u, v, and vold are a vector with x, y, z, coordinates represented in a __m128.

Is there a better way to do this than to create the a, b and c values as I do in the below code? I am running on an Intel i7 computer so any options would be appreciated.

#include "stdafx.h"

#include

#include

#include

using namespace std;

class __declspec(align(16)) Element {

public:

Element( float ux, float uy, float uz, float vx, float vy, float vz, float vxold, float vyold, float vzold) {

u.m128_f32[0] = ux;

u.m128_f32[1] = uy;

u.m128_f32[2] = uz;

v.m128_f32[0] = vx;

v.m128_f32[1] = vy;

v.m128_f32[2] = vz;

vold.m128_f32[0] = vxold;

vold.m128_f32[1] = vyold;

vold.m128_f32[2] = vzold;

}

void Move() {

// u = u + (v*1.5 - vold*0.5)*delta_t;

float delta_t = 0.01;

__m128 a, b, c;

a.m128_f32[0] = 1.5;

a.m128_f32[1] = 1.5;

a.m128_f32[2] = 1.5;

b.m128_f32[0] = 0.5;

b.m128_f32[1] = 0.5;

b.m128_f32[2] = 0.5;

c.m128_f32[0] = delta_t;

c.m128_f32[1] = delta_t;

c.m128_f32[2] = delta_t;

u = _mm_add_ps(u, _mm_mul_ps(_mm_sub_ps(_mm_mul_ps(v,a), _mm_mul_ps(vold,b)), c));

}

__m128 u, v, vold;

};

int _tmain(int argc, _TCHAR* argv[])

{

Element A( 1,1,1, 1,2,3, 4,5,6);

A.Move();

cout << A.u.m128_f32[0] << " " << A.u.m128_f32[1] << " " << A.u.m128_f32[2] << endl;

char c;

cin >> c;

return 0;

}