This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Inverse of a matrix


Hi,
What I do in my code is:

typedef struct Determinant {
    gsl_matrix * matrix; //!original matrix
    gsl_matrix * inverse; //!inverse matrix
    gsl_matrix * ludecomp; //!LU decomposition
    int size; //!number of electrons
    SPIN_TYPE spin; //!spin type of the determinant
    double det; //! determinant
    gsl_permutation * perm; //! permutation matrix
} Determinant;

Determinant new_determinant(int size, SPIN_TYPE spin) {
    Determinant d;

    d.matrix = gsl_matrix_calloc(size,size);
    d.inverse = gsl_matrix_calloc(size,size);
    d.ludecomp = gsl_matrix_calloc(size,size);
    d.size = size;
    d.spin = spin;
    d.det = 0;
    d.perm = gsl_permutation_alloc(size);
    return d;
}


gboolean set_determinant_via_LU_decomp(Determinant * D,
                                       gboolean CALC_INV) {
    int s;

    gsl_matrix_memcpy(D->ludecomp,D->matrix);
    gsl_linalg_LU_decomp(D->ludecomp,D->perm,&s);
        D->det =gsl_linalg_LU_det(D->ludecomp,s);
    if(CALC_INV) {
        //g_message("Inverting matrix!");
        gsl_linalg_LU_invert(D->ludecomp,D->perm,D->inverse);

    }

    return TRUE;
}

Greetings,
Alan

On Tue, 28 May 2002, Viadrina wrote:

> Hi, I would like to compute a inverse of a square matrix A. Is there
> any direct method implemented in gsl for computing inverses of suqare
> matrices. I want to compute a quadratic form
> 		-1
> 	Q = X'A  X
> 
> Could anybody help me with this topic. I'm not very familiar with gsl.
> 
> Przem
> 
> 
> 

-- 

Alan Aspuru-Guzik                    Dios mueve al jugador, y éste, la pieza.
(510)642-5911 UC Berkeley           ¿Qué Dios detrás de Dios la trama empieza
(925)422-8739 LLNL                de polvo y tiempo y sueño y agonías? -Borges


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]