home *** CD-ROM | disk | FTP | other *** search
- # include <stdlib.h>
- # include <math.h>
- # define nearzero 1.0E-20
- # include "complex.h"
- # include "gj.h"
-
- void ComplexGaussJordan(struct complext *coefary,struct complext *constary,
- int numcol,struct complext *solcoef,
- struct complext *invary,float *det)
- {
- float *inv;
- float *coef;
- float *sol;
- float *cons;
- int nn;
- int i;
- int j;
- float de;
-
- inv = (float *) calloc(4*numcol*numcol,4);
- coef = (float *) calloc(4*numcol*numcol,4);
- sol = (float *) calloc(2*numcol,4);
- cons = (float *) calloc(2*numcol,4);
-
- for ( i = 0; i <= numcol-1; ++i ) {
- for ( j = 0; j <= numcol-1; ++j ) {
- coef[(i * 2 )*2*numcol+(j * 2 )] = coefary[i*numcol +j].x;
- coef[(i * 2 )*2*numcol +(j * 2+1)] = -coefary[i*numcol+j].y;
- coef[(i * 2+1)*2*numcol +(j * 2 )] = coefary[i*numcol+j].y;
- coef[(i * 2+1)*2*numcol +(j * 2+1)] = coefary[i*numcol +j].x;
-
- }
- cons[i * 2 ] = constary[i].x;
- cons[i * 2+1] = constary[i].y;
- }
- nn = 2 * numcol;
- GaussJordan(coef,cons,nn,sol,inv,&de);
- for ( i = 0; i <= numcol-1; ++i ) {
- for ( j = 0; j <= numcol-1; ++j ) {
- invary[i*numcol +j].x = inv[(i * 2)*2*numcol +(j * 2 )];
- invary[i*numcol +j].y = inv[(i * 2+1)*2*numcol +(j * 2 )];
- }
- solcoef[i].x = sol[i * 2 ];
- solcoef[i].y = sol[i * 2+1];
- }
- (*det) = de;
- free(coef); free(inv); free(sol) ; free(cons);
-
- }