mat.cpp
// quick insertion sort for the eigen values AND corresponding vectors
// in decreasing order of MAGNITUDE
quick insertion sort for the eigen values AND corresponding vectors
in decreasing order of MAGNITUDE
quick insertion sort for the eigen values AND corresponding vectors in decreasing order of MAGNITUDE
void isort(double a[], double *b[], int len)
{
    for (int i=1; i<len; i++) {
        double aa, *bb;
        int j;
        aa = a[i];
        bb = b[i];
        for (j = i-1; (j>=0) && (fabs(a[j])<fabs(aa)); j--) {
            a[j+1] = a[j];
            b[j+1] = b[j];
        }
        a[j+1] = aa;
        b[j+1] = bb;
    }
}
void isort ( double a [ ] , double * b [ ] , int len ) { for ( int i = 1 ; i < len ; i ++ ) { double aa , * bb ; int j ; aa = a [ i ] ; bb = b [ i ] ; for ( j = i - 1 ; ( j >= 0 ) && ( fabs ( a [ j ] ) < fabs ( aa ) ) ; j -- ) { a [ j + 1 ] = a [ j ] ; b [ j + 1 ] = b [ j ] ; } a [ j + 1 ] = aa ; b [ j + 1 ] = bb ; } }
quick insertion sort for the eigen values AND corresponding vectors
in decreasing order of MAGNITUDE
quick insertion sort for the eigen values AND corresponding vectors in decreasing order of MAGNITUDE