GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
utrnhm.c
Go to the documentation of this file.
00001 /*  utrnhm.c    CCMATH mathematics library source code.
00002  *
00003  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
00004  *  This code may be redistributed under the terms of the GNU library
00005  *  public license (LGPL). ( See the lgpl.license file for details.)
00006  * ------------------------------------------------------------------------
00007  */
00008 #include <stdlib.h>
00009 #include "ccmath.h"
00010 void utrnhm(Cpx * hm, Cpx * a, Cpx * b, int n)
00011 {
00012     Cpx z, *q0, *p, *s, *t;
00013 
00014     int i, j, k;
00015 
00016     q0 = (Cpx *) calloc(n, sizeof(Cpx));
00017     for (i = 0; i < n; ++i) {
00018         for (j = 0, t = b; j < n; ++j) {
00019             z.re = z.im = 0.;
00020             for (k = 0, s = a + i * n; k < n; ++k, ++s, ++t) {
00021                 z.re += t->re * s->re + t->im * s->im;
00022                 z.im += t->im * s->re - t->re * s->im;
00023             }
00024             q0[j] = z;
00025         }
00026         for (j = 0, p = hm + i, t = a; j <= i; ++j, p += n) {
00027             z.re = z.im = 0.;
00028             for (k = 0, s = q0; k < n; ++k, ++t, ++s) {
00029                 z.re += t->re * s->re - t->im * s->im;
00030                 z.im += t->im * s->re + t->re * s->im;
00031             }
00032             *p = z;
00033             if (j < i) {
00034                 z.im = -z.im;
00035                 hm[i * n + j] = z;
00036             }
00037         }
00038     }
00039     free(q0);
00040 }