Autor Beitrag
paul_swatschina
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Fr 04.04.08 19:07 
hallo leute,

folgendes problem:
ich scheibe ein komplexes mathematik programm um würde EVENTUEL eine procedure brauchen, die ich aus dem internet downgeloaded habe. das problem ist, dass meine typen die ich in diese procedure reinladen will nicht genau den typen entsprechen, die dafür vorgesehen sind...
die frage lautet also: wie wandle ich das um???
ich verstehe nämlich den code null und nüsse, da ich kein programmier-chef bin.

und zwar mein typ heisst
pauls_matrix = array of array;

die dimensionen werden zur laufzeit festgesetzt.

es folgt der code dieser downgeloadeten unit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Vector     = ARRAY[1..4of EXTENDED;
        Array16    = ARRAY[1..16of EXTENDED;
        Array15by2 = ARRAY[1..15,1..2of EXTENDED;
        Str250     = STRING[250];
        Str64      = STRING[64];

        Intarray   = ARRAY[1..6of INTEGER;

        MatrixDataPtr = ^MatrixData;
        MatrixData    = RECORD
                          Index     : INTEGER;
                          Number    : EXTENDED;
                          Next,Last : MatrixDataPtr;
                        END;
        MatrixPtr     = RECORD
                          NumRows,NumCols : INTEGER;
                          DPtr            : MatrixDataPtr;
                          Head,Tail       : MatrixDataPtr;
                        END;
        Matrix        = ^MatrixPtr;


der letzte typ "Matrix" soll aus meiner obengenannten "pauls_matrix" entstehen.
dazu gibt es scheinbar auch eigene proceduren in der unit:

funktioniert das? was geht hier eigentlich ab? ich verstehe die pointer an sich nicht...

ich weiss ich könnts ausprobieren, weiss aber nicht ob es prinzipiell lohnt...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
{ ------------------------------------------------------------------------------
|
|                           PROCEDURE ASSIGNVAL
|
|  This PROCEDURE assigns a value to the record structure.  This is
|    necessary to decode the data.  It's set up to resemble the standard
|    array format, however, ['s are replaced by ('s.
|
|  Algorithm     : Call GETVAL to get the pointer at the correct index location
|                  Assign the value to the pointer variable record field
|
|  Author        : David Vallado                  719-573-2600    1 Mar 2001
|
|  Inputs          Description                    Range / Units
|    A           - Matrix
|    Row         - Row number of desired element
|    Col         - Col number of desired element
|    Number      - Value to assign at the desired location
|
|  OutPuts       :
|    A           - Matrix
|
|  Locals        :
|    Temp        -
|
|  Coupling      :

|    GETVAL      - Gets a value from the matrix
|
 ----------------------------------------------------------------------------- }


PROCEDURE ASSIGNVAL          ( VAR A                                 : Matrix;
                               Row,Col                               : INTEGER;
                               Number                                : EXTENDED );
   VAR
     Temp : EXTENDED;
   BEGIN
     Temp:= GETVAL( A,Row,Col );
     A^.DPtr^.Number:= Number;
   END;  { PROCEDURE ASSIGNVAL }

{ ------------------------------------------------------------------------------
|
|                           FUNCTION GETVAL
|
|  This FUNCTION gets a value from the record structure.  The FUNCTION is
|    necessary to decode the data.  It's set up to resemble the standard
|    array format, however, ['s are replaced by ('s.
|
|  Algorithm     : Find the index where you desire to get data
|                  Loop forward or backward to the desired index
|                  Assign the value
|
|  Author        : David Vallado                  719-573-2600    1 Mar 2001
|
|  Inputs          Description                    Range / Units
|    A           - Matrix
|    Rows        - Row number of desired element
|    Cols        - Col number of desired element
|
|  OutPuts       :
|    GetXVal     - Value of the Row,Col point
|
|  Locals        :
|    i           - Index
|    j           - index
|
|  Coupling      :
|    None.
|
 ----------------------------------------------------------------------------- }


FUNCTION GETVAL              ( VAR A                                 : Matrix;
                               Row,Col                               : INTEGER ) : EXTENDED;
   VAR
     i,j : INTEGER;
   BEGIN
     j:= (Row-1)*A^.NumCols + Col;

     WHILE ( j > A^.DPtr^.Index ) and ( A^.DPtr^.Next <> NIL ) DO
         A^.DPtr:= A^.DPtr^.Next;

     WHILE ( j < A^.DPtr^.Index ) and ( A^.DPtr^.Last <> NIL ) DO
         A^.DPtr:= A^.DPtr^.Last;

     GETVAL:= A^.DPtr^.Number;

   END;  { FUNCTION GETVAL}


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 04.04.08 20:24 
Zitat:
ich weiss ich könnts ausprobieren, weiss aber nicht ob es prinzipiell lohnt...

Und andere sollen nun für dich dich die Arbeit übernehmem !

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
paul_swatschina Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Sa 05.04.08 00:07 
jajaja...

ich kann ja nicht einmal meine array of array dieser komischen form übergeben...
das würd ich gern wissen, wie man das macht!

und wenn mir dann jemand aus erfahrung noch sagen könnte ob sich so ein pointer-zeugs rentiert, wäre es auch nicht schlecht zu wissen.

paul
busybyte
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 40



BeitragVerfasst: Sa 05.04.08 01:23 
Kommt darauf an,was Du damit machen willst,es ist eine supperschnelle Routine dank Pointer,
aber nicht ohne weiteres für offene Arrays, wie Du sie verwenden willst umzubauen.
Deswegen würde ich Dir empfehlen dich mal mit Pointern zu beschäftigen,aber nicht für Deine Arrays.
Bin aber auch nicht der MegaDelphin.