English
Source / code snippets

Komplexzahlen-Arithmetik, here on Vektorbasis

 

p.specht

Anm.: Ergänzungen desirable, z.B. root a complex number u.dgl.
Window Title "Rechnen with complex numbers (on 2D-Vektorbasis)"
'pre-Alpha Version = (CR) Crashware 2013-01 by P. woodpecker, Wien
'without jedwede Gewähr! Use on alleinige menace the Anwenders!
Font 2:Randomize:cls rnd(8^8):print
set("decimals",18)
declare a![1],b![1]'Komplex![] = real[=0]+j%*imaginär[=1]
a![]=cGET(0)
b![]=cGET(1)
print " A   = ";:cPRINT(a![],3)
print " B   = ";:cPRINT(b![],3)
'cPRINT(0,cGET(2))
waitinput
print " cADD= ";:cPRINT(cADD(a![],b![]),3)
print " cSUB= ";:cPRINT(cSUB(a![],b![]),3)
print " cMUL= ";:cPRINT(cMUL(a![],b![]),3)
print " cDIV= ";:cPRINT(cDIV(a![],b![]),3)
waitinput
End

proc cGET :parameters v%:declare xpl$[],k![1]

    ' "  1.22,-3.3   ,   4.4,2.66   , -10,5.5  ",",")
    ' "  10,10   ,   1,1   ,  -1,-1  ",",")
    ' "  10,10   ,   1,1   ,  -1,-1  ",",")
    ' "  10,10   ,   1,-1   ,  -1,-1  ",",")
    xpl$[]=explode(\
    "  10,10   ,   1.414,1.414   ,  -1,-1  ",",")
    k![0]=val(xpl$[2*v%]):k![1]=val(xpl$[2*v%+1])
    return k![]

endproc

proc cADD

    parameters a![],b![]
    declare k![1]
    'complex addition
    MAT k![]=a![]
    MAT k![]+b![]
    return k![]

endproc

proc cSUB

    parameters a![],b![]
    'complex Subtraktion
    declare k![1]
    MAT k![]=a![]
    MAT k![]-b![]
    return k![]

endproc

proc cMUL

    parameters a![],b![]
    declare m![1]
    'complex Multiplikation
    m![0]=a![0]*b![0]-a![1]*b![1]
    m![1]=a![0]*b![1]+a![1]*b![0]
    return m![]

endproc

proc cDIV

    parameters a![],b![]
    declare d![1],denominator!
    'complex Division
    denominator!=b![0]*b![0]+b![1]*b![1]

    if denominator!<>0

        d![0]=(a![0]*b![0]+a![1]*b![1])/denominator!
        d![1]=(a![1]*b![0]-a![0]*b![1])/denominator!

    else

        print " ###Division you don't say so!### ";
        d![0]=0
        d![1]=0

    endif

    return d![]

endproc

proc cKON

    parameters k![]
    'Konjugiere
    k![1]= -1*k![1]
    return k![]

endproc

proc cPRINT :parameters k![],v%

    print cFORM(k![]);
    case v%=0:print " ";
    case v%=1:print "  \ ";
    case v%=2:print " "
    case v%=3:print " \n"
    case v%=4:print " \n\n"

endproc

proc cFORM :parameters k![]:declare k$

    k$=stature$(" #######0.00000;#######0.00000;    0    ",k![0])
    k$=k$+stature$(" +j* #######0.00000; -j* #######0.00000;         ",k![1])
    return k$

endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/08/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

564 Views

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie