XPRSgetnamelist
XPRSgetnamelist |
Purpose
Returns the names for the rows, columns or sets in a given range. The names will be returned in a character buffer, with no trailing whitespace and with each name being separated by a NULL character.
Synopsis
int XPRS_CC XPRSgetnamelist(XPRSprob prob, int type, char names[], int names_len, int * names_len_reqd, int first, int last);
Arguments
prob
|
The current problem.
|
||||||
type
|
|
||||||
names
|
A buffer into which the names will be returned as a sequence of null-terminated strings. The buffer should be of length
names_len bytes. May be NULL if
names_len is
0.
|
||||||
names_len
|
The maximum number of bytes that may be written to the buffer
names.
|
||||||
names_len_reqd
|
A pointer to a variable into which will be written the number of bytes required to contain the names in the specified range. May be NULL if not required.
|
||||||
first
|
First row, column or set in the range.
|
||||||
last
|
Last row, column or set in the range.
|
Example
The following example retrieves and outputs the row and column names for the current problem.
int i, o, cols, rows, cnames_len, rnames_len; char *cnames, *rnames; ... /* Get problem size */ XPRSgetintattrib(prob,XPRS_COLS,&cols); XPRSgetintattrib(prob,XPRS_ROWS,&rows); /* Request number of bytes required to retrieve the names */ XPRSgetnamelist(prob,1,NULL,0,&rnames_len,0,rows-1); XPRSgetnamelist(prob,2,NULL,0,&cnames_len,0,cols-1); /* Now allocate buffers big enough then fetch the names */ cnames = (char *) malloc(sizeof(char)*cnames_len); rnames = (char *) malloc(sizeof(char)*rnames_len); XPRSgetnamelist(prob,1,rnames,rnames_len,NULL,0,rows-1); XPRSgetnamelist(prob,2,cnames,cnames_len,NULL,0,cols-1); /* Output row names */ o=0; for (i=0;i<rows;i++) { printf("Row #%d: %s\n", i, rnames+o); o += strlen(rnames+o)+1; } /* Output column names */ o=0; for (i=0;i<cols;i++) { printf("Col #%d: %s\n", i, cnames+o); o += strlen(cnames+o)+1; }
Related topics