# get_mat

Get a single element from the matrix.

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

Return Value

get_mat returns the value of the element on row row, column column. If no value was set for this element, the function returns 0.
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.

Remarks

This function is not efficient if many values are to be retrieved. Consider to use get_row, get_rowex, get_column, get_columnex.
If row and/or column are outside the allowed range, the function returns 0.

Example

    #include <stdio.h>
    #include <stdlib.h>
    #include "lp_lib.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, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, get_row, get_rowex, get_column, get_columnex, set_column, set_columnex, set_mat, set_row, set_rowex