GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
cmmult.c
Go to the documentation of this file.
00001 /*  cmmult.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 cmmult(Cpx * cm, Cpx * a, Cpx * b, int n, int m, int l)
00011 {
00012     Cpx z, *q0, *p, *q;
00013 
00014     int i, j, k;
00015 
00016     q0 = (Cpx *) calloc(m, sizeof(Cpx));
00017     for (i = 0; i < l; ++i, ++cm) {
00018         for (k = 0, p = b + i; k < m; p += l)
00019             q0[k++] = *p;
00020         for (j = 0, p = a, q = cm; j < n; ++j, q += l) {
00021             for (k = 0, z.re = z.im = 0.; k < m; ++k, ++p) {
00022                 z.re += p->re * q0[k].re - p->im * q0[k].im;
00023                 z.im += p->im * q0[k].re + p->re * q0[k].im;
00024             }
00025             *q = z;
00026         }
00027     }
00028     free(q0);
00029 }