QSopt QSget_rows QSopt > Callable Library > Function List
  QSopt
  Downloads
  LP Info
  Software
  Problem Formats
  Callable Library
  Overview
Function List
  Rational Solver
  Beta
  Contact Info
Purpose
Copy all rows.
Synopsis
int QSget_rows (QSprob p, int **rowcnt, int **rowbeg, int **rowind,
    double **rowval, double **rhs, char **sense, char ***names)
Arguments
p a handle to an initialized problem.
rowcnt returns an array of length nrows, the number of rows in the problem, with the ith entry specifying the number of non-zero coefficients in the ith row of the constraint matrix; this field can be NULL.
rowbeg returns an array of length nrows, with the ith entry specifying the location of the start of the ith row in the rowind and rowval arrays; this field can be NULL.
rowind returns an array that contains the column indices of the non-zero coefficients in the rows; the indices for the ith row are stored consecutively starting at entry number rowbeg[i] (there are rowcnt[i] indices for the ith row); this field can be NULL.
rowval returns an array that contains the non-zero coefficients in the rows; the coefficients for the ith row are stored consecutively starting at entry number rowbeg[i] (there are rowcnt[i] coefficients for the ith row); this field can be NULL.
rhs returns the right-hand-side values as an array of length nrows; this field can be NULL.
sense returns an array of length nrows where the ith entry specifies the sense of the ith constraint ('E' for ≥ , 'L' for = ; 'G' for ≤ ); this field can be NULL.
names returns an array of length nrows where the ith entry is a string that specifies the name of the ith constraint; this field can be NULL.
Returns
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
Description

A complete description of the constraints for the problem can be obtained using this function. Each of the arguments returns an array that is allocated by QSget_rows; if some piece of information is not needed, the corresponding argument for the function should be set to NULL. The calling function should free the memory for each of the arrays (and for the strings in the names array) when the information is no longer needed; since the memory for the arrays and strings is allocated by the QSopt library, the memory must be freed with calls to QSfree and not by the system free() function. The form of the row information is the same as that used in the QSadd_rows function.

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

double *rowval = NULL, *rhs = NULL;
int *rowcnt = NULL, *rowbeg = NULL, *rowind = NULL;
char *sense = NULL, **names = NULL;
int nrows, i, j, rval;

nrows = QSget_rowcount (p);
rval = QSget_rows (p, &rowcnt, &rowbeg, &rowind, &rowval, &rhs, &sense,
                      &names);
if (rval) {
    fprintf (stderr, "could not obtain rows, error code %d\n", rval);
} else {
    for (i = 0; i < nrows; i++) {
        printf ("%s RHS = %f, SENSE = %c\n",
                names[i], rhs[i], sense[i]);
        printf ("   Coefficients: ");
        for (j = rowbeg[i]; j < rowbeg[i] + rowcnt[i]; j++) {
            printf ("(%d, %f) ", rowind[j], rowval[j]);
        }
        printf ("\n");
    }
}

QSfree (rowcnt); QSfree (rowbeg); QSfree (rowind); QSfree (rowval);
QSfree (rhs); QSfree (sense);
if (names) {
    for (i = 0; i < nrows; i++) {
        QSfree (names[i]);
    }
    QSfree (names);
}
 
QSopt | Problem Formats | Downloads Back
Last Updated: November 2003