[cig-commits] r4320 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Geometry/src
walter at geodynamics.org
walter at geodynamics.org
Thu Aug 17 17:16:52 PDT 2006
Author: walter
Date: 2006-08-17 17:16:52 -0700 (Thu, 17 Aug 2006)
New Revision: 4320
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.h
Log:
r2698 at earth: boo | 2006-08-17 17:14:15 -0700
r2652 at earth (orig r3733): KathleenHumble | 2006-08-01 00:36:27 -0700
Updated comments in ComplexMath so that it is readable in
doxygen
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2697
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3732
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2698
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3733
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.c 2006-08-18 00:16:49 UTC (rev 4319)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.c 2006-08-18 00:16:52 UTC (rev 4320)
@@ -82,12 +82,12 @@
destination[ REAL_PART ] = real;
destination[ IMAG_PART ] = imag;
}
-
+/** Add real to complex number */
void Cmplx_AddReal( Cmplx self, double real, Cmplx destination ) {
destination[ REAL_PART ] = real + a;
destination[ IMAG_PART ] = b;
}
-
+/** Subtract a complex number from a real number */
void Cmplx_RealMinusCmplx( Cmplx self, double real, Cmplx destination ) {
destination[ REAL_PART ] = real - a;
destination[ IMAG_PART ] = -b;
@@ -116,15 +116,17 @@
destination[ REAL_PART ] = exp( realPart ) * cos( imagPart );
destination[ IMAG_PART ] = exp( realPart ) * sin( imagPart );
}
-
+/** Copy complex value from one variable to another.
+This nicely replaces = sign for assignments */
void Cmplx_Copy( Cmplx X, Cmplx destination ) {
memcpy( destination, X, sizeof(Cmplx) );
}
+
+/** Sets a complex variable to zero */
void Cmplx_Zero( Cmplx X ) {
memset( X, 0, sizeof(Cmplx) );
}
-
/**
X = a + b i
\bar X = a - b i
@@ -191,6 +193,8 @@
destination[ IMAG_PART ] = mod * sin(theta);
}
+/** Rotate complex value through an angle in radians.
+This rotates the complex number on the complex plane. */
void Cmplx_Rotate( Cmplx self, double angle, Cmplx dest ) {
Cmplx rotationFactor;
@@ -199,4 +203,3 @@
Cmplx_Multiply( self, rotationFactor, dest );
}
-
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.h 2006-08-18 00:16:49 UTC (rev 4319)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/ComplexMath.h 2006-08-18 00:16:52 UTC (rev 4320)
@@ -40,8 +40,10 @@
#define __Discretisation_Geometry_ComplexMath_h__
typedef double Cmplx[2];
-
+/** Define names for index into complex numbers.
+Which makes it clear what index it refers to.*/
#define REAL_PART 0
+/** see comments for REAL_PART */
#define IMAG_PART 1
void Cmplx_Add( Cmplx X, Cmplx Y, Cmplx destination ) ;
@@ -65,10 +67,13 @@
void Cmplx_RealPower( Cmplx X, double power, Cmplx destination ) ;
void Cmplx_CmplxPower( Cmplx X, Cmplx power, Cmplx destination ) ;
+/** Calculate the square root of a complex number */
#define Cmplx_Sqrt( self, destination ) \
Cmplx_RealPower( self, 0.5, destination )
+/** Print a complex number.
+Currently uses %g.5 formatting */
#define Journal_PrintCmplx( stream, self ) \
Journal_Printf( stream, #self " = %.5g %c %.5g i\n", (self)[ REAL_PART ], (self)[ IMAG_PART ] >= 0.0 ? '+' : '-', fabs( (self)[ IMAG_PART ] ) )
-#endif
+#endif
More information about the cig-commits
mailing list