C# 클래스 Accord.PolishExpression

Evaluator of expressions written in reverse polish notation.

The class evaluates expressions writen in reverse postfix polish notation.

The list of supported functuins is:

Arithmetic functions: +, -, *, /; sin - sine; cos - cosine; ln - natural logarithm; exp - exponent; sqrt - square root.

Arguments for these functions could be as usual constants, written as numbers, as variables, writen as $<var_number> ($2, for example). The variable number is zero based index of variables array.

Sample usage:

// expression written in polish notation string expression = "2 $0 / 3 $1 * +"; // variables for the expression double[] vars = new double[] { 3, 4 }; // expression evaluation double result = PolishExpression.Evaluate( expression, vars );
파일 보기 프로젝트 열기: accord-net/framework

공개 메소드들

메소드 설명
Evaluate ( string expression, double variables ) : double

Evaluates specified expression.

메소드 상세

Evaluate() 공개 정적인 메소드

Evaluates specified expression.
Unsupported function is used in the expression. Incorrect postfix polish expression.
public static Evaluate ( string expression, double variables ) : double
expression string Expression written in postfix polish notation.
variables double Variables for the expression.
리턴 double