TMtxSmallInt.CopyVec Method

Overload List

#SignatureDescription
1function CopyVec(const Vec: TVecInt; NrRows: Integer): TMtxInt;Copies values from vector to a matrix.
2function CopyVec(const Vec: TVecInt; VecIndex: Integer; Len: Integer; Row: Integer; Col: Integer): TMtxInt;Copy Vec elements [VecIndex]..[VecIndex+Len-1] to the calling matrix elements starting with [Row,Col].

Overload 1: function CopyVec(const Vec: TVecInt; NrRows: Integer): TMtxInt;

Copies values from vector to a matrix.

#NameTypeDescription
1VecTVecIntsource TVecInt
2NrRowsInteger

Result: stored in self (calling object), returns self for chaining

Remarks:

Copy all Vec elements to the calling matrix. Set the calling matrix TMtxInt.Rows property to NrRows. Set the calling matrix TMtxInt.Cols property to Vec.Length div NrRow (Length = Rows*Cols). The calling matrix TMtxVecInt.IntPrecision property is adjusted automatically. An exception is raised if Vec.Length mod NrRows <> 0.

Examples
var A: TMtxInt;
    v: TVecInt;
begin
    CreateIt(A);
    Create(v);
    try
        v.SetIt([1, 0, 2, -1, 5, 1.2]) ;
        A.CopyVec(v);
    finally
        FreeIt(A);
        FreeIt(v);
    end;
end;

Overload 2: function CopyVec(const Vec: TVecInt; VecIndex: Integer; Len: Integer; Row: Integer; Col: Integer): TMtxInt;

Copy Vec elements [VecIndex]..[VecIndex+Len-1] to the calling matrix elements starting with [Row,Col].

#NameTypeDescription
1VecTVecIntsource TVecInt
2VecIndexInteger
3LenIntegerelement count
4RowInteger
5ColInteger

Result: stored in self (calling object), returns self for chaining

Remarks:

An exception is raised if TMtxVecBase.ConditionCheck is true and bounds are overrun or if TMtxVecInt.IntPrecision properties of the calling matrix and Vec do not match.