6 #ifndef ClpHelperFunctions_H
7 #define ClpHelperFunctions_H
16 #error "don't have header file for math"
29 void setElements(
double *region,
int size,
double value);
30 void multiplyAdd(
const double *region1,
int size,
double multiplier1,
31 double *region2,
double multiplier2);
32 double innerProduct(
const double *region1,
int size,
const double *region2);
33 void getNorms(
const double *region,
int size,
double &norm1,
double &norm2);
45 for (
int i = 0; i < size; i++)
51 for (
int i = 0; i < size; i++)
52 to[i] = static_cast< double >(from[i]);
57 return (x1 > x2) ? x1 : x2;
62 return (x1 > x2) ? x1 : x2;
67 return (x1 < x2) ? x1 : x2;
72 return (x1 < x2) ? x1 : x2;
86 #define ClpTraceDebug(expression) \
90 void ClpTracePrint(std::string fileName, std::string message,
int line);
91 #define ClpTraceDebug(expression) \
93 if (!(expression)) { \
94 ClpTracePrint(__FILE__, __STRING(expression), __LINE__); \
114 for (
int k = 0; k < nlow; k++) {
115 sum1 += rL[low[k]] * rL[low[k]];
116 sum2 += cL[low[k]] * cL[low[k]];
121 for (
int k = 0; k < nupp; k++) {
122 sum1 += rL[upp[k]] * rL[upp[k]];
123 sum2 += cL[upp[k]] * cL[upp[k]];
139 inline void pdxxxresid1(
ClpPdco *model,
const int nlow,
const int nupp,
const int nfix,
140 int *low,
int *upp,
int *fix,
158 for (
int k = 0; k < nfix; k++)
165 for (
int k = 0; k < nfix; k++)
168 r1 = b - r1 - d2 * d2 * y;
173 for (
int k = 0; k < nlow; k++)
174 rL[low[k]] = bl[low[k]] - x[low[k]] + x1[low[k]];
175 for (
int k = 0; k < nupp; k++)
176 rU[upp[k]] = -bu[upp[k]] + x[upp[k]] + x2[upp[k]];
180 for (
int k = 0; k < nlow; k++)
181 if (rL[low[k]] > normL)
183 for (
int k = 0; k < nupp; k++)
184 if (rU[upp[k]] > normU)
201 inline void pdxxxresid2(
double mu,
int nlow,
int nupp,
int *low,
int *upp,
205 double *center,
double *Cinf,
double *Cinf0)
214 double maxXz = -1e20;
220 for (
int k = 0; k < nlow; k++) {
221 double x1z1 = x1_elts[low[k]] * z1_elts[low[k]];
222 cL_elts[low[k]] = mu - x1z1;
232 for (
int k = 0; k < nupp; k++) {
233 double x2z2 = x2_elts[upp[k]] * z2_elts[upp[k]];
234 cU_elts[upp[k]] = mu - x2z2;
243 *center = maxXz / minXz;
247 for (
int k = 0; k < nlow; k++)
248 if (cL_elts[low[k]] > normL)
249 normL = cL_elts[low[k]];
250 for (
int k = 0; k < nupp; k++)
251 if (cU_elts[upp[k]] > normU)
252 normU = cU_elts[upp[k]];
271 for (
int k = 0; k < n; k++)
273 if ((x_elts[k] / (-dx_elts[k])) < step)
274 step = x_elts[k] / (-dx_elts[k]);
292 for (
int k = 0; k < n; k++)
294 if ((x_elts[k] / (-dx_elts[k])) < step)
295 step = x_elts[k] / (-dx_elts[k]);
This solves problems in Primal Dual Convex Optimization.
void multiplyAdd(const double *region1, int size, double multiplier1, double *region2, double multiplier2)
void getNorms(const double *region, int size, double &norm1, double &norm2)
double twoNorm() const
2-norm of vector
T infNorm() const
infinity-norm of vector
const T * getElements() const
Get element values.
void CoinMemcpyN(const T *from, const CoinBigIndex size, T *to)
This helper function copies an array to another location.
void clear()
Reset the vector (i.e. set all elemenets to zero)
T CoinMax(const T x1, const T x2)
Return the larger (according to operator<() of the arguments.
double CoinSqrt(double x)
void setElements(double *region, int size, double value)
T CoinMin(const T x1, const T x2)
Return the smaller (according to operator<() of the arguments.
void ClpTracePrint(std::string fileName, std::string message, int line)
Trace.
double maximumAbsElement(const double *region, int size)
Note (JJF) I have added some operations on arrays even though they may duplicate CoinDenseVector.
void matVecMult(int, double *, double *)
double innerProduct(const double *region1, int size, const double *region2)