📄 constantcurve.vb
字号:
' The Constant class resides in the Extreme.Mathematics.Curves namespace.
Imports Extreme.Mathematics.Curves
Namespace Extreme.Mathematics.QuickStart.VB
' Illustrates the use of the DoubleComplex class in the
' Extreme Optimization Mathematics Library for .NET.
Module ConstantCurve
Sub Main()
' All curves inherit from the Curve abstract base
' class. It cannot be instantiated. This class
' defines methods and properties that are available
' to all derived types, including Constant, Line,
' Quadratic, Polynomial, ChebyshevSeries and
' LinearFunction.
'
' This QuickStart sample illustrates the Constant
' class.
'
' Creating Constant curves.
'
' Let's start by creating a Constant curve and some
' Line curves.
' A Constant curve has the same value everywhere.
Dim constant1 As Constant = New Constant(3)
' There is one predefined Constant curve, which is
' zero everywhere:
Dim constant2 As Constant = Constant.Zero
'
' Curve Parameters
'
' The shape of any curve is determined by a set of parameters.
' These parameters can be retrieved and set through the
' Parameters collection. The number of parameters for a curve
' is given by this collection's Count property.
'
' Constants have one parameter: the y value.
Console.WriteLine("constant1.ParameterCount = {0}", _
constant1.Parameters.Count)
' Parameters can easily be retrieved:
Console.WriteLine("constant1.Parameters(0) = {0}", _
constant1.Parameters(0))
' Parameters can also be set:
constant1.Parameters(0) = 3
'
' Curve Methods
'
' The ValueAt method returns the y value of the
' curve at the specified x value:
Console.WriteLine("constant1.ValueAt(2) = {0}", _
constant1.ValueAt(2))
' The SlopeAt method returns the slope of the curve
' a the specified x value:
Console.WriteLine("constant1.SlopeAt(2) = {0}", _
constant1.SlopeAt(2))
' You can also create a new curve that is the
' derivative of the original:
Dim derivative As Curve = constant1.GetDerivative()
Console.WriteLine("Slope at 2 (derivative) = {0}", _
derivative.ValueAt(2))
' You can get a Line that is the tangent to a curve
' at a specified x value using the TangentAt method:
Dim tangent As Line = constant1.TangentAt(2)
Console.WriteLine("Slope of tangent line at 2 = {0}", _
tangent.Slope)
' For many curves, you can evaluate a definite
' integral exactly:
Console.WriteLine("Integral between 0 and 1 = {0}", _
constant1.Integral(0, 1))
' You can find the zeroes or roots of the curve
' by calling the FindRoots method:
Dim roots As Double() = constant1.FindRoots()
Console.WriteLine("constant1 curve has {0} roots.", _
roots.Length)
Console.Write("Press Enter key to exit...")
Console.ReadLine()
End Sub
End Module
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -