Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Amath.cc

Go to the documentation of this file.
00001 // Amath.cc
00002 // SuperMix version 1.0  C++ source file
00003 //
00004 // Copyright (c) 1999 California Institute of Technology.
00005 // All rights reserved.
00006 //
00007 // Redistribution and use in source and binary forms for noncommercial
00008 // purposes are permitted provided that the above copyright notice and
00009 // this paragraph are duplicated in all such forms and that any
00010 // documentation and other materials related to such distribution and
00011 // use acknowledge that the software was developed by California
00012 // Institute of Technology. Redistribution and/or use in source or
00013 // binary forms is not permitted for any commercial purpose. Use of
00014 // this software does not include a permitted use of the Institute's
00015 // name or trademark for any purpose.
00016 //
00017 // DISCLAIMER:
00018 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00019 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00020 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00021 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00022 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00023 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00024 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00025 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00026 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00027 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00028 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00029 // MATERIALS.
00030 //
00031 // Change history:
00032 // 11/11/98: Changed appropriate arguments to const
00033 // 9/19/97:  Added Aapply()
00034 
00035 #include "Amath.h"
00036 
00037 void Aset( Complex dest[], Complex s, int len )
00038 {
00039   register Complex * d = dest + len;
00040   while (d != dest) *(--d) = s;
00041 }
00042 
00043 void Aset( double dest[], double s, int len )
00044 {
00045   register double * d = dest + len;
00046   while (d != dest) *(--d) = s;
00047 }
00048 
00049 void Ascale( Complex dest[], double s, int len )
00050 {
00051   register Complex * d = dest + len;
00052   while (d != dest) *(--d) *= s;
00053 }
00054 
00055 void Ascale( Complex dest[], Complex s, int len )
00056 {
00057   register Complex * d = dest + len;
00058   while (d != dest) *(--d) *= s;
00059 }
00060 
00061 void Ascale( double dest[], double s, int len )
00062 {
00063   register double * d = dest + len;
00064   while (d != dest) *(--d) *= s;
00065 }
00066 
00067 void Aadd( Complex *dest, const Complex *source, int len )
00068 {
00069   register Complex * d = dest + len;
00070   register const Complex * s = source + len;
00071 
00072   while (d != dest) *(--d) += *(--s);
00073 }
00074 
00075 void Aadd( double *dest, const double *source, int len )
00076 {
00077   register double * d = dest + len;
00078   register const double * s = source + len;
00079 
00080   while (d != dest) *(--d) += *(--s);
00081 }
00082 
00083 void Aadd( Complex *dest, const double *source, int len )
00084 {
00085   register Complex * d = dest + len;
00086   register const double * s = source + len;
00087 
00088   while (d != dest) *(--d) += *(--s);
00089 }
00090 
00091 void Asub( Complex *dest, const Complex *source, int len )
00092 {
00093   register Complex * d = dest + len;
00094   register const Complex * s = source + len;
00095 
00096   while (d != dest) *(--d) -= *(--s);
00097 }
00098 
00099 void Asub( double *dest, const double *source, int len )
00100 {
00101   register double * d = dest + len;
00102   register const double * s = source + len;
00103 
00104   while (d != dest) *(--d) -= *(--s);
00105 }
00106 
00107 void Asub( Complex *dest, const double *source, int len )
00108 {
00109   register Complex * d = dest + len;
00110   register const double * s = source + len;
00111 
00112   while (d != dest) *(--d) -= *(--s);
00113 }
00114 
00115 void Ascalesub( Complex *dest, const Complex *source, Complex scale, int len )
00116 {
00117   register Complex * d = dest + len;
00118   register const Complex * s = source + len;
00119 
00120   while (d != dest) *(--d) -= ((*(--s)) * scale);
00121 }
00122 
00123 void Ascalesub( double *dest, const double *source, double scale, int len )
00124 {
00125   register double * d = dest + len;
00126   register const double * s = source + len;
00127   register double rs = scale;
00128 
00129   while (d != dest) *(--d) -= ((*(--s)) * rs);
00130 }
00131 
00132 Complex Adot( const Complex *a1, const Complex *a2, int len )
00133 {
00134   register const Complex * ra1 = a1 + len;
00135   register const Complex * ra2 = a2 + len;
00136   Complex sum(0.0);
00137 
00138   while (ra1 != a1) sum += (conj(*(--ra1)) * (*(--ra2)));
00139   return sum;
00140 }
00141 
00142 double Adot( const double *a1, const double *a2, int len )
00143 {
00144   register const double * ra1 = a1 + len;
00145   register const double * ra2 = a2 + len;
00146   register double sum = 0.0;;
00147 
00148   while (ra1 != a1) sum += (*(--ra1)) * (*(--ra2));
00149   return sum;
00150 }
00151 
00152 void Aapply( Complex a[], Complex (* f)(Complex), int len)
00153 {
00154   register Complex * d = a + len;
00155   while (d-- != a) *d = f(*d);
00156 }
00157 
00158 void Aapply( Complex a[], Complex (* f)(Complex &), int len)
00159 {
00160   register Complex * d = a + len;
00161   while (d-- != a) *d = f(*d);
00162 }
00163 
00164 void Aapply( Complex a[], Complex (* f)(const Complex &), int len)
00165 {
00166   register Complex * d = a + len;
00167   while (d-- != a) *d = f(*d);
00168 }
00169 
00170 void Aapply( double a[], double (* f)(double), int len)
00171 {
00172   register double * d = a + len;
00173   while (d-- != a) *d = f(*d);
00174 }
00175 
00176 void Aapply( double a[], double (* f)(double &), int len)
00177 {
00178   register double * d = a + len;
00179   while (d-- != a) *d = f(*d);
00180 }
00181 
00182 void Aapply( double a[], double (* f)(const double &), int len)
00183 {
00184   register double * d = a + len;
00185   while (d-- != a) *d = f(*d);
00186 }

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7