[8703] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace AutoDiff
|
---|
| 7 | {
|
---|
| 8 | /// <summary>
|
---|
| 9 | /// A visitor for the terms that has a result from its computations
|
---|
| 10 | /// </summary>
|
---|
| 11 | /// <typeparam name="TResult">The type of the computation results</typeparam>
|
---|
| 12 | public interface ITermVisitor<TResult>
|
---|
| 13 | {
|
---|
| 14 | /// <summary>
|
---|
| 15 | /// Computes a value for a constant term.
|
---|
| 16 | /// </summary>
|
---|
| 17 | /// <param name="constant">The input term.</param>
|
---|
| 18 | /// <returns>The result of the computation.</returns>
|
---|
| 19 | TResult Visit(Constant constant);
|
---|
| 20 |
|
---|
| 21 | /// <summary>
|
---|
| 22 | /// Computes a value for a zero term.
|
---|
| 23 | /// </summary>
|
---|
| 24 | /// <param name="zero">The input term.</param>
|
---|
| 25 | /// <returns>The result of the computation.</returns>
|
---|
| 26 | TResult Visit(Zero zero);
|
---|
| 27 |
|
---|
| 28 | /// <summary>
|
---|
| 29 | /// Computes a value for a power term.
|
---|
| 30 | /// </summary>
|
---|
| 31 | /// <param name="power">The input term.</param>
|
---|
| 32 | /// <returns>The result of the computation.</returns>
|
---|
| 33 | TResult Visit(ConstPower power);
|
---|
| 34 |
|
---|
| 35 | /// <summary>
|
---|
| 36 | /// Computes a value for a power term.
|
---|
| 37 | /// </summary>
|
---|
| 38 | /// <param name="power">The input term.</param>
|
---|
| 39 | /// <returns>The result of the computation.</returns>
|
---|
| 40 | TResult Visit(TermPower power);
|
---|
| 41 |
|
---|
| 42 | /// <summary>
|
---|
| 43 | /// Computes a value for a product term.
|
---|
| 44 | /// </summary>
|
---|
| 45 | /// <param name="product">The input term.</param>
|
---|
| 46 | /// <returns>The result of the computation.</returns>
|
---|
| 47 | TResult Visit(Product product);
|
---|
| 48 |
|
---|
| 49 | /// <summary>
|
---|
| 50 | /// Computes a value for a sum term.
|
---|
| 51 | /// </summary>
|
---|
| 52 | /// <param name="sum">The input term.</param>
|
---|
| 53 | /// <returns>The result of the computation.</returns>
|
---|
| 54 | TResult Visit(Sum sum);
|
---|
| 55 |
|
---|
| 56 | /// <summary>
|
---|
| 57 | /// Computes a value for a variable term.
|
---|
| 58 | /// </summary>
|
---|
| 59 | /// <param name="variable">The input term.</param>
|
---|
| 60 | /// <returns>The result of the computation.</returns>
|
---|
| 61 | TResult Visit(Variable variable);
|
---|
| 62 |
|
---|
| 63 | /// <summary>
|
---|
| 64 | /// Computes a value for a logarithm term.
|
---|
| 65 | /// </summary>
|
---|
| 66 | /// <param name="log">The input term.</param>
|
---|
| 67 | /// <returns>The result of the computation.</returns>
|
---|
| 68 | TResult Visit(Log log);
|
---|
| 69 |
|
---|
| 70 | /// <summary>
|
---|
| 71 | /// Computes a value for an exponential function term.
|
---|
| 72 | /// </summary>
|
---|
| 73 | /// <param name="exp">The input term.</param>
|
---|
| 74 | /// <returns>The result of the computation.</returns>
|
---|
| 75 | TResult Visit(Exp exp);
|
---|
| 76 |
|
---|
| 77 | /// <summary>
|
---|
| 78 | /// Computes a value for an unary function
|
---|
| 79 | /// </summary>
|
---|
| 80 | /// <param name="func">The unary function</param>
|
---|
| 81 | /// <returns>The result of the computation</returns>
|
---|
| 82 | TResult Visit(UnaryFunc func);
|
---|
| 83 |
|
---|
| 84 | /// <summary>
|
---|
| 85 | /// Computes a value for a binary function
|
---|
| 86 | /// </summary>
|
---|
| 87 | /// <param name="func">The binary function</param>
|
---|
| 88 | /// <returns>The result of the computation</returns>
|
---|
| 89 | TResult Visit(BinaryFunc func);
|
---|
| 90 |
|
---|
| 91 | /// <summary>
|
---|
| 92 | /// Computes a value for a n-ary function
|
---|
| 93 | /// </summary>
|
---|
| 94 | /// <param name="func">The n-ary function</param>
|
---|
| 95 | /// <returns>The result of the computation</returns>
|
---|
| 96 | TResult Visit(NaryFunc func);
|
---|
| 97 | }
|
---|
| 98 | }
|
---|