b2ac/ext/src/Eigenmethods_double.c
void performQRStep_Givens_double(double *A, int m)
{
	int k, i;
	int row_ind, giv_ind;
	double tau_one = 0.0;
	double tau_two = 0.0;
	double givensValues[4] = {0.0, 0.0, 0.0, 0.0};

	// If m == 2 then we are still working with the 3x3 matrix.
	if (m == 2)
	{
		// Perform row rotation operations, first with the [0,1] rows,
		// then with [1,2].
		for (k = 0; k < 2; k++)
		{
			// Set indices for obtaining correct data for this iteration.
			giv_ind = 2 * k;
			row_ind = 3 * k;
			// Find the Givens rotation to apply here.
			givensRotation_double(&givensValues[giv_ind],
									 A[row_ind + k],
									 A[row_ind + 3 + k]);
			for (i = 0; i < 3; i++)
			{
				tau_one = A[row_ind + i];
				tau_two = A[row_ind + 3 + i];
				A[row_ind + i] = tau_one * givensValues[giv_ind] -
								 tau_two * givensValues[giv_ind + 1];
				A[row_ind + 3 + i] = tau_one * givensValues[giv_ind + 1] +
									 tau_two * givensValues[giv_ind];
			}
		}
		// Perform column rotation operations.
		for (k = 0; k < 2; k++)
		{
			// Set indices for obtaining correct data for this iteration.
			giv_ind = 2 * k;
			for (i = 0; i < 3; i++)
			{
				row_ind = 3 * i;
				tau_one = A[row_ind + k];
				tau_two = A[row_ind + k + 1];
				A[row_ind + k] = tau_one * givensValues[giv_ind] -
								 tau_two * givensValues[giv_ind + 1];
				A[row_ind + k + 1] = tau_one * givensValues[giv_ind + 1] +
									 tau_two * givensValues[giv_ind];
			}
		}
	}
	else // m == 1, we will be using the upper left 2x2 A.
	{
		// Find the Givens rotation to apply here.
		givensRotation_double(givensValues, A[0], A[3]);

		// Perform row rotation operations.
		tau_one = A[0];
		tau_two = A[3];
		A[0] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[3] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
		tau_one = A[1];
		tau_two = A[4];
		A[1] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[4] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];

		// Perform column rotation operations.
		tau_one = A[0];
		tau_two = A[1];
		A[0] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[1] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
		tau_one = A[3];
		tau_two = A[4];
		A[3] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[4] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
	}
}
/**
 * Performs QR algorithm iteration using Givens rotation.
 *
 * @brief The QR algorithm's key step is to perform a QR decomposition
 * of a Hessenberg matrix and multiply the matrices in reverse order,
 * i.e. RQ. The Givens solution here allows for implicit decomposition
 * and multiplication, yielding a much faster solution.
 *
 */
