gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r27741 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r27741 - gnunet/src/ats
Date: Thu, 4 Jul 2013 09:58:20 +0200

Author: wachs
Date: 2013-07-04 09:58:20 +0200 (Thu, 04 Jul 2013)
New Revision: 27741

Modified:
   gnunet/src/ats/gnunet-service-ats-solver_mlp.c
Log:
new function to update a value in the matrix


Modified: gnunet/src/ats/gnunet-service-ats-solver_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats-solver_mlp.c      2013-07-03 17:05:58 UTC 
(rev 27740)
+++ gnunet/src/ats/gnunet-service-ats-solver_mlp.c      2013-07-04 07:58:20 UTC 
(rev 27741)
@@ -411,7 +411,76 @@
 }
 
 
+/**
+ * Updates an existing value in the matrix
+ *
+ * Extract the row, updates the value and updates the row in the problem
+ *
+ * @param p the mlp problem
+ * @param row the row to create the value in
+ * @param col the column to create the value in
+ * @param val the value to set
+ * @param line calling line for debbuging
+ */
+static void
+mlp_create_problem_update_value (struct MLP_Problem *p,
+                                                                               
                                        int row, int col, double val,
+                                                                               
                                        int line)
+{
+       int c_cols;
+       int c_elems;
+       int c1;
+       double *val_array;
+  int *ind_array;
 
+       GNUNET_assert (NULL != p);
+       GNUNET_assert (NULL != p->prob);
+
+       /* Get number of columns and prepare data structure */
+       c_cols = glp_get_num_cols(p->prob);
+       if (0 >= c_cols)
+               return;
+
+       val_array = GNUNET_malloc (c_cols * sizeof (double));
+       GNUNET_assert (NULL != val_array);
+       ind_array = GNUNET_malloc (c_cols * sizeof (int));
+       GNUNET_assert (NULL != ind_array);
+       /* Extract the row */
+
+       if (0 == (c_elems = glp_get_mat_row (p->prob, row, ind_array, 
val_array)))
+               return;
+
+       /* Update the value */
+       for (c1 = 0; c1 <= c_elems; c1++)
+       {
+               if (ind_array[c1] == row)
+                       break;
+       }
+       if (c_elems == c1)
+               return; /* not found */
+
+       /* Update value */
+       val_array[c1] = val;
+
+       /* Update the row in the matrix */
+       glp_set_mat_row (p->prob, row, c_elems, ind_array, val_array);
+  GNUNET_free (ind_array);
+  GNUNET_free (val_array);
+  //p-> = GNUNET_YES;
+}
+
+/**
+ * Creates a new value in the matrix
+ *
+ * Sets the row and column index in the problem array and increments the
+ * position field
+ *
+ * @param p the mlp problem
+ * @param row the row to create the value in
+ * @param col the column to create the value in
+ * @param val the value to set
+ * @param line calling line for debbuging
+ */
 static void
 mlp_create_problem_set_value (struct MLP_Problem *p,
                                                                                
                                        int row, int col, double val,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]