get_mat, mat_elm

Get a single element from the matrix.

REAL get_mat(lprec *lp, int row, int column);

REAL mat_elm(lprec *lp, int row, int column);

Return Value

get_mat and mat_elm return the value of the element on row row, column column. If no value was set for this element, the function returns 0.

Parameters

lp

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

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.

Remarks

get_mat and mat_elm are identical. mat_elm is for backwards compatibility.
This function is not efficient if many values are to be retrieved. Consider to use get_row, get_column.
If row and/or column are outside the allowed range, the function returns 0.

Example

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

int main(void)
{
  lprec *lp;
  REAL a;

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

  a = get_mat(lp, 1, 2); /* will return 0 because this element isn't created */

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_lp_file, read_LP, read_mps, read_MPS, get_row, get_column, set_mat