|
GRASS Programmer's Manual
6.5.svn(2012)-r51648
|
00001 /* cvmul.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 "ccmath.h" 00009 void cvmul(Cpx * u, Cpx * a, Cpx * v, int n) 00010 { 00011 Cpx *q; 00012 00013 int i, j; 00014 00015 for (i = 0; i < n; ++i, ++u) { 00016 u->re = u->im = 0.; 00017 for (j = 0, q = v; j < n; ++j, ++a, ++q) { 00018 u->re += a->re * q->re - a->im * q->im; 00019 u->im += a->im * q->re + a->re * q->im; 00020 } 00021 } 00022 } 00023 00024 Cpx cvnrm(Cpx * u, Cpx * v, int n) 00025 { 00026 int k; 00027 00028 Cpx z; 00029 00030 z.re = z.im = 0.; 00031 for (k = 0; k < n; ++k, ++u, ++v) { 00032 z.re += u->re * v->re + u->im * v->im; 00033 z.im += u->re * v->im - u->im * v->re; 00034 } 00035 return z; 00036 }