<commit_before>//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2011-2012 <NAME>
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be 
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#ifndef CHFUNCT_BASE_H
#define CHFUNCT_BASE_H

//////////////////////////////////////////////////
//  
//   ChFunction_Base.h
//
//   Base class for all ChFunction objects, 
//   as scalar functions of scalar variable y=f(t)
//
//   HEADER file for CHRONO,
//	 Multibody dynamics engine
//
// ------------------------------------------------
//             www.deltaknowledge.com
// ------------------------------------------------
///////////////////////////////////////////////////


#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <memory.h>
#include <list>

#include "core/ChApiCE.h"
#include "core/ChMath.h"
#include "core/ChRunTimeType.h"
#include "physics/ChFilePS.h"
#include "physics/ChProplist.h"



namespace chrono 
{


#define CHF_FILE_HEADER_ID  1234.56


#define OPT_VARIABLES_START virtual const char** GetOptVariables() {static const char* mOptVars[]={
#define OPT_VARIABLES_END   0};return mOptVars;}




/// THE INTERFACE BASE CLASS FOR SCALAR FUNCTIONS OF TYPE:
/// 
///  y= f(x)
///
///
///  The ChFunction class defines the base class for all Chrono
/// functions of type y=f(x), that is scalar functions of an 
/// input variable x (usually, the time). ChFunctions are often
/// used to set time-dependent properties, for example to set
/// motion laws in linear actuators, engines, etc.
///  This base class just represent a constant function of
/// the type y= C.  Inherited classes must override at least the
/// Get_y() method, in order to represent more complex functions.

class ChApi ChFunction
{
						// Chrono simulation of RTTI, needed for serialization
	CH_RTTI_ROOT(ChFunction_base);

public:
	ChFunction () {};
	virtual ~ChFunction () {};
	//virtual void Copy (ChFunction* source) =0;
	virtual ChFunction* new_Duplicate () =0;

				/// Each class inherited from the ChFunction class must
				/// return an unique integer identifier with the virtual
				/// function Get_type(). This is useful for fast run-time downcasting etc.
	virtual int Get_Type () {return -1;}				
	
	
		///// THE MOST IMPORTANT MEMBER FUNCTIONS /////    
		//       At least Get_y() should be overridden
		//       by inherited classes.

				/// Returns the y value of the function, at position x. (For this
				/// base class, it will be a constant value y=C).
	virtual double Get_y      (double x) =0;

				/// Returns the dy/dx derivative of the function, at position x. 
				///  Note that inherited classes may also avoid overriding this method,
				/// because this base method already provide a general-purpose numerical differentiation
				/// to get dy/dx only from the Get_y() function. (however, if the analytical derivative
				/// is known, it may better to implement a custom method).
	virtual double Get_y_dx   (double x) {return ((Get_y(x+ BDF_STEP_LOW) - Get_y(x)) / BDF_STEP_LOW); }
	
				/// Returns the ddy/dxdx double derivative of the function, at position x. <commit_msg>All the ChFunctions are inherited from ChShared , so they can be managed with ChSharedPtr<><commit_after>//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2011-2012 <NAME>
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be 
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#ifndef CHFUNCT_BASE_H
#define CHFUNCT_BASE_H

//////////////////////////////////////////////////
//  
//   ChFunction_Base.h
//
//   Base class for all ChFunction objects, 
//   as scalar functions of scalar variable y=f(t)
//
//   HEADER file for CHRONO,
//	 Multibody dynamics engine
//
// ------------------------------------------------
//             www.deltaknowledge.com
// ------------------------------------------------
///////////////////////////////////////////////////


#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <memory.h>
#include <list>

#include "core/ChApiCE.h"
#include "core/ChMath.h"
#include "core/ChShared.h"
#include "physics/ChFilePS.h"
#include "physics/ChProplist.h"



namespace chrono 
{


#define CHF_FILE_HEADER_ID  1234.56


#define OPT_VARIABLES_START virtual const char** GetOptVariables() {static const char* mOptVars[]={
#define OPT_VARIABLES_END   0};return mOptVars;}




/// THE INTERFACE BASE CLASS FOR SCALAR FUNCTIONS OF TYPE:
/// 
///  y= f(x)
///
///
///  The ChFunction class defines the base class for all Chrono
/// functions of type y=f(x), that is scalar functions of an 
/// input variable x (usually, the time). ChFunctions are often
/// used to set time-dependent properties, for example to set
/// motion laws in linear actuators, engines, etc.
///  This base class just represent a constant function of
/// the type y= C.  Inherited classes must override at least the
/// Get_y() method, in order to represent more complex functions.

class ChApi ChFunction : public ChShared
{
						// Chrono simulation of RTTI, needed for serialization
	CH_RTTI(ChFunction_base, ChShared);

public:
	ChFunction () {};
	virtual ~ChFunction () {};
	//virtual void Copy (ChFunction* source) =0;
	virtual ChFunction* new_Duplicate () =0;

				/// Each class inherited from the ChFunction class must
				/// return an unique integer identifier with the virtual
				/// function Get_type(). This is useful for fast run-time downcasting etc.
	virtual int Get_Type () {return -1;}				
	
	
		///// THE MOST IMPORTANT MEMBER FUNCTIONS /////    
		//       At least Get_y() should be overridden
		//       by inherited classes.

				/// Returns the y value of the function, at position x. (For this
				/// base class, it will be a constant value y=C).
	virtual double Get_y      (double x) =0;

				/// Returns the dy/dx derivative of the function, at position x. 
				///  Note that inherited classes may also avoid overriding this method,
				/// because this base method already provide a general-purpose numerical differentiation
				/// to get dy/dx only from the Get_y() function. (however, if the analytical derivative
				/// is known, it may better to implement a custom method).
	virtual double Get_y_dx   (double x) {return ((Get_y(x+ BDF_STEP_LOW) - Get_y(x)) / BDF_STEP_LOW); }
	
				/// Returns the ddy/dxdx double derivative of the function, at position x. 
{'fraction_non_alphanumeric': 0.16324992463069038, 'fraction_numerical': 0.005728067530901417, 'mean_word_length': 2.386932108218479, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4027043', 'n_tokens_mistral': 2066, 'n_tokens_neox': 1895, 'n_words': 742}