📄 cfunc.mod
字号:
/* $Id: cfunc.mod,v 1.3 2004/07/09 18:37:57 pnenzi Exp $ *//*.......1.........2.........3.........4.........5.........6.........7.........8================================================================================FILE pwl/cfunc.modCopyright 1991Georgia Tech Research Corporation, Atlanta, Ga. 30332All Rights ReservedPROJECT A-8503-405 AUTHORS 19 Apr 1991 Jeffrey P. MurrayMODIFICATIONS 25 Sep 1991 Jeffrey P. Murray 2 Oct 1991 Jeffrey P. Murray SUMMARY This file contains the model-specific routines used to functionally describe the pwl (piece-wise linear) code model.INTERFACES FILE ROUTINE CALLED CMutil.c void cm_smooth_corner(); CMmacros.h cm_message_send(); CM.c void cm_analog_not_converged()REFERENCED FILES Inputs from and outputs to ARGS structure. NON-STANDARD FEATURES NONE===============================================================================*//*=== INCLUDE FILES ====================*/#include <math.h> /*=== CONSTANTS ========================*/#define FRACTION 0.30#define EPSILON 1.0e-9/*=== MACROS ===========================*/ /*=== LOCAL VARIABLES & TYPEDEFS =======*/ /*=== FUNCTION PROTOTYPE DEFINITIONS ===*/ /*==============================================================================FUNCTION double limit_x_value()AUTHORS 25 Sep 1991 Jeffrey P. MurrayMODIFICATIONS 2 Oct 1991 Jeffrey P. MurraySUMMARY Limits a passed input value to some fraction of the segment length defined by (x_upper - x_lower). The fractional value in question is passed as a value to the routine (fraction). INTERFACES FILE ROUTINE CALLED CM.c void cm_analog_not_converged()RETURNED VALUE Returns a double.GLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*/#include <stdlib.h>/*=== Static LIMIT_X_VALUE ROUTINE ================*/ /** limit_x_value ******************************************//** **//** Limits a passed input value to some fraction **//** of the segment length defined by **//** (x_upper - x_lower). The fractional value in **//** question is passed as a value to the routine **//** (fraction). **//** **//** 9/25/91 JPM **//***********************************************************/static double limit_x_value(double x_lower,double x_upper, double x_input,double fraction, double *last_x_value){ double max_x_delta, /* maximum delta value permissible for this segment domain. */ hold; /* Holding variable for previous x_input value */ /** Limit effective change of input to fraction of value of lowest **/ /** x-segment length... **/ /* calculate maximum delta value for this region */ max_x_delta = fraction * (x_upper - x_lower); /* Test new input */ if ( max_x_delta < fabs(x_input - *last_x_value) ) { hold = x_input; /* Assign new x_input based of direction of movement */ /* since last iteration call */ if ( 0.0 <= (x_input - *last_x_value) ) { x_input = *last_x_value = *last_x_value + max_x_delta; } else { x_input = *last_x_value = *last_x_value - max_x_delta; } /* Alert the simulator to non-convergence */ cm_analog_not_converged(); /*** Debugging printf statement ***/ /* printf("Assigning new x_input...\nPrevious value=%e, New value=%e\n\n", hold,x_input); */ } else { /* No limiting of x_input required */ *last_x_value = x_input; } return x_input;}/*==============================================================================FUNCTION void cm_pwl(>AUTHORS 19 Apr 1991 Jeffrey P. MurrayMODIFICATIONS 25 Sep 1991 Jeffrey P. Murray 2 Oct 1991 Jeffrey P. MurraySUMMARY This function implements the pwl code model.INTERFACES FILE ROUTINE CALLED CMutil.c void cm_smooth_corner(); CMmacros.h cm_message_send(); CM.c void cm_analog_not_converged()RETURNED VALUE Returns inputs and outputs via ARGS structure.GLOBAL VARIABLES NONENON-STANDARD FEATURES NONE==============================================================================*//*=== CM_PWL ROUTINE ================*/void cm_pwl(ARGS) /* structure holding parms, inputs, outputs, etc. */{ int i; /* generic loop counter index */ int size; /* size of the x_array */ double input_domain; /* smoothing range */ double *x; /* pointer to the x-coordinate array */ double *y; /* pointer to the y-coordinate array */ double lower_seg; /* x segment below which input resides */ double upper_seg; /* x segment above which the input resides */ double lower_slope; /* slope of the lower segment */ double upper_slope; /* slope of the upper segment */ double x_input; /* input */ double out; /* output */ double dout_din; /* partial derivative of the output wrt input */ double threshold_lower; /* value below which the output begins smoothing */ double threshold_upper; /* value above which the output begins smoothing */ double test1; /* debug testing value */ double test2; /* debug testing value */ double *last_x_value; /* static variable for limiting */ double test; /* temp storage variable for limit testing */ Mif_Complex_t ac_gain; char *allocation_error="\n***ERROR***\nPWL: Allocation calloc failed!\n"; char *limit_error="\n***ERROR***\nPWL: Violation of 50% rule in breakpoints!\n"; /* Retrieve frequently used parameters... */ input_domain = PARAM(input_domain); size = PARAM_SIZE(x_array);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -