矩陣轉置(x.T)

double testsig[] = {1,2,3,4,5,
                    2,4,6,8,15,
                    3,6,10,12,40,
                    4,8,12,16,20,
                    5,10,14,20,25,
                    6,1,18,24,30};

gsl_matrix *m=gsl_matrix_alloc(6, 5);
gsl_matrix *mT=gsl_matrix_alloc(5, 6);
SetMat(m,testsig);
gsl_matrix_transpose_memcpy(mT, m);
PrintMat(mT);

Autocorrelation Matrix

#include <gsl/gsl_vector.h>
#include <gsl/gsl_statistics_double.h>  //不引入這個會出事

//...

gsl_matrix *Rxx=gsl_matrix_alloc(6, 6);
for (int i=0;i<m->size1;i++){
    for(int j=0;j<mH->size2;j++){
        gsl_vector_view tempa = gsl_matrix_row (m, i);
        gsl_vector_view tempb = gsl_matrix_column (mH, j);
        double corr = gsl_stats_correlation(tempa.vector.data, tempa.vector.stride,
                                            tempb.vector.data, tempb.vector.stride,
                                            tempa.vector.size);
        //printf("%f\\n",corr);
        gsl_matrix_set (Rxx, i, j, corr);
    }
}
PrintMat(Rxx);

Inverse Matrix (還不確定,算出來有夠奇怪)

#include <gsl/gsl_linalg.h>

//...

void invMat(gsl_matrix *matrix,gsl_matrix *inv){
    gsl_permutation *p = gsl_permutation_alloc(matrix->size1);
    int s;

    gsl_linalg_LU_decomp(matrix, p, &s);
    gsl_linalg_LU_invert(matrix, p, inv);
    gsl_permutation_free(p);
}