QSopt QSget_rownames QSopt > Callable Library > Function List
  QSopt
  Downloads
  LP Info
  Software
  Problem Formats
  Callable Library
  Overview
Function List
  Rational Solver
  Beta
  Contact Info
Purpose
Copy the names of the rows in the problem.
Synopsis
int QSget_rownames (QSprob p, char **rownames)
Arguments
p a handle to an initialized problem.
rownames returns an array of strings specifying the names of the rows (constraints); this field should point to an array of length at least nrows, the number of rows in the problem.
Returns
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
Description

A QSprob data structure always contains names for each row of the LP problem; if the application does not give explicit row names, then the QSopt library will generate them when the problem is loaded and as new rows are added. The QSget_rownames function will allocate memory for each of the strings that are returned via the array of pointers in rownames; when the application no longer needs the names, the memory associated with each of the strings should be freed; since the memory for the strings was allocated by the QSopt library, the memory must be freed with calls to QSfree rather than by the system free() function.

Example
/* p is an initialized QSprob, a handle to an existing LP problem  */

int rval, nrows, i;
char **rownames;

nrows = QSget_rowcount (p);
rownames = (char **) malloc (nrows * sizeof (char *));

rval = QSget_rownames (p, rownames);
if (rval) {
    fprintf (stderr, 
             "Could not get row names, error code %d\n", rval);
} else {
    printf ("Constraint Names\n");
    for (i = 0; i < nrows; i++) {
        printf ("%s\n", rownames[i]);
    }

    /* Need to free the individual names */

    for (i = 0; i < nrows; i++) {
        /* Use QSfree for mem allocated by QSopt */
        QSfree (rownames[i]); 
    }
}

/* Use free for mem allocated by system malloc */
free (rownames); 
 
QSopt | Problem Formats | Downloads Back
Last Updated: November 2003