AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Übergabe einer Matrix an Unterprogramm

Ein Thema von swarley · begonnen am 23. Aug 2011 · letzter Beitrag vom 25. Aug 2011
 
swarley

Registriert seit: 17. Aug 2011
6 Beiträge
 
#4

AW: Übergabe einer Matrix an Unterprogramm

  Alt 24. Aug 2011, 17:45
so ich habe meinen algorithmus jetzt optimiert. und mein unterprogramm enthält folgenden Quelltext:
Delphi-Quellcode:
procedure Inverse(a,zeilen,spaltengauss:Integer;var matgauss:TMatrixgauss);
var i,j,k : Integer;
begin
  if a < zeilen-1 then
  begin
      for i := a to spaltengauss - 1 do
       begin
         matgauss[a,i]:=matgauss[a,i]/matgauss[a,a];
       end;
      for j := a+1 to zeilen - 1 do
        begin
          for k := a to spaltengauss - 1 do
            begin
              matgauss[j,k]:=matgauss[j,k]-matgauss[j,a]*matgauss[a,k];
            end;
        end;
    Inverse(a+1,zeilen,spaltengauss,matgauss);

    for j := a-1 downto 0 do
    matgauss[j,a]:=matgauss[j,a]-matgauss[j,a]*matgauss[a,a];
  end;
  for i := zeilen-1 to spaltengauss-1 do
    begin
       matgauss[zeilen-1,i]:=matgauss[zeilen-1,i]/matgauss[zeilen-1,zeilen-1];
        for j := a-1 downto 0 do
         matgauss[j,a]:=matgauss[j,a]-matgauss[j,a]*matgauss[a,a];
    end;
end;
mit der typdeklaration:
TMatrixgauss = array[0..5,0..10]of Double; in meiner ButtonInverse.onClick procedure erstelle ich die matrix matgauss, die vor der übergabe, wie folgt aussieht:
|8 4 5 1 0 0|
|4 7 3 0 1 0| =: matgauss
|7 3 2 0 0 1|

Ich habe mehrmals überprüft, dass auch wirklich diese matrix in "matgauss" steckt, daher verstehe ich nicht wieso ich nach meinem prozeduraufruf Inverse(0,zeilen,spaltengauss,matgauss); , wenn ich eine 3 x 3 matrix eingebe, in meinem Stringgrid folgendes Ergebnis erhalte(zeilen hat den wert 3, spaltengauss 6)
|1 0 0 1 0 0|
|0 1 0 0 1 0|
|0 0 1 0 0 1|


anstatt:
|1 0 0 -0.05 -0.08 0.25|
|0 1 0 -0.14 0.20 0.04|
|0 0 1 0.40 -0.04 -0.43|

(gut das ist wegen den gebrochenen Zahlen jetzt ein doofes Beispiel, aber darum geht es ja nicht)
Kann mir jemand erklären, wieso mein algorithmus im "vorderen Teil" der Matrix arbeitet und im "hinteren" nicht?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz