getqexpnextterm
getqexpnextterm |
Purpose
Synopsis
void *getqexpnextterm(XPRMctx ctx, void *quadctx, mmquad_qexp q, void *prev, XPRMmpvar *v1, XPRMmpvar *v2, double *coeff);
Arguments
ctx
|
Mosel's execution context
|
quadctx
|
Context of
mmquad
|
q
|
Reference to a quadratic expression
|
prev
|
Last value returned by this function. Should be
NULL for the first call
|
v1,v2
|
Pointers to return the decision variable references for the current term
|
coeff
|
Pointer to return the coefficient of the current term
|
Return value
The value to be used as
prev for the next call o
NULL when all terms have been returned.
Example
The following displays the terms of a quadratic expression:
void dispqexp(XPRMcontext ctx, mmquad_qexp q) { void *prev; XPRMmpvar v1,v2; double coeff; int nlin,ct; mq->getqexpstat(ctx, quadctx, q, &nlin, NULL, NULL, NULL); ct=0; prev=mq->getqexpnextterm(ctx, quadctx, q, NULL, &v1, &v2, &coeff); mm->printf(ctx, "%g ", coeff); while(prev!=NULL) { prev=mq->getqexpnextterm(ctx, quadctx, q, prev, &v1, &v2, &coeff); if(ct<nlin) { mm->printf(ctx,"%+g %p", coeff, v2); ct++; } else mm->printf(ctx,"%+g %p * %p", coeff, v1, v2); } mm->printf(ctx,"\n"); }
Further information
This function can be called repeatedly to enumerate all terms of a quadratic expression. For the first call, the parameter
prev must be
NULL and the function returns the constant term of the quadratic expression (for
v1 and
v2 the value
NULL is returned and
coeff contains the constant term). For the following calls, the value of
prev must be the last value returned by the function. The enumeration is completed when the function returns
NULL.
If this function is called repeatedly, after the constant term it returns next all linear terms and then the quadratic terms.
If this function is called repeatedly, after the constant term it returns next all linear terms and then the quadratic terms.
Module