Jump to content

AComplex


ValeryVal
 Share

Recommended Posts

This sample is an example of AutoItObject using. It allows to have complex Math Lib and calculate something like this:

Log[(3-4i)/(4-7i)]

The results of tests are very much appreciated.

Fixed: 20 July 2010

Added: 22 July 2010

Enjoy

:blink:

AComplex.au3

Edited by Valery

The point of world view

Link to comment
Share on other sites

CLn(): undefined function.

CDiv(): undefined function.

CPow(): undefined function.

CMul(): undefined function.

CRt(): undefined function.

OOps, are there any other UDFs I need to have?

Edited by jaberwocky6669
Link to comment
Share on other sites

CLn(): undefined function.

CDiv(): undefined function.

CPow(): undefined function.

CMul(): undefined function.

CRt(): undefined function.

Fixed. See first message.

are there any other UDFs I need to have?

New version has the following:

;===========================
; Complex Number Math Lib
;===========================
;New complex is equal to negative of $oA
Func _CMin($oA)
;New complex is equal to $oA + $oB
Func _CAdd($oA,$oB)
;New complex is equal to $oA - $oB
Func _CSub($oA,$oB)
;New complex is equal to $oA * $oB
Func _CMul($oA,$oB)
;New complex is equal to $oA / $oB
Func _CDiv($oA,$oB)
;New complex is equal to exp($oA)
Func _CExp($oA)
;New complex is equal to natural logarithm of $oA
Func _CLog($oA)
;New complex is equal to result of raising comples to the complex power
Func _CPow($oA,$oB)
;New complex is equal to complex squared
Func _CSqr($oA)
;New complex is equal to logarithmic base $oA of $oB
Func _CLogB($oA,$oB)
;New complex is equal to $oAth root of $oB
Func _CRt($oA,$oB)
;New complex is equal to square root of $oA
Func _CSqrt($oA)
;New complex is equal to sine of $oA
Func _CSin($oA)
;New complex is equal to cosine of $oA
Func _CCos($oA)
;New complex is equal to tangent of $oA
Func _CTan($oA)
;New complex is equal to tangent of $oA
Func _CCot($oA)
;New complex is equal to secant of $oA
Func _CSec($oA)
;New complex is equal to cosecant of $oA
Func _CCsc($oA)
;New complex is equal to arcsine of $oA
Func _CASin($oA)
;New complex is equal to arccosine of $oA
Func _CACos($oA)
;New complex is equal to arctangent of $oA
Func _CATan($oA)
;New complex is equal to arccotangent of $oA
Func _CACot($oA)
;New complex is equal to arcsecant of $oA
Func _CASec($oA)
;New complex is equal to arccosecant of $oA
Func _CACsc($oA)
;New complex is equal to hyperbolic sine of $oA
Func _CSinh($oA)
;New complex is equal to hyperbolic cosine of $oA
Func _CCosh($oA)
;New complex is equal to hyperbolic tangent of $oA
Func _CTanh($oA)
;New complex is equal to hyperbolic cotangent of $oA
Func _CCoth($oA)
;New complex is equal to hyperbolic secant of $oA
Func _CSech($oA)
;New complex is equal to hyperbolic cosecant of $oA
Func _CCSch($oA)

Any test is very much appreciated.

Enjoy,

:blink:

The point of world view

Link to comment
Share on other sites

Added new functions:

;New complex is equal to arcsine hyperbolic of $oA
Func _CASinh($oA)
;New complex is equal to arccosine hyperbolic of $oA
Func _CACosh($oA)
;New complex is equal to arctangent hyperbolic of $oA
Func _CATanh($oA)
;New complex is equal to arccotangent hyperbolic of $oA
;New complex is equal to arcsecant hyperbolic of $oA
Func _CASech($oA)
;New complex is equal to arcsecant hyperbolic of $oA
Func _CACsch($oA)

Now AComplex.au3 (see first message) has the following funcs:

