[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:55:22 UTC 2009


The following commit has been merged in the upstream branch:
commit 2584aa483007926e4491ac36812deebe4c7a6f51
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Fri May 9 17:04:50 2008 +1000

    Generalised gfs_matrix_new() to non-square matrices
    
    darcs-hash:20080509070450-d4795-fc63b98c7b31f408d7e602e3ce3e6f5e43a579b2.gz

diff --git a/modules/terrain.mod b/modules/terrain.mod
index 16544e6..cc94431 100644
--- a/modules/terrain.mod
+++ b/modules/terrain.mod
@@ -263,7 +263,7 @@ static void rms_update (RMS * rms)
       return;
     }
 #else
-    gdouble ** m = gfs_matrix_new (NM, sizeof (gdouble));
+    gdouble ** m = gfs_matrix_new (NM, NM, sizeof (gdouble));
     for (i = 0; i < NM; i++)
       for (j = 0; j < NM; j++)
 	m[i][j] = rms->m[i][j];
diff --git a/src/event.c b/src/event.c
index 96da9e2..9b16a92 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1147,12 +1147,12 @@ static void gfs_event_harmonic_read (GtsObject ** o, GtsFile * fp)
     g_array_append_val (s->omega, omega);
   } while (fp->type != '\n' && fp->type != '{');
 
-  s->Mn = gfs_matrix_new (2*s->omega->len + 1, sizeof (gdouble));
+  s->Mn = gfs_matrix_new (2*s->omega->len + 1, 2*s->omega->len + 1, sizeof (gdouble));
   for (i = 0; i < 2*s->omega->len + 1; i++)
     s->Mn[i][i] = 1.;
 
-  s->M  = gfs_matrix_new (2*s->omega->len + 1, sizeof (gdouble));
-  s->iM = gfs_matrix_new (2*s->omega->len + 1, sizeof (gdouble));
+  s->M  = gfs_matrix_new (2*s->omega->len + 1, 2*s->omega->len + 1, sizeof (gdouble));
+  s->iM = gfs_matrix_new (2*s->omega->len + 1, 2*s->omega->len + 1, sizeof (gdouble));
 
   s->A =    g_malloc (sizeof (GfsVariable *)*s->omega->len);
   s->B =    g_malloc (sizeof (GfsVariable *)*s->omega->len);
diff --git a/src/utils.c b/src/utils.c
index 1c715f3..032cd91 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1376,24 +1376,26 @@ gdouble gfs_matrix_inverse (gdouble ** m, guint n, gdouble pivmin)
 /**
  * gfs_matrix_new:
  * @n: the size of the matrix.
+ * @p: the size of the matrix.
  * @size: the size of the matrix elements.
  *
  * The matrix elements are initialised to zero.
  *
  * Returns: a newly allocated matrix.
  */
-gpointer gfs_matrix_new (guint n, guint size)
+gpointer gfs_matrix_new (guint n, guint p, guint size)
 {
   guint i;
   gpointer * m, a;
   
   g_return_val_if_fail (n > 0, NULL);
+  g_return_val_if_fail (p > 0, NULL);
   g_return_val_if_fail (size > 0, NULL);
 
   m = g_malloc (n*sizeof (gpointer));
-  a = g_malloc0 (n*n*size);
+  a = g_malloc0 (n*p*size);
   for (i = 0; i < n; i++)
-    m[i] = GUINT_TO_POINTER (GPOINTER_TO_UINT (a) + i*n*size);
+    m[i] = GUINT_TO_POINTER (GPOINTER_TO_UINT (a) + i*p*size);
   return m;
 }
 
diff --git a/src/utils.h b/src/utils.h
index 06017c6..da1f1df 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -115,6 +115,7 @@ gdouble            gfs_matrix_inverse       (gdouble ** m,
 					     guint n,
 					     gdouble pivmin);
 gpointer           gfs_matrix_new           (guint n, 
+					     guint p,
 					     guint size);
 void               gfs_matrix_free          (gpointer m);
 
diff --git a/src/vof.c b/src/vof.c
index f128ba6..7358b3d 100644
--- a/src/vof.c
+++ b/src/vof.c
@@ -1864,7 +1864,7 @@ static void parabola_fit_init (ParabolaFit * p, FttVector * o, FttVector * m)
   p->M = gts_matrix_zero (NULL);
   p->rhs[0] = p->rhs[1] = p->rhs[2] = 0.;
 # else
-  p->M = gfs_matrix_new (6, sizeof (gdouble));
+  p->M = gfs_matrix_new (6, 6, sizeof (gdouble));
   p->rhs[0] = p->rhs[1] = p->rhs[2] = p->rhs[3] = p->rhs[4] = p->rhs[5] = 0.;
 # endif
 #endif /* 3D */

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list