Class BinarySearch
Binary search root finding algorithm.
Inheritance
System.Object
BinarySearch
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Numerics.Statistics.Base
Assembly: Mars.Numerics.dll
Syntax
public class BinarySearch
Constructors
| Improve this Doc View SourceBinarySearch(Func<Int32, Double>, Int32, Int32)
Constructs a new Binary search algorithm.
Declaration
public BinarySearch(Func<int, double> function, int a, int b)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Int32, System.Double> | function | The function to be searched. |
System.Int32 | a | Start of search region (inclusive). |
System.Int32 | b | End of search region (exclusive). |
Properties
| Improve this Doc View SourceFunction
Gets the function to be searched.
Declaration
public Func<int, double> Function { get; }
Property Value
Type | Description |
---|---|
System.Func<System.Int32, System.Double> |
LowerBound
Gets or sets the (inclusive) lower bound for the search interval
a
.
Declaration
public int LowerBound { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Solution
Gets the solution found in the last call.
Declaration
public int Solution { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
UpperBound
Gets or sets the (exclusive) upper bound for the search interval
a
.
Declaration
public int UpperBound { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Value
Gets the value at the solution found in the last call.
Declaration
public double Value { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceFind(Double)
Finds a value of a function in the interval [a;b). The function can
be monotonically increasing or decreasing over the interface [a;b).
Declaration
public int Find(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value |
Returns
Type | Description |
---|---|
System.Int32 | The location of the zero value in the given interval. |
Find(Func<Int32, Double>, Int32, Int32, Double)
Finds a value of a function in the interval [a;b). The function can
be monotonically increasing or decreasing over the interface [a;b).
Declaration
public static int Find(Func<int, double> function, int lowerBound, int upperBound, double value)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Int32, System.Double> | function | The function to have its root computed. |
System.Int32 | lowerBound | Start of search region (inclusive). |
System.Int32 | upperBound | End of search region (exclusive). |
System.Double | value | The value to be looked for in the function. |
Returns
Type | Description |
---|---|
System.Int32 | The location of the zero value in the given interval. |