;===========================
; Complex Number Math Lib
;===========================
;New complex is equal to negative of $oA
Func _CMin($oA)
;New complex is equal to $oA + $oB
Func _CAdd($oA,$oB)
;New complex is equal to $oA - $oB
Func _CSub($oA,$oB)
;New complex is equal to $oA * $oB
Func _CMul($oA,$oB)
;New complex is equal to $oA / $oB
Func _CDiv($oA,$oB)
;New complex is equal to exp($oA)
Func _CExp($oA)
;New complex is equal to natural logarithm of $oA
Func _CLog($oA)
;New complex is equal to result of raising comples to the complex power
Func _CPow($oA,$oB)
;New complex is equal to complex squared
Func _CSqr($oA)
;New complex is equal to logarithmic base $oA of $oB
Func _CLogB($oA,$oB)
;New complex is equal to $oAth root of $oB
Func _CRt($oA,$oB)
;New complex is equal to square root of $oA
Func _CSqrt($oA)
;New complex is equal to sine of $oA
Func _CSin($oA)
;New complex is equal to cosine of $oA
Func _CCos($oA)
;New complex is equal to tangent of $oA
Func _CTan($oA)
;New complex is equal to tangent of $oA
Func _CCot($oA)
;New complex is equal to secant of $oA
Func _CSec($oA)
;New complex is equal to cosecant of $oA
Func _CCsc($oA)
;New complex is equal to arcsine of $oA
Func _CASin($oA)
;New complex is equal to arccosine of $oA
Func _CACos($oA)
;New complex is equal to arctangent of $oA
Func _CATan($oA)
;New complex is equal to arccotangent of $oA
Func _CACot($oA)
;New complex is equal to arcsecant of $oA
Func _CASec($oA)
;New complex is equal to arccosecant of $oA
Func _CACsc($oA)
;New complex is equal to hyperbolic sine of $oA
Func _CSinh($oA)
;New complex is equal to hyperbolic cosine of $oA
Func _CCosh($oA)
;New complex is equal to hyperbolic tangent of $oA
Func _CTanh($oA)
;New complex is equal to hyperbolic cotangent of $oA
Func _CCoth($oA)
;New complex is equal to hyperbolic secant of $oA
Func _CSech($oA)
;New complex is equal to hyperbolic cosecant of $oA
Func _CCSch($oA)
;New complex is equal to arcsine hyperbolic of $oA
Func _CASinh($oA)
;New complex is equal to arccosine hyperbolic of $oA
Func _CACosh($oA)
;New complex is equal to arctangent hyperbolic of $oA
Func _CATanh($oA)
;New complex is equal to arccotangent hyperbolic of $oA
;New complex is equal to arcsecant hyperbolic of $oA
Func _CASech($oA)
;New complex is equal to arcsecant hyperbolic of $oA
Func _CACsch($oA)

Short sample for it AComplex_Example_1.au3:

;=====================================================
; AComplex - 20 July 2010 by Valery Ivanov
; The sample of AutoItObject using for Complex Number Math Lib
; 20 July 2010 by Valery Ivanov
;------------------------------
#include <AutoItObject.au3>
#include "AComplex.au3"

; Calculate value of
; Log[(3-4i)/(4-7i)]
Global $oA = _ComplexCreator(3,-4)
Global $oB = _ComplexCreator(4,-7)
Global $oC = 0

$oC = _CDiv($oA, $oB)

Global $oD = _CLog($oC)
MsgBox(0,"","Re(Log[(3-4i)/(4-7i)]) = " & $oD.Re & @CrLf & "Im(Log[(3-4i)/(4-7i)]) = " & $oD.Im)

; Calculate value of
; Log[(3-4i)*(4-7i)]
;Release object $oC returned from _CMul!
$oC = 0
$oC = _CMul($oA, $oB)

;Release object $oD returned from _CLog!
$oD = 0
$oD = _CLog($oC)
MsgBox(0,"","Re(Log[(3-4i)*(4-7i)]) = " & $oD.Re & @CrLf & "Im(Log[(3-4i)*(4-7i)]) = " & $oD.Im)


Global $oE = _ComplexCreator(6.5,4.7)
Global $oF = _ComplexCreator(4.7,-6.5)

With $oE
   MsgBox(0,"","_CAbs(6.5 + i*4.7) = " & .CAbs() & @CrLf & "_CAbsSqr(6.5 + i*4.7) = " & .CAbsSqr())
   MsgBox(0,"","_CArg(6.5 + i*4.7) = " & .CArg())
EndWith

With $oF
   MsgBox(0,"","_CAbs(4.7 - i*6.5) = " & .CAbs() & @CrLf & "_CAbsSqr(4.7 - i*6.5) = " & .CAbsSqr())
   MsgBox(0,"","_CArg(4.7 - i*6.5) = " & .CArg())
EndWith

The point of world view

Link to comment
Share on other sites

The next AQuaternion.au3 is an example of AutoItObject using for Quaternion's Math Lib.

It has the following functions:

;New quaternion is equal to opposite quaternion of $oA
Func _HOpp($oA)
;New quaternion is equal to reciprocal quaternion of $oA
Func _HRec($oA)
;New quaternion is equal to $oA + $oB
Func _HAdd($oA, $oB)
;New quaternion is equal to $oA - $oB
Func _HSub($oA, $oB)
;New quaternion is equal to $oA * $oB
Func _HMul($oA, $oB)
;New quaternion is equal to quaternion squared
Func _HSqr($oA)
;New quaternion is equal to $oA / $oB

Enjoy,

:blink:

AQuaternion.au3

The point of world view

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...