Lines Matching refs:hist
58 PetscErrorCode PetscDrawHGCreate(PetscDraw draw, int bins, PetscDrawHG *hist) in PetscDrawHGCreate() argument
65 PetscAssertPointer(hist, 3); in PetscDrawHGCreate()
86 *hist = h; in PetscDrawHGCreate()
103 PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG hist, int bins) in PetscDrawHGSetNumberBins() argument
106 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGSetNumberBins()
107 PetscValidLogicalCollectiveInt(hist, bins, 2); in PetscDrawHGSetNumberBins()
109 if (hist->maxBins < bins) { in PetscDrawHGSetNumberBins()
110 PetscCall(PetscFree(hist->bins)); in PetscDrawHGSetNumberBins()
111 PetscCall(PetscMalloc1(bins, &hist->bins)); in PetscDrawHGSetNumberBins()
112 hist->maxBins = bins; in PetscDrawHGSetNumberBins()
114 hist->numBins = bins; in PetscDrawHGSetNumberBins()
130 PetscErrorCode PetscDrawHGReset(PetscDrawHG hist) in PetscDrawHGReset() argument
133 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGReset()
135 hist->xmin = PETSC_MAX_REAL; in PetscDrawHGReset()
136 hist->xmax = PETSC_MIN_REAL; in PetscDrawHGReset()
137 hist->ymin = 0.0; in PetscDrawHGReset()
138 hist->ymax = 1.e-6; in PetscDrawHGReset()
139 hist->numValues = 0; in PetscDrawHGReset()
155 PetscErrorCode PetscDrawHGDestroy(PetscDrawHG *hist) in PetscDrawHGDestroy() argument
158 if (!*hist) PetscFunctionReturn(PETSC_SUCCESS); in PetscDrawHGDestroy()
159 PetscValidHeaderSpecific(*hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGDestroy()
160 if (--((PetscObject)*hist)->refct > 0) { in PetscDrawHGDestroy()
161 *hist = NULL; in PetscDrawHGDestroy()
165 PetscCall(PetscFree((*hist)->bins)); in PetscDrawHGDestroy()
166 PetscCall(PetscFree2((*hist)->values, (*hist)->weights)); in PetscDrawHGDestroy()
167 PetscCall(PetscDrawAxisDestroy(&(*hist)->axis)); in PetscDrawHGDestroy()
168 PetscCall(PetscDrawDestroy(&(*hist)->win)); in PetscDrawHGDestroy()
169 PetscCall(PetscHeaderDestroy(hist)); in PetscDrawHGDestroy()
189 PetscErrorCode PetscDrawHGAddValue(PetscDrawHG hist, PetscReal value) in PetscDrawHGAddValue() argument
192 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGAddValue()
195 if (hist->numValues >= hist->maxValues) { in PetscDrawHGAddValue()
198 PetscCall(PetscMalloc2(hist->maxValues + CHUNKSIZE, &tmp, hist->maxValues + CHUNKSIZE, &tmpw)); in PetscDrawHGAddValue()
199 PetscCall(PetscArraycpy(tmp, hist->values, hist->maxValues)); in PetscDrawHGAddValue()
200 PetscCall(PetscArraycpy(tmpw, hist->weights, hist->maxValues)); in PetscDrawHGAddValue()
201 PetscCall(PetscFree2(hist->values, hist->weights)); in PetscDrawHGAddValue()
203 hist->values = tmp; in PetscDrawHGAddValue()
204 hist->weights = tmpw; in PetscDrawHGAddValue()
205 hist->maxValues += CHUNKSIZE; in PetscDrawHGAddValue()
209 if (!hist->numValues && (hist->xmin == PETSC_MAX_REAL) && (hist->xmax == PETSC_MIN_REAL)) { in PetscDrawHGAddValue()
210 hist->xmin = value; in PetscDrawHGAddValue()
211 hist->xmax = value; in PetscDrawHGAddValue()
215 if (value > hist->xmax) hist->xmax = value; in PetscDrawHGAddValue()
216 if (value < hist->xmin) hist->xmin = value; in PetscDrawHGAddValue()
218 } else if (hist->numValues == 1) { in PetscDrawHGAddValue()
220 …if (value > hist->xmax) hist->xmax = value + 0.001 * (value - hist->xmin) / (PetscReal)hist->numBi… in PetscDrawHGAddValue()
221 if (value < hist->xmin) { in PetscDrawHGAddValue()
222 hist->xmin = value; in PetscDrawHGAddValue()
223 hist->xmax = hist->xmax + 0.001 * (hist->xmax - hist->xmin) / (PetscReal)hist->numBins; in PetscDrawHGAddValue()
227 …if (value > hist->xmax) hist->xmax = value + 0.001 * (hist->xmax - hist->xmin) / (PetscReal)hist->… in PetscDrawHGAddValue()
228 if (value < hist->xmin) hist->xmin = value; in PetscDrawHGAddValue()
232 hist->values[hist->numValues] = value; in PetscDrawHGAddValue()
233 hist->weights[hist->numValues] = 1.; in PetscDrawHGAddValue()
234 ++hist->numValues; in PetscDrawHGAddValue()
257 PetscErrorCode PetscDrawHGAddWeightedValue(PetscDrawHG hist, PetscReal value, PetscReal weight) in PetscDrawHGAddWeightedValue() argument
260 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGAddWeightedValue()
263 if (hist->numValues >= hist->maxValues) { in PetscDrawHGAddWeightedValue()
266 PetscCall(PetscMalloc2(hist->maxValues + CHUNKSIZE, &tmp, hist->maxValues + CHUNKSIZE, &tmpw)); in PetscDrawHGAddWeightedValue()
267 PetscCall(PetscArraycpy(tmp, hist->values, hist->maxValues)); in PetscDrawHGAddWeightedValue()
268 PetscCall(PetscArraycpy(tmpw, hist->weights, hist->maxValues)); in PetscDrawHGAddWeightedValue()
269 PetscCall(PetscFree2(hist->values, hist->weights)); in PetscDrawHGAddWeightedValue()
271 hist->values = tmp; in PetscDrawHGAddWeightedValue()
272 hist->weights = tmpw; in PetscDrawHGAddWeightedValue()
273 hist->maxValues += CHUNKSIZE; in PetscDrawHGAddWeightedValue()
277 if (!hist->numValues && (hist->xmin == PETSC_MAX_REAL) && (hist->xmax == PETSC_MIN_REAL)) { in PetscDrawHGAddWeightedValue()
278 hist->xmin = value; in PetscDrawHGAddWeightedValue()
279 hist->xmax = value; in PetscDrawHGAddWeightedValue()
282 if (value > hist->xmax) hist->xmax = value; in PetscDrawHGAddWeightedValue()
283 if (value < hist->xmin) hist->xmin = value; in PetscDrawHGAddWeightedValue()
286 hist->values[hist->numValues] = value; in PetscDrawHGAddWeightedValue()
287 hist->weights[hist->numValues] = weight; in PetscDrawHGAddWeightedValue()
288 ++hist->numValues; in PetscDrawHGAddWeightedValue()
304 PetscErrorCode PetscDrawHGDraw(PetscDrawHG hist) in PetscDrawHGDraw() argument
316 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGDraw()
317 PetscCall(PetscDrawIsNull(hist->win, &isnull)); in PetscDrawHGDraw()
319 PetscCallMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)hist), &rank)); in PetscDrawHGDraw()
321 if ((hist->xmin >= hist->xmax) || (hist->ymin >= hist->ymax)) PetscFunctionReturn(PETSC_SUCCESS); in PetscDrawHGDraw()
322 if (hist->numValues < 1) PetscFunctionReturn(PETSC_SUCCESS); in PetscDrawHGDraw()
324 color = hist->color; in PetscDrawHGDraw()
328 xmin = hist->xmin; in PetscDrawHGDraw()
329 xmax = hist->xmax; in PetscDrawHGDraw()
330 ymin = hist->ymin; in PetscDrawHGDraw()
331 ymax = hist->ymax; in PetscDrawHGDraw()
332 numValues = hist->numValues; in PetscDrawHGDraw()
333 values = hist->values; in PetscDrawHGDraw()
334 weights = hist->weights; in PetscDrawHGDraw()
338 draw = hist->win; in PetscDrawHGDraw()
344 bins = hist->bins; in PetscDrawHGDraw()
354 if (maxHeight > ymax) ymax = hist->ymax = maxHeight; in PetscDrawHGDraw()
356 PetscCall(PetscDrawAxisSetLimits(hist->axis, xmin, xmax, ymin, ymax)); in PetscDrawHGDraw()
357 if (hist->calcStats) { in PetscDrawHGDraw()
371 PetscCall(PetscDrawAxisSetLabels(hist->axis, title, xlabel, NULL)); in PetscDrawHGDraw()
373 PetscCall(PetscDrawAxisDraw(hist->axis)); in PetscDrawHGDraw()
385 numBins = hist->numBins; in PetscDrawHGDraw()
386 numBinsOld = hist->numBins; in PetscDrawHGDraw()
387 if (hist->integerBins && (((int)xmax - xmin) + 1.0e-05 > xmax - xmin)) { in PetscDrawHGDraw()
392 PetscCall(PetscDrawHGSetNumberBins(hist, numBins)); in PetscDrawHGDraw()
396 bins = hist->bins; in PetscDrawHGDraw()
417 if (maxHeight > ymax) ymax = hist->ymax = maxHeight; in PetscDrawHGDraw()
419 PetscCall(PetscDrawAxisSetLimits(hist->axis, xmin, xmax, ymin, ymax)); in PetscDrawHGDraw()
420 if (hist->calcStats) { in PetscDrawHGDraw()
434 PetscCall(PetscDrawAxisSetLabels(hist->axis, title, xlabel, NULL)); in PetscDrawHGDraw()
436 PetscCall(PetscDrawAxisDraw(hist->axis)); in PetscDrawHGDraw()
451 PetscCall(PetscDrawHGSetNumberBins(hist, numBinsOld)); in PetscDrawHGDraw()
492 PetscErrorCode PetscDrawHGView(PetscDrawHG hist, PetscViewer viewer) in PetscDrawHGView() argument
500 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGView()
502 if ((hist->xmin > hist->xmax) || (hist->ymin >= hist->ymax)) PetscFunctionReturn(PETSC_SUCCESS); in PetscDrawHGView()
503 if (hist->numValues < 1) PetscFunctionReturn(PETSC_SUCCESS); in PetscDrawHGView()
505 if (!viewer) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)hist), &viewer)); in PetscDrawHGView()
506 PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)hist, viewer)); in PetscDrawHGView()
507 xmax = hist->xmax; in PetscDrawHGView()
508 xmin = hist->xmin; in PetscDrawHGView()
509 numValues = hist->numValues; in PetscDrawHGView()
510 values = hist->values; in PetscDrawHGView()
511 weights = hist->weights; in PetscDrawHGView()
516 bins = hist->bins; in PetscDrawHGView()
528 numBins = hist->numBins; in PetscDrawHGView()
529 numBinsOld = hist->numBins; in PetscDrawHGView()
530 if (hist->integerBins && (((int)xmax - xmin) + 1.0e-05 > xmax - xmin)) { in PetscDrawHGView()
536 PetscCall(PetscDrawHGSetNumberBins(hist, inumBins)); in PetscDrawHGView()
540 bins = hist->bins; in PetscDrawHGView()
566 PetscCall(PetscDrawHGSetNumberBins(hist, inumBins)); in PetscDrawHGView()
569 if (hist->calcStats) { in PetscDrawHGView()
600 PetscErrorCode PetscDrawHGSetColor(PetscDrawHG hist, int color) in PetscDrawHGSetColor() argument
603 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGSetColor()
605 hist->color = color; in PetscDrawHGSetColor()
627 PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG hist, PetscReal x_min, PetscReal x_max, int y_min, … in PetscDrawHGSetLimits() argument
630 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGSetLimits()
632 hist->xmin = x_min; in PetscDrawHGSetLimits()
633 hist->xmax = x_max; in PetscDrawHGSetLimits()
634 hist->ymin = y_min; in PetscDrawHGSetLimits()
635 hist->ymax = y_max; in PetscDrawHGSetLimits()
652 PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG hist, PetscBool calc) in PetscDrawHGCalcStats() argument
655 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGCalcStats()
657 hist->calcStats = calc; in PetscDrawHGCalcStats()
674 PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG hist, PetscBool ints) in PetscDrawHGIntegerBins() argument
677 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGIntegerBins()
679 hist->integerBins = ints; in PetscDrawHGIntegerBins()
701 PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG hist, PetscDrawAxis *axis) in PetscDrawHGGetAxis() argument
704 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGGetAxis()
706 *axis = hist->axis; in PetscDrawHGGetAxis()
725 PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG hist, PetscDraw *draw) in PetscDrawHGGetDraw() argument
728 PetscValidHeaderSpecific(hist, PETSC_DRAWHG_CLASSID, 1); in PetscDrawHGGetDraw()
730 *draw = hist->win; in PetscDrawHGGetDraw()