[cig-commits] r13343 - mc/3D/CitcomS/trunk/lib

tan2 at geodynamics.org tan2 at geodynamics.org
Tue Nov 18 22:49:05 PST 2008


Author: tan2
Date: 2008-11-18 22:49:04 -0800 (Tue, 18 Nov 2008)
New Revision: 13343

Modified:
   mc/3D/CitcomS/trunk/lib/General_matrix_functions.c
Log:
Fixed two bugs in lg_pow(a, n), which computes a^n.

One bug is when n=0, it returned a, instead of 1
Another bug is a^(n-1) was returned


Modified: mc/3D/CitcomS/trunk/lib/General_matrix_functions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/General_matrix_functions.c	2008-11-19 03:19:33 UTC (rev 13342)
+++ mc/3D/CitcomS/trunk/lib/General_matrix_functions.c	2008-11-19 06:49:04 UTC (rev 13343)
@@ -834,12 +834,11 @@
 {
     /* compute the value of "a" raised to the power of "n" */
     long double b = 1.0;
-    int i = 1;
+    int i;
 
-    do {
+    for(i=0; i<n; i++) {
         b = b*a;
-        i++;
-    } while (i<n);
+    }
 
     return(b);
 }



More information about the CIG-COMMITS mailing list