38 if (_t ==
PT_NONE || !nDim || samples.size() < nDim || samples.size() < nAxes || !nLayers)
44 for (
size_t s = 0; s < samples.size(); s++)
56 for (
size_t l = 0; l < nLayers; l++)
59 nDim >= 2 ? samples[
YCOORD] : 1,
60 nDim == 3 ? samples[
ZCOORD] : 1);
62 nDim >= 2 ? samples[
YCOORD] : 1,
63 nDim == 3 ? samples[
ZCOORD] : 1);
64 data[l].first.Put(NAN);
65 data[l].second.Put(NAN);
72 for (
size_t a = 0; a < nAxes; a++)
74 axes[a].Create(samples[a]);
94 if (layer >=
data.size()
95 || x >= (
size_t)
data[layer].first.nx
96 || y >= (
size_t)
data[layer].first.ny
97 || z >= (
size_t)
data[layer].first.nz)
100 data[layer].first.a[x +
data[layer].first.nx*y +
data[layer].first.nx*
data[layer].first.ny*z] =
mu::isinf(val) ? NAN : val.real();
101 data[layer].second.a[x +
data[layer].second.nx*y +
data[layer].second.nx*
data[layer].second.ny*z] =
mu::isinf(val) ? NAN : val.imag();
117 if (c >=
axes.size())
120 if (pos >= (
size_t)
axes[c].nx)
137 for (
size_t l = 0; l <
data.size(); l++)
143 for (
size_t n = 0; n <
axes.size(); n++)
165 for (
int n = 0; n <
axes[c].GetNN(); n++)
167 axes[c].a[n] =
axes[c].a[n] >= 0.0 ?
axes[c].a[n] : NAN;
170 else if (c -
axes.size() <
data.size())
172 for (
int i = 0; i <
data[c-
axes.size()].first.GetNN(); i++)
175 ?
data[c-
axes.size()].first.a[i] : NAN;
177 ?
data[c-
axes.size()].second.a[i] : NAN;
193 if (c >=
axes.size())
212 if (layer >=
data.size())
221 ivl.
intervals.push_back(ivl[0].combine(ivl[1]));
222 mglData normData =
norm(layer);
224 ivl.
setNames({
"Re",
"Im",
"ReIm",
"AbsReIm"});
240 if (layer >=
data.size())
243 mglData absData =
data[layer].first *
data[layer].first +
data[layer].second*
data[layer].second;
245 for (
int i = 0; i < absData.GetNN(); i++)
246 absData.a[i] = sqrt(absData.a[i]);
262 if (layer >=
data.size())
265 mglData phaseData(
data[layer].first.nx,
data[layer].first.ny,
data[layer].first.nz);
267 for (
int i = 0; i < phaseData.GetNN(); i++)
268 phaseData.a[i] = atan2(
data[layer].second.a[i],
data[layer].first.a[i]);
284 if (layer >=
data.size())
287 return data[layer].second.Minimal() != 0.0 ||
data[layer].second.Maximal() != 0.0;
304 for (
int n = 0; n <
axes[c].nx; n++)
306 axes[c].a[n] = ::fmod(
axes[c].a[n], mod);
308 if (
axes[c].a[n] < 0)
312 else if (c -
axes.size() <
data.size())
314 for (
int n = 0; n <
data[c-
axes.size()].first.GetNN(); n++)
316 data[c-
axes.size()].first.a[n] = ::fmod(
data[c-
axes.size()].first.a[n], mod);
317 data[c-
axes.size()].second.a[n] = ::fmod(
data[c-
axes.size()].second.a[n], mod);
319 if (
data[c-
axes.size()].first.a[n] < 0)
320 data[c-
axes.size()].first.a[n] += mod;
322 if (
data[c-
axes.size()].second.a[n] < 0)
323 data[c-
axes.size()].second.a[n] += mod;
338 int maxdim =
data[0].first.nx;
341 for (
size_t val = 1; val <
data.size(); val++)
343 if (maxdim <
data[val].first.nx)
344 maxdim =
data[val].first.nx;
348 mglData _mData(maxdim,
data.size());
350 for (
size_t val = 0; val <
data.size(); val++)
352 for (
int col = 0; col <
data[val].first.nx; col++)
354 _mData.a[col + val * maxdim] =
data[val].first.a[col];
376 if (layer >=
data.size())
379 mglData cp(
data[layer].first);
381 size_t lowerpos =
rint(fabs(1.0-dLowerPercentage)/2.0*(nLength));
382 size_t upperpos =
rint((dUpperPercentage/2.0+0.5)*(nLength));
384 ivl[0].reset(cp.a[lowerpos], cp.a[upperpos]);
386 cp =
data[layer].second;
388 lowerpos =
rint(fabs(1.0-dLowerPercentage)/2.0*(nLength));
389 upperpos =
rint((dUpperPercentage/2.0+0.5)*(nLength));
391 ivl[1].reset(cp.a[lowerpos], cp.a[upperpos]);
418 for (
size_t i = 0; i <
assets.size(); i++)
424 || (coord ==
ONLYLEFT &&
assets[i].boundAxes.find(
'l') != std::string::npos)
425 || (coord ==
ONLYRIGHT &&
assets[i].boundAxes.find(
'r') != std::string::npos))
429 for (
size_t l = 0; l <
assets[i].getLayers(); l++)
431 dataIntervals =
assets[i].getDataIntervals(l);
434 ivl[n] = ivl[n].combine(dataIntervals[n]);
439 if ((
int)
assets[i].getLayers() <= coord)
445 ivl[n] = ivl[n].combine(dataIntervals[n]);
466 for (
size_t i = 0; i <
assets.size(); i++)
491 std::pair<double, double> maxnorm(0, 0);
495 for (
size_t layer = 0; layer < ass.getLayers(); layer++)
512 for (
size_t layer = 0; layer < ass.getLayers(); layer++)
515 ass.data[layer].first /= maxnorm.first * maxnorm.first /
m_maxnorm.first;
518 ass.data[layer].second /= maxnorm.second * maxnorm.second /
m_maxnorm.second;
566 for (
size_t i = 0; i <
assets.size(); i++)
572 || (coord ==
ONLYLEFT &&
assets[i].boundAxes.find(
'l') != std::string::npos)
573 || (coord ==
ONLYRIGHT &&
assets[i].boundAxes.find(
'r') != std::string::npos))
577 for (
size_t l = 0; l <
assets[i].getLayers(); l++)
579 dataIntervals =
assets[i].getWeightedRanges(l, dLowerPercentage, dUpperPercentage);
586 if ((
int)
assets[i].getLayers() <= coord)
589 IntervalSet dataIntervals =
assets[i].getWeightedRanges(coord, dLowerPercentage, dUpperPercentage);
638 if (log(ivl.
range()) > 5)
640 const double dPercentage = 0.975;
641 const double dSinglePercentageValue = 0.99;
642 double dSinglePercentageUse;
645 dSinglePercentageUse = dSinglePercentageValue;
647 dSinglePercentageUse = dPercentage;
649 if (log(fabs(ivl.
min())) <= 1)
651 else if (log(fabs(ivl.
max())) <= 1)
694 for (
size_t i = 0; i <
assets.size(); i += every)
698 if (
assets[i].getDim() == 1)
This class represents a single interval in code providing reading access functionality.
double range() const
Return the real inteval range of this interval.
double max() const
Return the maximal element in the interval.
double min() const
Return the minimal element in the interval.
void weightedRange(int coord, Interval &ivl) const
This member function does the "undefined data point" magic, where the range of the plot is chosen so ...
IntervalSet getIntervalsOfType(PlotType t, int coord) const
Returns the intervals fitting to all selected data and type.
IntervalSet getFunctionAxes() const
Returns the axis intervals of function plots.
IntervalSet getDataIntervals(int coord=ALLRANGES) const
Returns the intervals fitting to all selected data.
IntervalSet getFunctionIntervals(int coord=ALLRANGES) const
Returns the intervals fitting to all selected data.
IntervalSet getDataAxes() const
Returns the axis intervals of data plots.
bool hasDataPlots() const
Returns true, if the manager contains some data plots.
void applyCoordSys(CoordinateSystem coords, size_t every=1)
Apply the necessary transformation for the selected coordinate system to the managed assets.
IntervalSet getWeightedFunctionIntervals(int coord=ALLRANGES, double dLowerPercentage=1.0, double dUpperPercentage=1.0) const
Returns the central function quantiles.
std::pair< double, double > m_maxnorm
void normalize(int t_animate)
Normalize the managed data to be below 1 (or the starting amplitude in an animation).
std::vector< PlotAsset > assets
IntervalSet getAxisIntervalsOfType(PlotType t) const
Returns the axis intervals of the selected type.
Common exception class for all exceptions thrown in NumeRe.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
bool isinf(const value_type &v)
value_type rint(value_type v)
mglData duplicatePoints(const mglData &_mData)
This static function is a fix for the MathGL bug, which connects points outside of the data range.
This class represents a set of intervals used together for calculations and simulations.
void setNames(const std::vector< std::string > &vNames)
Set the interval names.
std::vector< Interval > intervals
A single plot data asset to be plotted. Contains the data, its axes and its type.
std::vector< mglData > axes
mglData norm(size_t layer) const
Get the absolute value of the complex value contained within this asset.
IntervalSet getWeightedRanges(size_t layer=0, double dLowerPercentage=1.0, double dUpperPercentage=1.0) const
Get the centralized data quantiles.
mglData arg(size_t layer) const
Get the phase angle of the complex value contained within this asset.
void duplicatePoints()
This function is a fix for the MathGL bug, which connects points outside of the data range.
void applyModulus(PlotCoords c, double mod)
Apply a modulus to a selected axis (e.g. for curvilinear coordinates).
std::vector< std::pair< mglData, mglData > > data
IntervalSet getDataIntervals(size_t layer=0) const
Return the internal data arrays for real and imaginary values.
void writeData(const mu::value_type &val, size_t layer, size_t x, size_t y=0, size_t z=0)
Convenience function to write multi- dimensional data to the internal data object.
bool isComplex(size_t layer=0) const
Return true, if the internal data is complex valued.
void removeNegativeValues(PlotCoords c)
This function is a fix for the MathGL bug to connect points, which are out of data range....
mglData vectorsToMatrix() const
Converts the vectors in multiple layers into a single matrix.
void writeAxis(double val, size_t pos, PlotCoords c=XCOORD)
Convenience function to write the axis values.
void create(PlotType _t, size_t nDim, size_t nAxes, const std::vector< size_t > &samples, size_t nLayers=1)
Prepares the internal memory to fit the desired elements.
Interval getAxisInterval(PlotCoords c=XCOORD) const
Return the interval, which is governed by the corresponding axis.