https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: e54e44dd52e3b010d9d38e2558c07b431a3ec5eb authored by Lars Bilke on 26 March 2023, 21:45:03 UTC
Merge branch 'ci-unittests' into 'master'
Tip revision: e54e44d
PiecewiseLinearMonotonicCurve.h
/**
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 * \file
 *
 * Created on November 11, 2016, 10:49 AM
 */

#pragma once

#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"

namespace MathLib
{
/// Class for strong monotonic curves
class PiecewiseLinearMonotonicCurve final : public PiecewiseLinearInterpolation
{
public:
    /**
     * @ x x coordinates of curve points
     * @ y y coordinates of curve points
     */
    PiecewiseLinearMonotonicCurve(std::vector<double> x,
                                  std::vector<double> y);

    ~PiecewiseLinearMonotonicCurve() = default;

    /// Get variable, x, or abscissa, by a given value \c y, the ordinate.
    /// If this curve is not monotonic, this function gives a fatal error.
    double getInverseVariable(const double y) const;

private:
    /**
     *  Check monotonicity of this curve such as
     *  for any \f$i\f$,
     *    \f$y(x_{i+1})>y(x_{i})\f$ if \f$x_{i+1}>x_{i}\f$
     *  or for any \f$i\f$
     *    \f$y(x_{i+1})<y(x_{i})\f$ if \f$x_{i+1}>x_{i}\f$
     *  \return True if the curve exhibits strong monotonic.
     */
    bool isStrongMonotonic() const;
};
}  // namespace MathLib
back to top