Performs QR algorithm iteration using Givens rotation.
@brief The QR algorithm's key step is to perform a QR decomposition
of a Hessenberg matrix and multiply the matrices in reverse order,
i.e. RQ. The Givens solution here allows for implicit decomposition
and multiplication, yielding a much faster solution.
Performs QR algorithm iteration using Givens rotation . @brief The QR algorithm ' s key step is to perform a QR decomposition of a Hessenberg matrix and multiply the matrices in reverse order i . e . RQ . The Givens solution here allows for implicit decomposition and multiplication yielding a much faster solution .
void performQRStep_Givens_double(double *A, int m)
{
	int k, i;
	int row_ind, giv_ind;
	double tau_one = 0.0;
	double tau_two = 0.0;
	double givensValues[4] = {0.0, 0.0, 0.0, 0.0};
	if (m == 2)
	{
		for (k = 0; k < 2; k++)
		{
			giv_ind = 2 * k;
			row_ind = 3 * k;
			givensRotation_double(&givensValues[giv_ind],
									 A[row_ind + k],
									 A[row_ind + 3 + k]);
			for (i = 0; i < 3; i++)
			{
				tau_one = A[row_ind + i];
				tau_two = A[row_ind + 3 + i];
				A[row_ind + i] = tau_one * givensValues[giv_ind] -
								 tau_two * givensValues[giv_ind + 1];
				A[row_ind + 3 + i] = tau_one * givensValues[giv_ind + 1] +
									 tau_two * givensValues[giv_ind];
			}
		}
		for (k = 0; k < 2; k++)
		{
			giv_ind = 2 * k;
			for (i = 0; i < 3; i++)
			{
				row_ind = 3 * i;
				tau_one = A[row_ind + k];
				tau_two = A[row_ind + k + 1];
				A[row_ind + k] = tau_one * givensValues[giv_ind] -
								 tau_two * givensValues[giv_ind + 1];
				A[row_ind + k + 1] = tau_one * givensValues[giv_ind + 1] +
									 tau_two * givensValues[giv_ind];
			}
		}
	}
	else 
	{
		givensRotation_double(givensValues, A[0], A[3]);
		tau_one = A[0];
		tau_two = A[3];
		A[0] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[3] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
		tau_one = A[1];
		tau_two = A[4];
		A[1] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[4] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
		tau_one = A[0];
		tau_two = A[1];
		A[0] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[1] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
		tau_one = A[3];
		tau_two = A[4];
		A[3] = tau_one * givensValues[0] -
			   tau_two * givensValues[1];
		A[4] = tau_one * givensValues[1] +
			   tau_two * givensValues[0];
	}
}
void performQRStep_Givens_double ( double * A , int m ) { int k , i ; int row_ind , giv_ind ; double tau_one = 0.0 ; double tau_two = 0.0 ; double givensValues [ 4 ] = { 0.0 , 0.0 , 0.0 , 0.0 } ; if ( m == 2 ) { for ( k = 0 ; k < 2 ; k ++ ) { giv_ind = 2 * k ; row_ind = 3 * k ; givensRotation_double ( & givensValues [ giv_ind ] , A [ row_ind + k ] , A [ row_ind + 3 + k ] ) ; for ( i = 0 ; i < 3 ; i ++ ) { tau_one = A [ row_ind + i ] ; tau_two = A [ row_ind + 3 + i ] ; A [ row_ind + i ] = tau_one * givensValues [ giv_ind ] - tau_two * givensValues [ giv_ind + 1 ] ; A [ row_ind + 3 + i ] = tau_one * givensValues [ giv_ind + 1 ] + tau_two * givensValues [ giv_ind ] ; } } for ( k = 0 ; k < 2 ; k ++ ) { giv_ind = 2 * k ; for ( i = 0 ; i < 3 ; i ++ ) { row_ind = 3 * i ; tau_one = A [ row_ind + k ] ; tau_two = A [ row_ind + k + 1 ] ; A [ row_ind + k ] = tau_one * givensValues [ giv_ind ] - tau_two * givensValues [ giv_ind + 1 ] ; A [ row_ind + k + 1 ] = tau_one * givensValues [ giv_ind + 1 ] + tau_two * givensValues [ giv_ind ] ; } } } else { givensRotation_double ( givensValues , A [ 0 ] , A [ 3 ] ) ; tau_one = A [ 0 ] ; tau_two = A [ 3 ] ; A [ 0 ] = tau_one * givensValues [ 0 ] - tau_two * givensValues [ 1 ] ; A [ 3 ] = tau_one * givensValues [ 1 ] + tau_two * givensValues [ 0 ] ; tau_one = A [ 1 ] ; tau_two = A [ 4 ] ; A [ 1 ] = tau_one * givensValues [ 0 ] - tau_two * givensValues [ 1 ] ; A [ 4 ] = tau_one * givensValues [ 1 ] + tau_two * givensValues [ 0 ] ; tau_one = A [ 0 ] ; tau_two = A [ 1 ] ; A [ 0 ] = tau_one * givensValues [ 0 ] - tau_two * givensValues [ 1 ] ; A [ 1 ] = tau_one * givensValues [ 1 ] + tau_two * givensValues [ 0 ] ; tau_one = A [ 3 ] ; tau_two = A [ 4 ] ; A [ 3 ] = tau_one * givensValues [ 0 ] - tau_two * givensValues [ 1 ] ; A [ 4 ] = tau_one * givensValues [ 1 ] + tau_two * givensValues [ 0 ] ; } }
Performs QR algorithm iteration using Givens rotation.
Performs QR algorithm iteration using Givens rotation .
// If m == 2 then we are still working with the 3x3 matrix. // Perform row rotation operations, first with the [0,1] rows, // then with [1,2]. // Set indices for obtaining correct data for this iteration. // Find the Givens rotation to apply here. // Perform column rotation operations. // Set indices for obtaining correct data for this iteration. // m == 1, we will be using the upper left 2x2 A. // Find the Givens rotation to apply here. // Perform row rotation operations. // Perform column rotation operations.