Last Ray of Hope Home of Kaluriel Hargrove

31Mar/11Off

iOS Vector and Matrix Math

Vector Swap

Swaps the contents of two vectors

float vec1[2] = { 1.0f, 2.0f };
float vec2[2] = { 3.0f, 4.0f };
 
vDSP_vswap( &vec1[0], 1, &vec2[0], 1, 2 );
void vDSP_vswap( const float * inInput1Vector, const int inInput1Stride,
		 float * inInput2Vector, const int inInput2Stride,
		 const unsigned int inCount )
{
	for( unsigned int idx = 0; idx < inCount; ++idx )
	{
		const float tmp = *inInput1Vector;
 
		//
		*inInput1Vector = *inInput2Vector;
		*inInput2Vector = tmp;
 
		//
		inInput1Vector += inInput1Stride;
		inInput2Vector += inInput2Stride;
	}
}

 

Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.