H
Hicham Mouline
Hello,
I have a Curve class that holds variable data
x f(x)
------ ---------
0.5 7.8
0.9 6.7
-5.4 6.6
0.0 6.6
1.5 7.8
and a CurveWithError object that holds data as
x f(x) error
------ --------- ----------
0.5 7.8 0.1
0.9 6.7 0.2
-5.4 6.6 0.05
0.0 6.6 0.1
1.5 7.8 0.05
I maintain the Curve object sorted at all times. In particular, the last
thing done by Curve::Curve(...) is to sort the data based on x.
I implemented CurveWithError with the help of Curve so that
class CurveWithError {
private:
Curve mCurve;
ContainerType mErrors;
};
I am trying to implement CurveWithError ctor in a way that I maintain the
invariant of sorted Curve.
in pseudo-code:
// xbegin is the iterator that points to the beginning of the sequence of
x's
// xend is the iterator that points to the end of the sequence of f(x)'s
// fbegin is the iterator that points to the beginning of the sequence of
f(x)'s
// ferrbegin is the iterator that points to the beginning of the sequence of
errors
CurveWithError::CurveWithError(... xbegin, .... xend, .... fbegin,
....ferrbegin )
: mCurve( xbegin, xend, fbegin), // the Curve ctor finished by sorting its
internal container based on the x's
mErrors(xend-xbegin)
{
// I should sort mErrors as well in the same order Curve sorted its
container
}
Ideas to implement this are welcome.
regards,
I have a Curve class that holds variable data
x f(x)
------ ---------
0.5 7.8
0.9 6.7
-5.4 6.6
0.0 6.6
1.5 7.8
and a CurveWithError object that holds data as
x f(x) error
------ --------- ----------
0.5 7.8 0.1
0.9 6.7 0.2
-5.4 6.6 0.05
0.0 6.6 0.1
1.5 7.8 0.05
I maintain the Curve object sorted at all times. In particular, the last
thing done by Curve::Curve(...) is to sort the data based on x.
I implemented CurveWithError with the help of Curve so that
class CurveWithError {
private:
Curve mCurve;
ContainerType mErrors;
};
I am trying to implement CurveWithError ctor in a way that I maintain the
invariant of sorted Curve.
in pseudo-code:
// xbegin is the iterator that points to the beginning of the sequence of
x's
// xend is the iterator that points to the end of the sequence of f(x)'s
// fbegin is the iterator that points to the beginning of the sequence of
f(x)'s
// ferrbegin is the iterator that points to the beginning of the sequence of
errors
CurveWithError::CurveWithError(... xbegin, .... xend, .... fbegin,
....ferrbegin )
: mCurve( xbegin, xend, fbegin), // the Curve ctor finished by sorting its
internal container based on the x's
mErrors(xend-xbegin)
{
// I should sort mErrors as well in the same order Curve sorted its
container
}
Ideas to implement this are welcome.
regards,