Das freut mich, dass die UDF doch genutzt wird.
Wenn Euch noch etwas auffällt, ihr eine mathematische Funktion vermisst oder eine Funktion nicht versteht, stehe ich gerne zur Verfügung!
Gruß der Strahleman
Das freut mich, dass die UDF doch genutzt wird.
Wenn Euch noch etwas auffällt, ihr eine mathematische Funktion vermisst oder eine Funktion nicht versteht, stehe ich gerne zur Verfügung!
Gruß der Strahleman
Hallo Bollen,
inhaltlich sieht das schon wie gewollt aus, aber mir kommt es auf das Layout an.
Etwa so wie in diesem Screenshot-Ausschnitt:
[Blockierte Grafik: http://up.picr.de/18206791af.jpg]
Der Strahleman
Hallo Autoiter,
ist es möglich in einem ListView-Control auch Zeilenüberschriften darzustellen?
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
Opt('GUIOnEventMode', 1)
[/autoit] [autoit][/autoit] [autoit]Global Const $sTitle = "ListView Test"
$Width = 429
$Height = 341
Global $hGUIMain = GUICreate($sTitle, $Width, $Height, 22, 22, 0x80C70000)
Global $lstStrct = GUICtrlCreateListView("Spalte 1|Spalte 2|Spalte 3|Spalte 4", 13, 32, $Width - 26, $Height - 82, 0, BitOr($LVS_EX_DOUBLEBUFFER, $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT))
GUISetOnEvent(-3, '_Close', $hGUIMain)
[/autoit] [autoit][/autoit] [autoit]GUICtrlSetResizing($lstStrct, 0x66)
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $hGUIMain)
[/autoit] [autoit][/autoit] [autoit]While 1
WEnd
Func _Close()
Exit
EndFunc
Gruß Strahleman
Ja, zumindest so weit wie mir das möglich war.
(Einzig bei der Sinus-Interpolation _SinInt() ist noch nicht alles abgeklopft, aber für viele Datenpaare klappt es ganz gut)
Hallo,
seit einiger Zeit habe ich meine mathematischen Funktionen für Autoit zusammengetragen. Nun wollte ich das Ganze als UDF gestalten.
Nun ist die UDF etwas umfangreicher geworden, aber ich hoffe, dass ich die gebräuchlichsten mathematischen Funktionen hiermit zur Verfügung stellen kann. (Und noch ein paar mehr)
Inhalt:
Naturwissenschaftliche Konstanten
Grundlegende Funktionen (Betrag, kgV, ggT, Log, Pow, Kettenbruch, Primzahlen, Fakultät, PFZ, Kombinatorik, u.v.m.)
Spezielle Funktionen (Gammafunktion, Betafunktion, Digammafunktion)
Komplexe Funktionen (komplexe Berechnung: Add, Sub, Mult, Div, Pow, Log, komplexe trigonometrische und hyperbolische Funktionen)
Trigonometrische Funktionen (Sin, Cos, Tan, Sec, Csc, Cot)
Trigonometrische Umkehrfunktionen (ASin, ACos, ATan, ASec, ACsc, ACot)
Hyperbolische Funktionen (Sinh, Cosh, Tanh, Sech, Csch, Coth)
Hyperbolische Umkehrfunktionen (ASinh, ACosh, ATanh, ASech, ACsch, ACoth)
Stetige Wahrscheinlichkeits-Verteilungsfunktionen (Normal-, Beta-, Gamma-, Rechteck-, X²-, t-, F-Verteilung u.v.m.)
Diskrete Wahrscheinlichkeits-Verteilungsfunktionen (Gleich-, Binomial-, Hypergeometrische -, Poisson-Verteilung u.v.m.)
Statistikfunktionen 1 (Mittelwerte, Median, Modus, Standardabweichung, Varianz, Schiefe, Wölbung, quadratische Abweichung, Häufigkeit)
Statistikfunktionen 2 (Kovarianz, Bestimmtheitsmass, Korrelation, Ausgleichsgerade)
Matrixfunktionen (Addition, Multiplikation, Transformierte, Invertierte, Adjunkte, Determinante, Eigenwerte, LGS)
Interpolationsfunktionen (Linear-, Potenz-, Logarithmus-, Exponential- und Sinus-Interpolation)
Anaylisis-Funktionen (Erstellung, Ableitung, bestimmtes Integral, Nullstellen, Extremwerte und Wendepunkte von Funktionswertepaar-Arrays)
Finanzmathematische Funktionen (Einfache Verzinsung, Zinseszinsrechnung)
Zahlensystemen-Funktionen (allgemeine Umrechnung zw. verschiedenen Zahlensystemen)
Zeichnungsfunktion (Ausgabe von Funktionswertepaar-Arrays)
Dann hoffe ich auf rege Antworten zur Verbesserung, Vereinfachung oder Einfach nur weil es Euch gefällt.
14.01.2015: Bugs beseitigt (_Factor)
Es hat mir keine Ruhe gegeben.
Ich wollte die UDF natürlich auch so einfach wie möglich gestalten, somit hier jetzt die vereinfachte Version.
Außerdem ist mir aufgefallen, dass ich auf eine andere UDF verweise bzw. auf Funktionen aus einer anderen UDF. Hab die benötigten Funktionen jetzt direkt in die Complex-UDF eingegeben.
Falls Interesse besteht stelle ich die Datei und eine Beispieldatei zum Download bereit:
Complex
autoit.de/wcf/attachment/23748/
Complex Beispiele
autoit.de/wcf/attachment/23747/
Hi BugFix,
ja danke für die Hinweise, die Änderungen werde ich auf jeden Fall aufnehmen. Vereinfachen ist immer so eine lästige Arbeit - vor allem wenn man sich freut, dass die Funktionen endlich laufen
Mal sehen wann ich Zeit hab das einzupflegen. Dann werde ich die neue UDF auch nochmal einstellen.
Gruß der Strahleman
Hallo,
also komplexe Zahlen sind in der Elektrotechnik und im Maschinenbau extrem wichtig. Und wer schon einmal probiert hat, Berechnungen für die Wechselstromtechnik zu programmieren, wird um die komplexen Zahlen gar nicht herum kommen. Mir ging es ähnlich, deshalb hab ich auch eine UDF für komplexe Zahlen entwickelt. allerdings hab ich auch structs verwendet. Aber am Ende muss jeder selber entscheiden was und wie er es nutzen möchte.
#cs
#INDEX# ==## Complex.au3 ##=======================================================================================
Title .........: complex number calculations
AutoIt Version : 3.2
Language ......: English
Description ...: Special Functions for complex number calculations.
Author(s) .....: Strahleman
Date ..........: 2013-07-02
================================================================================================================
#ce
[/autoit] [autoit][/autoit] [autoit]Global Const $pi = 3.141592653589793238462643383279 ; pi / Kreiszahl
Global Const $e = 2.718281828459045235360287471352 ; Euler's number / Eulersche Zahl
Global Const $em = 0.577215664901532860606512090082 ; Euler-Mascheroni constant / Euler-Mascheroni Konstante
Global Const $ratio = 1.618033988749894848204586834365 ; golden mean / Goldener Schnitt
Global Const $sq2pi = 2.5066282746310005024157652848110 ; Sqrt(2pi)
Global Const $Reps = __Reps() ; Number of digits of computer precision / Anzahl Stellen Rechnergenauigkeit
Global Const $meps = __Machine_Epsilon() ; computer precision / Rechnergenauigkeit
Func __Reps()
Return Round(Abs(Log(__Machine_Epsilon())/log(10)),0)
EndFunc
func __Machine_Epsilon()
Local $eps, $Res = 1.0
Do
$Res = 0.5 * $Res
$eps = 1.0 + 0.5 * $Res
Until $eps <= 1.0
Return $Res
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CmplxCheck()
; Description ...: Check of a complex number type.
; Syntax ........: _CmplxCheck($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns TRUE if $cmp is a complex number, else FALSE
; On Failure: = Sets @Error and returns FALSE.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Complex Number Check", "_CmplxCheck(_Cmplx( 3, 4 )) = " & _CmplxCheck(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _CmplxCheck($cmp)
Local $cmpSize = DllStructGetSize($cmp)
If @error Then
SetError(1)
Return False
EndIf
Local $cmpReal = DllStructGetData($cmp, "Real")
If @error Then
SetError(1)
Return False
EndIf
Local $cmpImag = DllStructGetData($cmp, "Imag")
If @error Then
SetError(1)
Return False
EndIf
If Not( $cmpSize = 16 And IsNumber($cmpReal) And IsNumber($cmpImag) ) Then
SetError(1)
Return False
EndIf
Return True
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CmplxToStr()
; Description ...: Returns the difference of two complex numbers.
; Syntax ........: _CmplxToStr($cmp [, $imagUnit])
; Parameters ....: $cmp = complex number.
; Return values .: On Success: = Returns a string of the complex number.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the imaginary part of a Complex Number", "_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )) = " & _CReal(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))) & "+" & _CImag(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))))
; ===============================================================================================================================
Func _CmplxToStr($cmp, $imagUnit="i")
If Not _CmplxCheck($cmp) Then
if IsNumber($cmp) Then
$cmp = _Cmplx($cmp)
Else
SetError(1)
return 0
EndIf
EndIf
Local $strC = ""
Select
Case DllStructGetData($cmp,"Imag") < 0
If DllStructGetData($cmp,"Imag") = -1 Then
$strC = "-" & $imagUnit
Else
$strC = "-" & String(Abs(DllStructGetData($cmp,"Imag"))) & $imagUnit
EndIf
Case DllStructGetData($cmp,"Imag") = 0
$strC = ""
Case DllStructGetData($cmp,"Imag") > 0
If DllStructGetData($cmp,"Imag") = 1 Then
$strC = "+" & $imagUnit
Else
$strC = "+" & String(Abs(DllStructGetData($cmp,"Imag"))) & $imagUnit
EndIf
EndSelect
Select
Case DllStructGetData($cmp,"Real") < 0
$strC = "-" & String(Abs(DllStructGetData($cmp,"Real"))) & $strC
Case DllStructGetData($cmp,"Real") = 0
If DllStructGetData($cmp,"Imag") = 1 Then
$strC = $imagUnit
ElseIf DllStructGetData($cmp,"Imag") = -1 Then
$strC = "-" & $imagUnit
elseif DllStructGetData($cmp,"Imag") = 0 Then
$strC = 0
Else
$strC = String(DllStructGetData($cmp,"Imag")) & $imagUnit
EndIf
Case DllStructGetData($cmp,"Real") > 0
$strC = String(Abs(DllStructGetData($cmp,"Real"))) & $strC
EndSelect
Return $strC
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _Cmplx()
; Description ...: Returns a complex number.
; Syntax ........: _Cmplx(Const $real, Const $imag )
; Parameters ....: $real = the real part of a complex number.
; $imag = the imaginary part of a complex number.
; Return values .: On Success: = Returns the complex number as a complex number type.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $real or $imag is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Create a Complex Number", "_Cmplx( 3, 4 ) = " & DllStructGetPtr(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _Cmplx($real=0, $imag=0)
If Not IsNumber($real) or Not IsNumber($imag) Then
SetError(1)
Return 0
EndIf
Local $cmp = DllStructCreate("double Real;double Imag")
DllStructSetData($cmp, "Real", $real)
DllStructSetData($cmp, "Imag", $imag)
Return $cmp
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CAbs()
; Description ...: Returns the absolute value of a complex number.
; Syntax ........: _CAbs($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns the absolute value of the complex number.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the absolute value of a Complex Number", "_CAbs(_Cmplx( 3, 4 )) = " & _CAbs(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _CAbs($cmp)
If Not _CmplxCheck($cmp) Then
SetError(1)
Return 0
EndIf
Return Sqrt(DllStructGetData($cmp, "Real")^2 + DllStructGetData($cmp, "Imag")^2)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CArg()
; Description ...: Returns the argument of a complex number.
; Syntax ........: _CArg($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns the argument of the complex number in the Intervall of I = (-PI and PI].
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; 2 = the argument is indeterminate because the real and imaginary values are 0.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the argument of a Complex Number", "_CArg(_Cmplx( 3, 4 )) = " & _CArg(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _CArg($cmp)
If Not _CmplxCheck($cmp) Then
SetError(1)
Return 0
EndIf
Local $A[2] = [DllStructGetData($cmp, "Real"), DllStructGetData($cmp, "Imag")]
Select
Case $A[0] > 0
Return ATan($A[1]/$A[0])
Case $A[0] < 0
If $A[1] >= 0 Then
Return ATan($A[1]/$A[0]) + $pi
Else
Return ATan($A[1]/$A[0]) - $pi
EndIf
Case $A[0] = 0
If $A[1] > 0 Then
Return $pi/2
ElseIf $A[1] < 0 Then
Return $pi/-2
ElseIf $A[1] = 0 Then
SetError(2)
Return 0
EndIf
EndSelect
SetError(1)
Return 0
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CReal()
; Description ...: Returns the real part of a complex number.
; Syntax ........: _CReal($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns the real part of the complex.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the real part of a Complex Number", "_CReal(_Cmplx( 3, 4 )) = " & _CReal(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _CReal($cmp)
If Not _CmplxCheck($cmp) Then
SetError(1)
Return 0
EndIf
Return DllStructGetData($cmp, "Real")
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CImag()
; Description ...: Returns the imaginary part of a complex number.
; Syntax ........: _CImag($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns the imaginary part of the complex.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the imaginary part of a Complex Number", "_CImag(_Cmplx( 3, 4 )) = " & _CImag(_Cmplx( 3, 4 )))
; ===============================================================================================================================
Func _CImag($cmp)
If Not _CmplxCheck($cmp) Then
SetError(1)
Return 0
EndIf
Return DllStructGetData($cmp, "Imag")
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCon()
; Description ...: Returns the complex conjugate of a complex number.
; Syntax ........: _CCon($cmp)
; Parameters ....: $cmp = a complex number.
; Return values .: On Success: = Returns the complex conjugate.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a complex number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the imaginary part of a Complex Number", "_CCon(_Cmplx( 3, 4 )) = " & _CmplxToStr(_CCon(_Cmplx( 3, 4 ))))
; ===============================================================================================================================
Func _CCon($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
Return _Cmplx($cmp,0)
EndIf
SetError(1)
Return 0
EndIf
Return _Cmplx(DllStructGetData($cmp, "Real"), -1 * DllStructGetData($cmp, "Imag"))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CAdd()
; Description ...: Returns the sum of two complex numbers.
; Syntax ........: _CAdd($cmp1, $cmp2)
; Parameters ....: $cmp1, $cmp2 = complex numbers.
; Return values .: On Success: = Returns the complex number of the addition.
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp1 or $cmp2 is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the imaginary part of a Complex Number", "_CAdd(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )) = " & _CAdd(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )))
; ===============================================================================================================================
Func _CAdd($cmp1, $cmp2)
If Not _CmplxCheck($cmp1) Then
If IsNumber($cmp1) Then
$cmp1 = _Cmplx($cmp1, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not _CmplxCheck($cmp2) Then
If IsNumber($cmp2) Then
$cmp2 = _Cmplx($cmp2, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $real = Round(DllStructGetData($cmp1,"Real") + DllStructGetData($cmp2,"Real") , $Reps - 1 )
Local $imag = Round(DllStructGetData($cmp1,"Imag") + DllStructGetData($cmp2,"Imag") , $Reps - 1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CSub()
; Description ...: Returns the difference of two complex numbers.
; Syntax ........: _CSub($cmp1, $cmp2)
; Parameters ....: $cmp1, $cmp2 = complex numbers.
; Return values .: On Success: = Returns the complex number of the subtraction
; On Failure: = Sets @Error and returns 0, which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp1 or $cmp2 is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the imaginary part of a Complex Number", "_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )) = " & _CReal(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))) & "+" & _CImag(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))))
; ===============================================================================================================================
Func _CSub($cmp1, $cmp2)
If Not _CmplxCheck($cmp1) Then
If IsNumber($cmp1) Then
$cmp1 = _Cmplx($cmp1, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not _CmplxCheck($cmp2) Then
If IsNumber($cmp2) Then
$cmp2 = _Cmplx($cmp2, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $real = Round(DllStructGetData($cmp1,"Real") - DllStructGetData($cmp2,"Real") , $Reps - 1 )
Local $imag = Round(DllStructGetData($cmp1,"Imag") - DllStructGetData($cmp2,"Imag") , $Reps - 1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CMul()
; Description ...: Returns the product of two complex numbers.
; Syntax ........: _CMul($cmp1, $cmp2)
; Parameters ....: $cmp = complex number.
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the product of two Complex Numbers", "_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )) = " & _CReal(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))) & "+" & _CImag(_CSub(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))))
; ===============================================================================================================================
Func _CMul($cmp1, $cmp2)
If Not _CmplxCheck($cmp1) Then
If IsNumber($cmp1) Then
$cmp1 = _Cmplx($cmp1, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not _CmplxCheck($cmp2) Then
If IsNumber($cmp2) Then
$cmp2 = _Cmplx($cmp2, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $real = Round((DllStructGetData($cmp1,"Real")*DllStructGetData($cmp2,"Real"))-(DllStructGetData($cmp1,"Imag")*DllStructGetData($cmp2, "Imag")),$Reps-1)
Local $imag = Round((DllStructGetData($cmp1,"Real")*DllStructGetData($cmp2,"Imag"))+(DllStructGetData($cmp1,"Imag")*DllStructGetData($cmp2, "Real")),$Reps-1)
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CDiv()
; Description ...: Returns the product of two complex numbers.
; Syntax ........: _CDiv($cmp1, $cmp2)
; Parameters ....: $cmp = complex number.
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; 2 = Division by zero
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......: MsgBox(0x42040, "Get the product of two Complex Numbers", "_CDiv(_Cmplx( 0, 1 ),_Cmplx( 1, 0 )) = " & _CReal(_CDiv(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))) & "+" & _CImag(_CDiv(_Cmplx( 0, 1 ),_Cmplx( 1, 0 ))))
; ===============================================================================================================================
Func _CDiv($cmp1, $cmp2)
If Not _CmplxCheck($cmp1) Then
If IsNumber($cmp1) Then
$cmp1 = _Cmplx($cmp1, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not _CmplxCheck($cmp2) Then
If IsNumber($cmp2) Then
$cmp2 = _Cmplx($cmp2, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If DllStructGetData($cmp2, "Real") = 0 and DllStructGetData($cmp2, "Imag") = 0 Then
SetError(2)
Return 0
EndIf
Local $real = Round(1/(DllStructGetData($cmp2,"Real")^2 + DllStructGetData($cmp2,"Imag")^2) * ((DllStructGetData($cmp1,"Real")*DllStructGetData($cmp2, "Real"))+(DllStructGetData($cmp1,"Imag")*DllStructGetData($cmp2, "Imag"))),$Reps-1)
Local $imag = Round(1/(DllStructGetData($cmp2,"Real")^2 + DllStructGetData($cmp2,"Imag")^2) * ((DllStructGetData($cmp2,"Real")*DllStructGetData($cmp1, "Imag"))-(DllStructGetData($cmp1,"Real")*DllStructGetData($cmp2, "Imag"))),$Reps-1)
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CPow()
; Description ...: Returns the power of a complex number to an integer exponent.
; Syntax ........: _CPow($cmp1, $n)
; Parameters ....: $cmp = complex number
; $n = integer number
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CPow($cmp, $n)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not IsNumber($n) Then
SetError(1)
Return 0
EndIf
Local $real = Round(_CAbs($cmp)^$n * Cos(_CArg($cmp) * $n),$Reps-1)
Local $imag = Round(_CAbs($cmp)^$n * Sin(_CArg($cmp) * $n),$Reps-1)
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CRoot()
; Description ...: Returns the root of a complex number to an real exponent.
; Syntax ........: _CRoot($cmp, $n)
; Parameters ....: $cmp = complex number
; $n = float number, degree of complex root
; $m = float number, count value of the complex root
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; 2 = the count value is greater than the root number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CRoot($cmp, $n, $m=0)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not IsNumber($n) or Not IsNumber($m) Then
SetError(1)
Return 0
EndIf
Local $R = _Rat($n)
If $m >= $R[0] Then
SetError(2)
Return 0
EndIf
Local $real = Round(_CAbs($cmp)^(1/$n) * Cos((_CArg($cmp)+(2*$m*$pi))/$n),$Reps-1)
Local $imag = Round(_CAbs($cmp)^(1/$n) * Sin((_CArg($cmp)+(2*$m*$pi))/$n),$Reps-1)
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CLn()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CLn($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CLn($cmp, $m=0)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If Not IsNumber($m) Then
SetError(1)
Return 0
EndIf
Local $real = Round(Log(_CAbs($cmp)),$Reps-1)
Local $imag = Round(_CArg($cmp)+(2*$m*$pi),$Reps-1)
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CSin()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CSin($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CSin($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round(Sin($x) * _Cosh($y) , $Reps-1 )
Local $imag = Round(Cos($x) * _Sinh($y) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCos()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCos($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCos($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round(Cos($x) * _Cosh($y) , $Reps-1 )
Local $imag = Round(Sin($x) * _Sinh($y) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CTan()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CTan($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CTan($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( Sin(2 * $x) / ( Cos(2 * $x) + _Cosh(2 * $y) ) , $Reps-1 )
Local $imag = Round( _Sinh(2 * $y) / ( Cos(2 * $x) + _Cosh(2 * $y) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CSec()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CSec($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CSec($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( (2 * Cos($x) * _Cosh($y) ) / ( Cos( 2 * $x ) + _Cosh( 2 * $y ) ) , $Reps-1 )
Local $imag = Round( (2 * Sin($x) * _Sinh($y) ) / ( Cos( 2 * $x ) + _Cosh( 2 * $y ) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCsc()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCsc($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCsc($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
If $y = 0 And $x = 0 Then
SetError(2)
Return 0
EndIf
Local $real = Round( (-2 * Sin($x) * _Cosh($y) ) / ( Cos( 2 * $x ) - _Cosh( 2 * $y ) ) , $Reps-1 )
Local $imag = Round( (2 * Cos($x) * _Sinh($y) ) / ( Cos( 2 * $x ) - _Cosh( 2 * $y ) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCot()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCot($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCot($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
If $y = 0 And $x = 0 Then
SetError(2)
Return 0
EndIf
Local $real = Round( -Sin(2 * $x) / ( Cos(2 * $x) - _Cosh(2 * $y) ) , $Reps-1 )
Local $imag = Round( _Sinh(2 * $y) / ( Cos(2 * $x) - _Cosh(2 * $y) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CASin()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CASin($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CASin($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round((_Sgn($x)/2) * ACos( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) - ($x^2 + $y^2) ) , $Reps-1 )
Local $imag = Round((_Sgn($y)/2) * _ACosh( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) + ($x^2 + $y^2) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACos()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACos($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACos($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( $pi/2 - ( (_Sgn($x)/2) * ACos( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) - ($x^2 + $y^2) ) ) , $Reps-1 )
Local $imag = Round((_Sgn($y)/2) * _ACosh( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) + ($x^2 + $y^2) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CATan()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CATan($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CATan($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = 0
If $x = 0 Then
If Abs($y) <= 1 Then
$real = 0
Else
$real = $pi/2 * _Sgn($y)
EndIf
Else
$real = 0.5 * ( ATan( ($x^2 + $y^2 - 1)/(2 * $x) ) + ($pi/2 * _Sgn($x)) )
EndIf
$real = Round( $real, $Reps-1 )
Local $imag = Round( 0.5 * _ATanh( (2 * $y)/($x^2 + $y^2 + 1) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CASec()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CASec($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CASec($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
$cmp = _CDiv(1, $cmp)
if @error Then
SetError(2)
Return 0
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( $pi/2 - ( (_Sgn($x)/2) * ACos( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) - ($x^2 + $y^2) ) ) , $Reps-1 )
Local $imag = Round((_Sgn($y)/2) * _ACosh( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) + ($x^2 + $y^2) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACsc()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACsc($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACsc($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
$cmp = _CDiv(1, $cmp)
if @error Then
SetError(2)
Return 0
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round((_Sgn($x)/2) * ACos( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) - ($x^2 + $y^2) ) , $Reps-1 )
Local $imag = Round((_Sgn($y)/2) * _ACosh( Sqrt( ($x^2 + $y^2 - 1)^2 + (2 * $y)^2 ) + ($x^2 + $y^2) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACot()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACot($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACot($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = 0
If $x = 0 Then
If Abs($y) <= 1 Then
$real = $pi / 2
Else
$real = $pi/2 * (1 - _Sgn($y))
EndIf
Else
$real = 0.5 * ($pi - ( ATan( ($x^2 + $y^2 - 1)/(2 * $x) ) + ($pi/2 * _Sgn($x)) ) )
EndIf
$real = Round( $real, $Reps-1 )
Local $imag = Round( 0.5 * _ATanh( (2 * $y)/($x^2 + $y^2 + 1) ) , $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CSinh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CSinh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CSinh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( Cos($y) * _Sinh($x), $Reps-1 )
Local $imag = Round( Sin($y) * _Cosh($x), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCosh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCosh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCosh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( Cos($y) * _Cosh($x), $Reps-1 )
Local $imag = Round( Sin($y) * _Sinh($x), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CTanh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CTanh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CTanh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( (_Sinh(2 * $x)) / (_Cosh(2 * $x) + Cos(2 * $y)), $Reps-1 )
Local $imag = Round( (Sin(2 * $y)) / (_Cosh(2 * $x) + Cos(2 * $y)), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CSech()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CSech($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CSech($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
Local $real = Round( (2 * _Cosh($x) * Cos($y)) / (_Cosh(2 * $x) + Cos(2 * $y)), $Reps-1 )
Local $imag = Round( (-2 * _Sinh($x) * Sin($y)) / (_Cosh(2 * $x) + Cos(2 * $y)), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCsch()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCsch($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCsch($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
If $y = 0 And $x = 0 Then
SetError(2)
Return 0
EndIf
Local $real = Round( (2 * _Sinh($x) * Cos($y)) / (_Cosh(2 * $x) - Cos(2 * $y)), $Reps-1 )
Local $imag = Round( (-2 * _Cosh($x) * Sin($y)) / (_Cosh(2 * $x) - Cos(2 * $y)), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CCoth()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CCoth($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CCoth($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Local $x = DllStructGetData($cmp, "Real")
Local $y = DllStructGetData($cmp, "Imag")
If $y = 0 And $x = 0 Then
SetError(2)
Return 0
EndIf
Local $real = Round( (_Sinh(2 * $x)) / (_Cosh(2 * $x) - Cos(2 * $y)), $Reps-1 )
Local $imag = Round( (-Sin(2 * $y)) / (_Cosh(2 * $x) - Cos(2 * $y)), $Reps-1 )
Return _Cmplx($real, $imag)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CASinh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CASinh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CASinh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Return _CLn(_CAdd($cmp, _CPow(_CAdd(_Cmplx(1,0), _CPow($cmp, 2)), 1/2)))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACosh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACosh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACosh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
Return _CLn(_CAdd($cmp, _CMul(_CPow(_CAdd($cmp, _Cmplx(1,0)), 1/2), _CPow(_CSub($cmp, _Cmplx(1,0)), 1/2))))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CATanh()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CATanh($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CATanh($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If DllStructGetData($cmp, "Real") = 1 and DllStructGetData($cmp, "Imag") = 0 Then
SetError(2)
Return 0
EndIf
Return _CMul(0.5, _CLn(_CDiv(_CAdd(_Cmplx(1, 0), $cmp), _CSub(_Cmplx(1, 0), $cmp))))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACoth()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACoth($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACoth($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If DllStructGetData($cmp, "Real") = 1 and DllStructGetData($cmp, "Imag") = 0 Then
SetError(2)
Return 0
EndIf
Return _CMul(0.5, _CLn(_CDiv(_CAdd($cmp, _Cmplx(1, 0)), _CSub($cmp, _Cmplx(1, 0)))))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CASech()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CASech($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CASech($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If DllStructGetData($cmp, "Real") = 0 and DllStructGetData($cmp, "Imag") = 0 Then
SetError(2)
Return 0
EndIf
Return _CLn(_CAdd(_CMul(_CRoot(_CSub(_CDiv(_Cmplx(1,0), $cmp), _Cmplx(1,0)), 2), _CRoot(_CAdd(_CDiv(_Cmplx(1,0), $cmp), _Cmplx(1, 0)), 2)), _CDiv(_Cmplx(1,0), $cmp)))
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: _CACsch()
; Description ...: Returns the logarithm of a complex number to an real exponent.
; Syntax ........: _CACsch($cmp, $n)
; Parameters ....: $cmp = complex number
; $m = float number, count value of the complex logarithm
; Return values .: On Success: = Returns the multiplication of complex numbers.
; On Failure: = Sets @Error and returns "", which can be a valid responce, so check @Error first.
; @ERROR: = 0 = No error.
; 1 = $cmp is not a number.
; Author ........: Strahleman
; Remarks .......: the complex number type is a two, double-floating type structure
; Example .......:
; ===============================================================================================================================
Func _CACsch($cmp)
If Not _CmplxCheck($cmp) Then
If IsNumber($cmp) Then
$cmp = _Cmplx($cmp, 0)
Else
SetError(1)
Return 0
EndIf
EndIf
If DllStructGetData($cmp, "Real") = 0 and DllStructGetData($cmp, "Imag") = 0 Then
SetError(2)
Return 0
EndIf
Return _CLn(_CAdd(_CRoot(_CAdd(_Cmplx(1,0), _CDiv(_Cmplx(1, 0), _CPow($cmp, 2))), 2), _CDiv(_Cmplx(1, 0), $cmp)))
EndFunc
PS: Die Erklärungen/Kommentare sind nicht vollständig.
Gruß der Strahleman
Hallo,
gibt's eine Möglichkeit, dass bei einem TabItem mit fester Breite der Text zentriert dargestellt wird?
Gruß der Strahleman
Hallo,
und nochmal ich.
Jetzt klappt es. Hab ein ByRef in einer Funktion vergessen.
Merkwürdigerweise funktioniert die Rückübergabe bei allen erstellten einparametrigen Type-Varianten (inkl. Double) und bei allen mehrparametrigen Type-Varianten wenn kein Double verwendet wird.
Allerdings würde ich gerne mit einem vier-parametrigen Type aus Double arbeiten.
Hiermal der Beispiel-Code.
Der Aufruf in Autoit:
$hDll = DllOpen($strdll)
$a = DllStructCreate("double;double;double;double")
$ptrA = DllStructGetPtr($a)
$arrPtrA = DllCall($hDll, "Ptr", "f_inTest", "double", 1,"double", 2,"double", 3,"double", 4, "ptr", $ptrA)
$b = DllStructCreate("double;double;double;double")
$ptrB = DllStructGetPtr($b)
$arrPtrB = DllCall($hDll, "Ptr", "f_Test", "ptr", $ptrA, "ptr", $ptrB)
DllClose($hDll)
[/autoit]
Die entsprechende DLL:
Extern "Windows-MS"
Type testtype
x1 As Double
x2 As Double
x3 As Double
x4 As Double
End Type
Function f_inTest(ByVal y1 As Double, ByVal y2 As Double, ByVal y3 As Double, ByVal y4 As Double, z As testtype) As testtype Export
z.x1 = y1 + 1
z.x2 = y2 + 1
z.x3 = y3 + 1
z.x4 = y4 + 1
Return z
End Function
Function f_Test(ByRef z1 As testtype, ByRef z2 As testtype) As testtype Export
z2.x1 = z1.x1 - 1
z2.x2 = z1.x2 - 1
z2.x3 = z1.x3 - 1
z2.x4 = z1.x4 - 1
Return z2
End Function
End Extern
Alles anzeigen
Wie gesagt, wenn ich beispielsweise vier byte-Typen verwende funktioniert diese Variante, nur eben nicht bei der Version wie oben mit den Double-Typen ?!?
Ich hoffe jemand kann mir auf die Sprünge helfen!
Das hatte ich mir schon gedacht, allerdings bekomme ich dann immer nur Null-Werte übergeben.
Naja, werde mal noch ein bischen probieren.
Danke!
Danke funkey,
habs jetzt hinbekommen, dass über ByRef die ermittelte Struktur an Autoit übergeben wird. Aber kann ich auch diese erstellten Strukturen wieder von Autoit an die DLL zur Weiterverarbeitung zurückübergeben und eine neu berechnete Struktur dann von der DLL erhalten?
Hab gleich mal eine Frage:
Wie kann man denn einen selbst definierten type in der erstellten DLL nutzen.
Dieser soll als Rückgabewert einer Funktion in Autoit nutzbar sein.
Hab da nämlich versucht die komplexen Zahlen und ihre Rechenregeln in eien DLL zu packen, allerdings komme ich mit den Rückgabewerten nicht klar?!?
der Strahleman
Super Tut!
Hab gleich den Einstieg gefunden, gerne mehr zu dem Thema. Vlt. auch mit weiteren Beispielen!
Gruß der Strahleman
ZitatAlles anzeigenSpoiler anzeigen
[autoit]Func _GetComputerName()
[/autoit]
$fkernel32 = @SystemDir & "\" & "kernel32.dll"
$function = "GetComputerName"
$MaxLength = 15
$lpBuffer = DllStructCreate("char[" & $MaxLength + 2 & "]")
$nSize = DllStructCreate("int nSize")
DllStructSetData($nSize, 1, $MaxLength)
$dll = DllOpen($fkernel32)
$return = DllCall($dll, "int", $function, "ptr", DllStructGetPtr($lpBuffer), "int_ptr", DllStructGetPtr($nSize))
DllClose($dll)
Return DllStructGetData($lpBuffer,1)
EndFunc
Hallo funkey,
das hat wieder nicht mehr funktioniert!
Na gut,
dann probiere ich mal noch ein wenig weiter - auch mit anderen Aufrufen.
Ich hoffe mal, dass es jetzt besser funktioniert.
Ansonsten, weiß ich ja wen ich fragen kann
Gruß
der Strahleman
Danke funkey, so funktioniert es.
Allerdings weiß ich noch nicht wieso? Die Parameter sind doch Pointer und müssten über einen Struct definiert werden.
[autoit]DllCall("kernel32.dll", "int", "GetComputerName", "str", "", "int*", $iLen)
[/autoit]
Der Aufruf erfolgt also direkt mit String-Parameter und einem Integer-Pointer, mmh
Immer noch Fehlanzeige.
Schade, trotzdem Danke für die Unterstützung!
Ich erhalt keine Fehlermeldungen. Allerdings ist das Ergebnis leer!
Wie kann ich das Skript nur als x86 ausführen?