get_column, get_columnex

Get all (get_column) or only the non-zero (get_columnex) column elements from the matrix.

unsigned char get_column(lprec *lp, int col_nr, REAL *column);
int get_columnex(lprec *lp, int col_nr, REAL *column, int *nzrow);

Return Value

get_column returns TRUE (1) if the operation was successful. A return value of FALSE (0) indicates an error.
get_columnex returns the number of non-zero elements returned in column and nzrow. If an error occurs, then -1 is returned.
An error occurs when col_nr is not between 1 and the number of columns in the lp.
Note that row entry mode must be off, else these functions also fail. 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

col_nr

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

column

Array in which the values are returned. For get_column, the array must be dimensioned with at least 1get_Nrows elements in the lp. For get_columnex, the array must be dimentioned with at least the number of non-zero elements in the column. If that is unknown, then use 1+get_Nrows in the lp. The return value of the function indicates how many non-zero elements there are.

nzrow

Array in which the row numbers are returned. The array must be dimentioned with at least the number of non-zero elements in the column. If that is unknown, then use 1+get_Nrows in the lp. The return value of the function indicates how many non-zero elements there are.

Remarks

get_column retrieves all values for the given column.
Element 0 of the column array will contain the value of the objective function, element 1 will contain the value for column 1, Element 2 the value for column 2, ...
get_columnex retrieves only the non-zero values for a given column.
Returned values in column and nzrow start from element 0.

Example

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

int main(void)
{
  lprec *lp;
  REAL column[1+2]; /* must be 1 greater than number of rows ! */

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

  get_column(lp, 1, column);

  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_mat, get_row, get_rowex, set_row, set_rowex, set_rh, set_rh_vec, str_set_rh_vec, add_constraint, add_constraintex, str_add_constraint, add_column, add_columnex, str_add_column, set_column, set_columnex