Imports BV.Math
Imports BV.Core
Imports BV.TopLevel.Parsing
Imports System.Collections.Generic
<CLSCompliant(True)> _
Public Class SingularityFinder
Protected intFunction As FunctionBase
Protected intArea As Areaf
Protected intDivisions As Integer
Protected intPlane(,) As ComplexUndefinied
Public Sub New()
ReDim Me.intPlane(Me.intDivisions, Me.intDivisions)
Me.intArea = New Areaf(-100, 100, -100, 100)
End Sub
Public Overridable Property Area() As Areaf
Get
Return Me.intArea
End Get
Set(ByVal value As Areaf)
Me.intArea = value
End Set
End Property
Public Overridable Property [Function]() As FunctionBase
Get
Return intFunction
End Get
Set(ByVal value As FunctionBase)
intFunction = value
End Set
End Property
Public Property Divisions() As Integer
Get
Return Me.intDivisions
End Get
Set(ByVal value As Integer)
If value >= 10 Then
Me.intDivisions = value
End If
End Set
End Property
Public Sub DetermiteSingulatities()
Dim i, j As Integer
Dim x, y As Double
Dim min, max, prom As Double
min = Single.MinValue
max = Single.MaxValue
'calculo el logaritmo de la funcion en el area de trabajo
For i = 0 To Me.intDivisions
x = Me.intArea.XMin + i * Me.intArea.XRange.dx / Me.intDivisions
For j = 0 To Me.intDivisions
y = Me.intArea.YMin + j * Me.intArea.YRange.dx / Me.intDivisions
Me.intPlane(i, j) = Me.intFunction.Calc(New ComplexUndefinied(x, y))
Try
Me.intPlane(i, j) = BVMathFunctions.Ln(Me.intPlane(i, j))
If Me.intPlane(i, j).Module > max Then
max = Me.intPlane(i, j).Module
End If
If Me.intPlane(i, j).Module < min Then
min = Me.intPlane(i, j).Module
End If
prom += Me.intPlane(i, j).Module
Catch ex As Exception
End Try
Next
Next
prom /= (Me.intDivisions ^ 2)
'determino que puntos del plano son maximos y m�nimos
Dim TH, TL As Double
Dim HTbl As New Dictionary(Of Integer, Integer)
Dim LTbl As New Dictionary(Of Integer, Integer)
TH = min + 0.7 * (max - min)
TL = min + 0.3 * (max - min)
For i = 0 To Me.intDivisions
For j = 0 To Me.intDivisions
If Me.intPlane(i, j).Module >= TH Then
HTbl.Add(i, j)
End If
If Me.intPlane(i, j).Module <= TL Then
LTbl.Add(i, j)
End If
Next
Next
End Sub
End Class