English
Source / code snippets

3x3-Matrix invertieren with Determinantenmethode

 

p.specht

The Determinantenmethode can with small Matrizen Geschwindigkeits- and Genauigkeitsvorteile having. ex 4x4 are The usual take action (Gauß-Jordan etc) already consider.
Window Title "3x3-Matrixinversion by Division the Adjungierten through Determinante"
' (CL) Copyleft 2012-08 by P.woodpecker@gmx.at
' accuracy with usage of DoublePrecision: 12 signifikante to put. (~ 8*10^-13)
Font 2:Randomize:Cls rnd(8^8):set("decimals",12):set("numwidth",23)

proc Show : parameters M![]

    whileloop 0,n&:i&=&Loop:whileLoop 0,n&:j&=&Loop

        print M![i&,j&],:endwhile :print:endwhile

    endproc

    ' EINGABETEIL
    Var n&=3:dec n&:Declare M![n&,n&], Inv![2,2],Det!,s$,m$[],i&,j&
    print "Eingabe: Matrixelemente line by line:\n"
    '             0,0        0,1       0,2           1,0        1,1        1,2           2,0        2,1       2,2
    s$ = " 11.11,   44.44,   99.99,      22.22,  77.77,  66.66,     33.33,   88.88,  0.100000000001"
    'Testeingabe: Linear_abhängige_Zeilen:
    '             0,0        0,1       0,2           1,0        1,1        1,2           2,0        2,1       2,2
    ' s$ = " 11.11,   44.44,   99.99,      22.22,  77.77,  66.66,     22.22,  77.77,  66.66"
    ' Allfällige further Testeingaben the Anwenders:
    '             0,0        0,1       0,2           1,0        1,1        1,2           2,0        2,1       2,2
    '  s$ = "    0,   44.44,   99.99,      22.22,  77.77,  66.66,     33.33,  88.88,        0"
    ' here becomes The line by line shape into spaltenweise Datenhaltung of XProfan gewandelt:
    m$[]=explode(s$,",")

    whileloop 0,n&:i&=&Loop:whileloop 0,n&:j&=&Loop

        m![j&,i&]=val(m$[3*j&+i&]):endwhile :endwhile :clear m$[]
        Show M![]
        print "\nDeterminante = ";Det3x3(M![])
        print "\nAdjungierte[]:\n"
        Show Adjoint3x3(M![]): print
        print "\nInvertierte[]: ";
        Inv![] = Invt3x3(M![])

        if   Inv![0,0]<>-1*10^-38

            print:print
            Show Inv![] : print
            print "\nZur Probe: Invertierte rückinvertieren:\n"
            Inv![] = Invt3x3(Inv![]) : Show Inv![] : print

        else

            Print "\nEINE INVERTIERUNG IST BEI DIESEN EINGABEDATEN LEIDER NOT MÖGLICH! "

        endif

        WaitInput
        End
        ' ________________________________________

        proc Invt3x3

            parameters A![]
            declare Invt![2,2],Adju![2,2],Det!
            Det!=Det3x3(A![])

            if Det!<>0

                Adju![]=Adjoint3x3(A![])

                whileloop 0,2:i&=&Loop:whileloop 0,2:j&=&Loop

                    invt![i&,j&] = adju![i&,j&] / Det! :endwhile : endwhile

                else

                    sound 2300,300:beep
                    print " E R R O R:  DETERMINANTE = NULL!"
                    erase invt![]
                    invt![0,0]=-1*10^-38

                endif

                return Invt![]

            endproc

            proc Det3x3 :parameters A![]

                return a![0,0]*(a![1,1]*a![2,2]-a![1,2]*a![2,1]) \
                - a![0,1]*(a![1,0]*a![2,2]-a![1,2]*a![2,0]) \
                + a![0,2]*(a![1,0]*a![2,1]-a![1,1]*a![2,0])

            endproc

            proc Adjoint3x3 : parameters A![]

                Declare Adju![2,2]' = 3x3-Matrix !
                ' Beschleunigung through Variablenfassung the each
                ' twice vorkommenden Products would yet possible!
                ' row 0
                adju![0,0]=a![1,1]*a![2,2]-a![1,2]*a![2,1]
                adju![0,1]=a![0,2]*a![2,1]-a![0,1]*a![2,2]
                adju![0,2]=a![0,1]*a![1,2]-a![0,2]*a![1,1]
                ' row 1
                adju![1,0]=a![1,2]*a![2,0]-a![1,0]*a![2,2]
                adju![1,1]=a![0,0]*a![2,2]-a![0,2]*a![2,0]
                adju![1,2]=a![0,2]*a![1,0]-a![0,0]*a![1,2]
                ' row 2
                adju![2,0]=a![1,0]*a![2,1]-a![1,1]*a![2,0]
                adju![2,1]=a![0,1]*a![2,0]-a![0,0]*a![2,1]
                adju![2,2]=a![0,0]*a![1,1]-a![0,1]*a![1,0]
                return adju![]

            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

453 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