set_mat

Set a single element in the matrix.

unsigned char set_mat(lprec *lp, int row, int column, REAL value);

Return Value

set_mat returns TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.
Note that row entry mode must be off, else this function also fails. See set_add_rowmode

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

row

Row number of the matrix. Must be between 0 and number of rows in the lp. Row 0 is objective function.

column

Column number of the matrix. Must be between 1 and number of columns in the lp.

value

Value to be set for row row, column column.

Remarks

The set_mat function sets a value in the matrix. If there was already a value for this element, it is replaced and if there was no value, it is added.
This function is not efficient if many values are to be set. Consider to use add_constraint, add_constraintex, str_add_constraint, set_row, set_rowex, set_obj_fn, set_obj_fnex, str_set_obj_fn, set_obj, add_column, add_columnex, str_add_column, set_column, set_columnex.

Example

#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"

int main(void)
{
  lprec *lp;

  /* Create a new LP model */
  lp = make_lp(2, 3);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");
    return(1);
  }

  set_mat(lp, 1, 2, 3.1415927);

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, add_constraint, add_constraintex, str_add_constraint, set_row, set_rowex, set_obj_fn, set_obj_fnex, str_set_obj_fn, add_column, add_columnex, str_add_column, set_column, set_columnex, get_column, get_columnex, get_row, get_rowex, get_mat