Click here to Skip to main content
15,897,519 members
Articles / Programming Languages / Visual Basic

Mathemathics Framework

Rate me:
Please Sign up or sign in to vote.
4.76/5 (56 votes)
16 Sep 2008CPOL6 min read 75.5K   6.2K   171  
.NET Mathematical Framework
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

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Universidad Tecnológica Nacional
Argentina Argentina
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions