b2ac/ext/src/Eigenmethods_double.c
void matrixToHessenbergForm_Householder_double(double *A)
{
    double vk[2] = {0.0, 0.0,};
    double vk_norm = 0.0;
    double dot_array[3] = {0.0, 0.0, 0.0};

    // First iteration, fix zero at position (3,1).
    // Find Householder reflector.
    vk[0] = A[3];
    vk[1] = A[6];
    vk_norm = sqrt(vk[0] * vk[0] + vk[1] * vk[1]);
    vk[0] += signbit(vk[0]) * vk_norm;
    vk_norm = sqrt(vk[0] * vk[0] + vk[1] * vk[1]);
    vk[0] /= vk_norm;
    vk[1] /= vk_norm;

    // Apply Householder reflector.
    dot_array[0] = vk[0] * A[3] + vk[1] * A[6];
    dot_array[1] = vk[0] * A[4] + vk[1] * A[7];
    dot_array[2] = vk[0] * A[5] + vk[1] * A[8];
    A[3] -= 2 * vk[0] * dot_array[0];
    A[4] -= 2 * vk[0] * dot_array[1];
    A[5] -= 2 * vk[0] * dot_array[2];
    A[6] -= 2 * vk[1] * dot_array[0];
    A[7] -= 2 * vk[1] * dot_array[1];
    A[8] -= 2 * vk[1] * dot_array[2];

    dot_array[0] = vk[0] * A[1] + vk[1] * A[2];
    dot_array[1] = vk[0] * A[4] + vk[1] * A[5];
    dot_array[2] = vk[0] * A[7] + vk[1] * A[8];
    A[1] -= 2 * vk[0] * dot_array[0];
    A[2] -= 2 * vk[1] * dot_array[0];
    A[4] -= 2 * vk[0] * dot_array[1];
    A[5] -= 2 * vk[1] * dot_array[1];
    A[7] -= 2 * vk[0] * dot_array[2];
    A[8] -= 2 * vk[1] * dot_array[2];

    // Perform second and final iteration.
    // Find Householder reflector.
    A[2] = -A[2];
    A[5] = -A[5];
    A[7] = -A[7];

    // Done.
}
/**
 * Converts a 3x3 general matrix to a Hessenberg form, using
 * Householder reflections.
 *
 * @brief In Hessenberg form, a matrix has the same eigenvalues
 * as in its original form, but it is upper triangular, with
 * non-zero values from the first subdiagonal and up.
 *
 */
Converts a 3x3 general matrix to a Hessenberg form, using
Householder reflections.

