From 21e6dd54385d2148c70ffd40e6c325d2dee977a2 Mon Sep 17 00:00:00 2001 From: koldo Date: Mon, 12 Feb 2018 16:03:01 +0000 Subject: [PATCH] *ScatterDraw: Fixed DataSource problem git-svn-id: svn://ultimatepp.org/upp/trunk@11783 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ScatterDraw/DataSource.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uppsrc/ScatterDraw/DataSource.cpp b/uppsrc/ScatterDraw/DataSource.cpp index 3d3de3d02..ce9c07c51 100644 --- a/uppsrc/ScatterDraw/DataSource.cpp +++ b/uppsrc/ScatterDraw/DataSource.cpp @@ -98,6 +98,8 @@ Pointf DataSource::MaxSubDataImp(Getdatafun getdataY, Getdatafun getdataX, int64 const Vector &coeff = polyFit.GetCoeff(); double b = coeff[1]; double a = coeff[2]; + if (IsNull(a) || a < 1E-10) + return Null; return Pointf(-b/2/a, polyFit.f(-b/2/a)); } @@ -159,7 +161,7 @@ double DataSource::Variance(Getdatafun getdata, double avg) { count++; } } - if (count <= 0) + if (count <= 1) return Null; return ret/(count - 1); } @@ -647,6 +649,8 @@ void DataSource::GetSpectralMoments(Getdatafun getdataY, Getdatafun getdataX, bo bool DataSource::SameX(DataSource &data) { int64 num = GetCount(); + if (num == 0) + return false; if (data.GetCount() != num) return false; for (int64 i = 0; i < num; ++i) {