yanera->models_complete
are formed.The file also contains the required evaluation functions, when it comes time to evaluate the expression to calculate the SLD profile.
There are two local variables that are file in scope; evaluation_stack
and operator_stack
, two linked-list stacks.
operator_stack
is only used to convert to the postfix expression. It should be empty after the conversion.
evaluation_stack
is only used in evaluation of the postfix expression. It also should be empty when evalutation is complete.
Definition in file yanera_postfix.c.
Go to the source code of this file.
Functions | |
short | parmindex (char c, char *parm_name) |
From the string of parameter names, find the character. | |
void | parse_expression (yanera_postfix *pq, char *expression, char *parm_name, short *parm) |
Parse the prefix expression into a postfix expression. | |
void | parameter_decision (yanera_postfix *pq, const char c[4], short indx) |
Check for recurrence of same variable. | |
void | append_number_string (char c) |
Append a numeric character to the number_string . | |
void | stop_number_string (yanera_postfix *pq) |
Take the number_string and push onto yanera_postfix . | |
yanera_postfix * | initizlize_postfix_queue (void) |
Initialize the yanera_postfix . | |
void | enqueue_postfix_queue (yanera_postfix *pq, const char *c, double d, short indx, short type) |
Initialize the yanera_postfix . | |
void | print_postfix (yanera_postfix *pq, double x, double *params) |
Print the yanera_postfix for examination. | |
double | evaluate_postfix (yanera_postfix *pq, double z, double *params) |
Evaluate the yanera_postfix . | |
void | free_postfix_queue (yanera_postfix *pq) |
Free the yanera_postfix . | |
void | initizlize_operator_stack (void) |
Initalize the operator_stack . | |
struct operator_stack_element * | operator_stack_element_new (const char *oper, short prec, short type) |
Load data into an operator_stack_element . | |
void | push_operator_stack (struct operator_stack_element *o) |
Push an operator_stack_element onto the operator_stack . | |
struct operator_stack_element * | pop_operator_stack (void) |
Pop the top operator_stack_element from the operator_stack . | |
short | operator_stack_is_empty (void) |
Returns whether the operator_stack is empty. | |
short | operator_stack_top_precedence (void) |
Returns the precendence of the top operator_stack_element . | |
void | operator_decision (yanera_postfix *pq, const char oper[4], short prec, short type) |
The heart of the prefix to postfix conversion algorithm. | |
void | initizlize_evaluation_stack (void) |
Initalize the evaluation_stack . | |
void | push_evaluation_stack (double d) |
Push a number onto the evaluation_stack. | |
double | pop_evaluation_stack (void) |
Pop a number from the evaluation_stack. |
short parmindex | ( | char | c, | |
char * | parm_name | |||
) |
c | The character to match. | |
parm_name | The string of parameter names. |
Definition at line 39 of file yanera_postfix.c.
void parse_expression | ( | yanera_postfix * | pq, | |
char * | expression, | |||
char * | parm_name, | |||
short * | parm | |||
) |
pq | The yanera_postfix which will hold the expression | |
expression | The prefix expression as a character string | |
parm_name | A character array containing only one leter | |
parm | The index array for the parameters |
expression
into a postfix expression.
The parm_name
and parm
arrays together form a look-up table. Every variable name appears once in the parm_name
array. The parm
array conatins the index for the paramter array that carries the actual values of that variable.
Example:
parm_name = "acbd"
parm = {4,0,2,1}
parmamter = {1.2, 3.5, 5.4, 0.2, 10.2}
a = parameter[4] = 10.2 d = parameter[1] = 3.5
Definition at line 76 of file yanera_postfix.c.
void parameter_decision | ( | yanera_postfix * | pq, | |
const char | c[4], | |||
short | indx | |||
) |
We need to determine whether a variable has already been added to the yanera_postfix
. If it has, then add it again, but using the same index as before. This allows varaibles (a,b,c,etc.) to appear more than once in the expression.
Definition at line 615 of file yanera_postfix.c.
void append_number_string | ( | char | c | ) |
Append a numeric character to the number_string
Definition at line 644 of file yanera_postfix.c.
void stop_number_string | ( | yanera_postfix * | pq | ) |
Take the number_string
and push onto yanera_postfix
. Free the string memory.
Definition at line 669 of file yanera_postfix.c.
yanera_postfix* initizlize_postfix_queue | ( | void | ) |
Initialize the yanera_postfix
.
Definition at line 684 of file yanera_postfix.c.
void enqueue_postfix_queue | ( | yanera_postfix * | pq, | |
const char * | c, | |||
double | d, | |||
short | indx, | |||
short | type | |||
) |
pq | The yanera_postfix with the postfix expression | |
c | A size 4 character string of the operator or variable | |
d | A double number. | |
indx | For variables, the paramter array index. | |
type | The type of element store See below. |
yanera_postfix
.The queue contains either a number, symbolic operators (+,-,*,/,^), word operators (cos,sin,tan,exp,log,abs), varaibles (a,b,c,etc.) or the ordinate value (z).
Definition at line 711 of file yanera_postfix.c.
void print_postfix | ( | yanera_postfix * | pq, | |
double | x, | |||
double * | params | |||
) |
pq | The yanera_postfix with the postfix expression | |
x | The ordinate | |
params | A parameter array. |
yanera_postfix
, however it mearly prints to stderr
the contents of the queue, to see if the prefix expression was evaluated properly.
Definition at line 756 of file yanera_postfix.c.
double evaluate_postfix | ( | yanera_postfix * | pq, | |
double | z, | |||
double * | params | |||
) |
pq | The yanera_postfix with the postfix expression | |
z | The ordinate | |
params | A parameter array. |
z
and with variables in the params
array. When the ordinate is encountered, substitute the value z
.
Definition at line 800 of file yanera_postfix.c.
void free_postfix_queue | ( | yanera_postfix * | pq | ) |
FILL IN
Definition at line 871 of file yanera_postfix.c.
void initizlize_operator_stack | ( | void | ) |
Initalize the operator_stack
. The stack will be empty at the end and not need to be freed.
Definition at line 897 of file yanera_postfix.c.
struct operator_stack_element* operator_stack_element_new | ( | const char * | oper, | |
short | prec, | |||
short | type | |||
) | [read] |
Allocate a new operator_stack_element
, and fill with data.
Definition at line 908 of file yanera_postfix.c.
void push_operator_stack | ( | struct operator_stack_element * | o | ) |
Push an operator_stack_element
onto teh operator_stack
.
Definition at line 925 of file yanera_postfix.c.
struct operator_stack_element* pop_operator_stack | ( | void | ) | [read] |
Pop the top operator_stack_element
from the operator_stack
. Creates a copy of the operator_stack_element
which MUST BE FREE
Definition at line 938 of file yanera_postfix.c.
short operator_stack_is_empty | ( | void | ) |
Returns whether the operator_stack
is empty.
Definition at line 965 of file yanera_postfix.c.
short operator_stack_top_precedence | ( | void | ) |
Returns the precendence of the top operator_stack_element
. Returns 0 is stack is empty.
Definition at line 976 of file yanera_postfix.c.
void operator_decision | ( | yanera_postfix * | pq, | |
const char | oper[4], | |||
short | prec, | |||
short | type | |||
) |
The heart of the prefix to postfix conversion algorithm.
Definition at line 988 of file yanera_postfix.c.
void initizlize_evaluation_stack | ( | void | ) |
Initalize the evaluation_stack
. The stack will be empty at the end and not need to be freed.
Definition at line 1021 of file yanera_postfix.c.
void push_evaluation_stack | ( | double | d | ) |
Push a number onto the evaluation_stack
Definition at line 1032 of file yanera_postfix.c.
double pop_evaluation_stack | ( | void | ) |
Pop a number from the evaluation_stack.
Definition at line 1048 of file yanera_postfix.c.