Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
49 views1 page

Complete-Reference-Vb Net 3

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

Complete-Reference-Vb Net 3

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Structures

'floats for real and imaginary parts of complex numbers


'or use both for simple float math
Public real, unreal As Double
Public Sub New(ByVal re As Double, ByVal unre As Double)
real = re
unreal = unre
End Sub

Public ReadOnly Property BasicProduct()


Get
BasicProduct = real * unreal
End Get
End Property

Public ReadOnly Property BasicDivide()


Get
BasicDivide = real / unreal
End Get
End Property

Public ReadOnly Property Reciprocal() As Complex


Get
If real = 0.0 And unreal = 0.0 Then
Throw New DivideByZeroException()
End If
Dim div As Double = real * real + unreal * unreal
Return New Complex(real / div, −unreal / div)
End Get
End Property

Public Shared Function ComplexToDouble(ByVal aReal As Complex) _


As Double
Return aReal.real
End Function

Public Shared Function RealToComplex(ByVal dble As Double) _


As Complex
Return New Complex(dble, 0.0)
End Function

Public Shared Function ToPositive(ByVal aReal As Complex) _


As Complex
Return aReal
End Function

Public Shared Function ComplexToNegative(ByVal areal As Complex) _


As Complex
Return New Complex(−areal.real, −areal.unreal)
End Function

Public Shared Function AddComplex(ByVal areal As Complex, _


ByVal breal As Complex) As Complex
Return New Complex(areal.real + breal.real, areal.unreal + _
breal.unreal)
End Function

Public Shared Function SubtractComplex(ByVal areal As Complex, _


ByVal breal As Complex) As Complex
Return New Complex(areal.real − breal.real, areal.unreal − _
breal.unreal)
End Function

241

You might also like