/* unitary.c CCMATH mathematics library source code. * * Copyright (C) 2000 Daniel A. Atkinson All rights reserved. * This code may be redistributed under the terms of the GNU library * public license (LGPL). ( See the lgpl.license file for details.) * ------------------------------------------------------------------------ */ #include #include "complex.h" static void ortho(); static double tpi=6.283185307179586; double unfl(); void unitary(Cpx *u,int n) { int i,j,k,m; Cpx h,*v,*e,*p,*r; double *g,*q,a; m=n*n; g=(double *)calloc(n*n,sizeof(double)); v=(Cpx *)calloc(m+n,sizeof(Cpx)); e=v+m; h.re=1.; h.im=0.; for(i=0; ire= *q++; } for(i=0,p=v; ire-h.im*p->im; p->im=h.im*p->re+h.re*p->im; p->re=a; } } ortho(g,n); for(i=m=0,p=u; ire=p->im=0.; for(k=0,q=g+m,r=v+j; kre+= *q*r->re; p->im+= *q++ *r->im; } } } free(g); free(v); } static void ortho(double *g,int n) { int i,j,k,m; double *p,*q,c,s,a; for(i=0,p=g; i