Rev | Line | |
---|
[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 | /// Represents a constant-power function x^n, where n is constant.
|
---|
| 10 | /// </summary>
|
---|
| 11 | [Serializable]
|
---|
| 12 | public class ConstPower : Term
|
---|
| 13 | {
|
---|
| 14 | /// <summary>
|
---|
| 15 | /// Constructs a new instance of the <see cref="ConstPower"/> class.
|
---|
| 16 | /// </summary>
|
---|
| 17 | /// <param name="baseTerm">The base of the power function</param>
|
---|
| 18 | /// <param name="exponent">The exponent of the power function</param>
|
---|
| 19 | public ConstPower(Term baseTerm, double exponent)
|
---|
| 20 | {
|
---|
| 21 | Base = baseTerm;
|
---|
| 22 | Exponent = exponent;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | /// <summary>
|
---|
| 26 | /// Gets the base term of the power function
|
---|
| 27 | /// </summary>
|
---|
| 28 | public Term Base { get; private set; }
|
---|
| 29 |
|
---|
| 30 | /// <summary>
|
---|
| 31 | /// Gets the exponent term of the power function.
|
---|
| 32 | /// </summary>
|
---|
| 33 | public double Exponent { get; private set; }
|
---|
| 34 |
|
---|
| 35 | /// <summary>
|
---|
| 36 | /// Accepts a term visitor.
|
---|
| 37 | /// </summary>
|
---|
| 38 | /// <param name="visitor">The term visitor to accept.</param>
|
---|
| 39 | public override void Accept(ITermVisitor visitor)
|
---|
| 40 | {
|
---|
| 41 | visitor.Visit(this);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | /// <summary>
|
---|
| 45 | /// Accepts a term visitor with a generic result
|
---|
| 46 | /// </summary>
|
---|
| 47 | /// <typeparam name="TResult">The type of the result from the visitor's function</typeparam>
|
---|
| 48 | /// <param name="visitor">The visitor to accept</param>
|
---|
| 49 | /// <returns>
|
---|
| 50 | /// The result from the visitor's visit function.
|
---|
| 51 | /// </returns>
|
---|
| 52 | public override TResult Accept<TResult>(ITermVisitor<TResult> visitor)
|
---|
| 53 | {
|
---|
| 54 | return visitor.Visit(this);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.