The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



CopyFromArray


Unit: SDL_matrix
Class: TMatrix, TIntMatrix
Declaration: [1] function CopyFromArray (Src: TDouble2DArray; SrcColLo, SrcRowLo, SrcColHi, SrcRowHi, Col, Row: integer): integer; { class TMatrix }
[2] function CopyFromArray (Src: TInt2DArray; SrcColLo, SrcRowLo, SrcColHi, SrcRowHi, Col, Row: integer): integer; { class TMatrix }
[3] function CopyFromArray (Src: TDouble2DArray; SrcColLo, SrcRowLo, SrcColHi, SrcRowHi, Col, Row: integer): integer; { class TIntMatrix }
[4] function CopyFromArray (Src: TInt2DArray; SrcColLo, SrcRowLo, SrcColHi, SrcRowHi, Col, Row: integer): integer; { class TIntMatrix }
[5] function CopyFromArray (Src: TDoubleArray; FirstElem, LastElem, Col, Row: integer; AsColumn: boolean): integer; { class TMatrix }
[6] function CopyFromArray (Src: TIntArray; FirstElem, LastElem, Col, Row: integer; AsColumn: boolean): integer; { class TMatrix }
[7] function CopyFromArray (Src: TDoubleArray; FirstElem, LastElem, Col, Row: integer; AsColumn: boolean): integer; { class TIntMatrix }
[8] function CopyFromArray (Src: TIntArray; FirstElem, LastElem, Col, Row: integer; AsColumn: boolean): integer; { class TIntMatrix }

The method CopyFromArray copies the cells of the dynamic array Src into the matrix. The parameters Col and Row specify the first column and row to be used in the matrix (the cell Src[FirstElem] (or Src[SrcColLo,SrcColHi]) is copied to self[Col,Row], all other cells are copied to higher indices, see figures below).

The versions [5] to [8] allow copying a one-dimensional array. In this case the parameter AsColumn controls whether the source array is copied into a column (AsColumn = TRUE) or into a row (AsColumn = FALSE) of the matrix.

If the source array does not fit into the matrix all excess cells are ignored.

The method return the following error codes:

 0 ... everything is OK
-1 ... the source array Src has zero size
-2 ... SrcColLo and/or SrcColHi are out of range (valid range: 0 to length(Src)-1)
-3 ... SrcRowLo and/or SrcRowHi are out of range (valid range: 0 to length(Src[0])-1)
-4 ... FirstElem and/or LastElem are out of range (valid range: 0 to length(Src)-1)
-5 ... Col and/or Row are out of range (valid ranges: 1 ≤ ColNrOfColumns, and 1 ≤ RowNrOfRows)

Hint: Setting both the ...Lo and ...Hi parameters, or both the FirstElem and LastElem parameters to zero is a shortcut for specifying the entire range of cells in the particular dimension. For example, CopyFromArray (mat1,0,4,0,6,1,1); copies the entire rows 4 to 6 of the Src array to the matrix at position [1,1] (because both the SrcColLo and the SrcColHi parameters are zero).



Last Update: 2023-Feb-06