2023-01-24 18:57:18 +01:00
# ifndef MLPP_NUMERICAL_ANALYSIS_H
# define MLPP_NUMERICAL_ANALYSIS_H
2023-12-30 00:41:59 +01:00
/*************************************************************************/
/* numerical_analysis.h */
/*************************************************************************/
/* This file is part of: */
/* PMLPP Machine Learning Library */
/* https://github.com/Relintai/pmlpp */
/*************************************************************************/
2023-12-30 00:43:39 +01:00
/* Copyright (c) 2023-present Péter Magyar. */
2023-12-30 00:41:59 +01:00
/* Copyright (c) 2022-2023 Marc Melikyan */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
2023-01-23 21:13:26 +01:00
//
// NumericalAnalysis.hpp
//
//
2024-01-25 13:42:45 +01:00
# ifdef USING_SFW
# include "sfw.h"
# else
2023-01-27 13:01:16 +01:00
# include "core/math/math_defs.h"
2023-02-12 16:06:59 +01:00
# include "core/object/reference.h"
2023-12-29 18:37:06 +01:00
# include "core/containers/vector.h"
# include "core/string/ustring.h"
2024-01-25 13:42:45 +01:00
# endif
2023-12-29 18:37:06 +01:00
class MLPPVector ;
class MLPPMatrix ;
class MLPPTensor3 ;
2023-01-23 21:13:26 +01:00
2023-02-12 16:06:59 +01:00
class MLPPNumericalAnalysis : public Reference {
GDCLASS ( MLPPNumericalAnalysis , Reference ) ;
2023-01-24 19:20:18 +01:00
2023-01-24 19:00:54 +01:00
public :
/* A numerical method for derivatives is used. This may be subject to change,
as an analytical method for calculating derivatives will most likely be used in
the future .
*/
2023-12-29 18:37:06 +01:00
real_t num_diffr ( real_t ( * function ) ( real_t ) , real_t x ) ;
real_t num_diff_2r ( real_t ( * function ) ( real_t ) , real_t x ) ;
real_t num_diff_3r ( real_t ( * function ) ( real_t ) , real_t x ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t constant_approximationr ( real_t ( * function ) ( real_t ) , real_t c ) ;
real_t linear_approximationr ( real_t ( * function ) ( real_t ) , real_t c , real_t x ) ;
real_t quadratic_approximationr ( real_t ( * function ) ( real_t ) , real_t c , real_t x ) ;
real_t cubic_approximationr ( real_t ( * function ) ( real_t ) , real_t c , real_t x ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t num_diffv ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & , int axis ) ;
real_t num_diff_2v ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & , int axis1 , int axis2 ) ;
real_t num_diff_3v ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & , int axis1 , int axis2 , int axis3 ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t newton_raphson_method ( real_t ( * function ) ( real_t ) , real_t x_0 , real_t epoch_num ) ;
real_t halley_method ( real_t ( * function ) ( real_t ) , real_t x_0 , real_t epoch_num ) ;
real_t inv_quadratic_interpolation ( real_t ( * function ) ( real_t ) , const Ref < MLPPVector > & x_0 , int epoch_num ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t eulerian_methodr ( real_t ( * derivative ) ( real_t ) , real_t q_0 , real_t q_1 , real_t p , real_t h ) ; // Euler's method for solving diffrential equations.
real_t eulerian_methodv ( real_t ( * derivative ) ( const Ref < MLPPVector > & ) , real_t q_0 , real_t q_1 , real_t p , real_t h ) ; // Euler's method for solving diffrential equations.
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t growth_method ( real_t C , real_t k , real_t t ) ; // General growth-based diffrential equations can be solved by seperation of variables.
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
Ref < MLPPVector > jacobian ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ; // Indeed, for functions with scalar outputs the Jacobians will be vectors.
Ref < MLPPMatrix > hessian ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ;
Ref < MLPPTensor3 > third_order_tensor ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ;
Vector < Ref < MLPPMatrix > > third_order_tensorvt ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t constant_approximationv ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & c ) ;
real_t linear_approximationv ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & c , const Ref < MLPPVector > & x ) ;
real_t quadratic_approximationv ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & c , const Ref < MLPPVector > & x ) ;
real_t cubic_approximationv ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & c , const Ref < MLPPVector > & x ) ;
2023-01-24 19:00:54 +01:00
2023-12-29 18:37:06 +01:00
real_t laplacian ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ; // laplacian
String second_partial_derivative_test ( real_t ( * function ) ( const Ref < MLPPVector > & ) , const Ref < MLPPVector > & x ) ;
2023-01-24 19:20:18 +01:00
2023-02-12 16:06:59 +01:00
protected :
static void _bind_methods ( ) ;
} ;
2023-01-23 21:13:26 +01:00
# endif /* NumericalAnalysis_hpp */