@brief In Hessenberg form, a matrix has the same eigenvalues
as in its original form, but it is upper triangular, with
non-zero values from the first subdiagonal and up.
Converts a 3x3 general matrix to a Hessenberg form using Householder reflections . @brief In Hessenberg form a matrix has the same eigenvalues as in its original form but it is upper triangular with non - zero values from the first subdiagonal and up .
void matrixToHessenbergForm_Householder_double(double *A)
{
    double vk[2] = {0.0, 0.0,};
    double vk_norm = 0.0;
    double dot_array[3] = {0.0, 0.0, 0.0};
    vk[0] = A[3];
    vk[1] = A[6];
    vk_norm = sqrt(vk[0] * vk[0] + vk[1] * vk[1]);
    vk[0] += signbit(vk[0]) * vk_norm;
    vk_norm = sqrt(vk[0] * vk[0] + vk[1] * vk[1]);
    vk[0] /= vk_norm;
    vk[1] /= vk_norm;
    dot_array[0] = vk[0] * A[3] + vk[1] * A[6];
    dot_array[1] = vk[0] * A[4] + vk[1] * A[7];
    dot_array[2] = vk[0] * A[5] + vk[1] * A[8];
    A[3] -= 2 * vk[0] * dot_array[0];
    A[4] -= 2 * vk[0] * dot_array[1];
    A[5] -= 2 * vk[0] * dot_array[2];
    A[6] -= 2 * vk[1] * dot_array[0];
    A[7] -= 2 * vk[1] * dot_array[1];
    A[8] -= 2 * vk[1] * dot_array[2];
    dot_array[0] = vk[0] * A[1] + vk[1] * A[2];
    dot_array[1] = vk[0] * A[4] + vk[1] * A[5];
    dot_array[2] = vk[0] * A[7] + vk[1] * A[8];
    A[1] -= 2 * vk[0] * dot_array[0];
    A[2] -= 2 * vk[1] * dot_array[0];
    A[4] -= 2 * vk[0] * dot_array[1];
    A[5] -= 2 * vk[1] * dot_array[1];
    A[7] -= 2 * vk[0] * dot_array[2];
    A[8] -= 2 * vk[1] * dot_array[2];
    A[2] = -A[2];
    A[5] = -A[5];
    A[7] = -A[7];
}
void matrixToHessenbergForm_Householder_double ( double * A ) { double vk [ 2 ] = { 0.0 , 0.0 , } ; double vk_norm = 0.0 ; double dot_array [ 3 ] = { 0.0 , 0.0 , 0.0 } ; vk [ 0 ] = A [ 3 ] ; vk [ 1 ] = A [ 6 ] ; vk_norm = sqrt ( vk [ 0 ] * vk [ 0 ] + vk [ 1 ] * vk [ 1 ] ) ; vk [ 0 ] += signbit ( vk [ 0 ] ) * vk_norm ; vk_norm = sqrt ( vk [ 0 ] * vk [ 0 ] + vk [ 1 ] * vk [ 1 ] ) ; vk [ 0 ] /= vk_norm ; vk [ 1 ] /= vk_norm ; dot_array [ 0 ] = vk [ 0 ] * A [ 3 ] + vk [ 1 ] * A [ 6 ] ; dot_array [ 1 ] = vk [ 0 ] * A [ 4 ] + vk [ 1 ] * A [ 7 ] ; dot_array [ 2 ] = vk [ 0 ] * A [ 5 ] + vk [ 1 ] * A [ 8 ] ; A [ 3 ] -= 2 * vk [ 0 ] * dot_array [ 0 ] ; A [ 4 ] -= 2 * vk [ 0 ] * dot_array [ 1 ] ; A [ 5 ] -= 2 * vk [ 0 ] * dot_array [ 2 ] ; A [ 6 ] -= 2 * vk [ 1 ] * dot_array [ 0 ] ; A [ 7 ] -= 2 * vk [ 1 ] * dot_array [ 1 ] ; A [ 8 ] -= 2 * vk [ 1 ] * dot_array [ 2 ] ; dot_array [ 0 ] = vk [ 0 ] * A [ 1 ] + vk [ 1 ] * A [ 2 ] ; dot_array [ 1 ] = vk [ 0 ] * A [ 4 ] + vk [ 1 ] * A [ 5 ] ; dot_array [ 2 ] = vk [ 0 ] * A [ 7 ] + vk [ 1 ] * A [ 8 ] ; A [ 1 ] -= 2 * vk [ 0 ] * dot_array [ 0 ] ; A [ 2 ] -= 2 * vk [ 1 ] * dot_array [ 0 ] ; A [ 4 ] -= 2 * vk [ 0 ] * dot_array [ 1 ] ; A [ 5 ] -= 2 * vk [ 1 ] * dot_array [ 1 ] ; A [ 7 ] -= 2 * vk [ 0 ] * dot_array [ 2 ] ; A [ 8 ] -= 2 * vk [ 1 ] * dot_array [ 2 ] ; A [ 2 ] = - A [ 2 ] ; A [ 5 ] = - A [ 5 ] ; A [ 7 ] = - A [ 7 ] ; }
Converts a 3x3 general matrix to a Hessenberg form, using
 Householder reflections.
Converts a 3x3 general matrix to a Hessenberg form using Householder reflections .
// First iteration, fix zero at position (3,1). // Find Householder reflector. // Apply Householder reflector. // Perform second and final iteration. // Find Householder reflector. // Done.