TMtxVec AddProduct(TMtxVec Vec1, TMtxVec Vec2)
Add a product of two vectors.
Result: stored in self (calling object), returns self for chaining
Remarks:
Multiply Vec1 elements with coresponding Vec2 elements and add the result to the calling vector. The size of the calling vector is set implicitly.
Examples
Matrix a = new Matrix();
a.SetIt(2, 2, false, new double[] { 1.0, 2.0, 3.0, 4.0 });
Matrix x = new Matrix();
x.SetIt(2, 2, false, new double[] { 1.0, 2.0, 3.0, 4.0 });
Matrix y = new Matrix();
y.SetIt(2, 2, false, new double[] { 5.0, 6.0, 7.0, 8.0 });
a.AddProduct(x, y);
Matrix expected = new Matrix();
expected.SetIt(2, 2, false, new double[] { 6.0, 14.0, 24.0, 36.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
throw new Exception("Matrix.AddProduct: mismatch");
Indexed: TMtxVec AddProduct(TMtxVec Vec1, TMtxVec Vec2, Int32 Vec1Index, Int32 Vec2Index, Int32 Index, Int32 Len)
Multiply Vec1 elements [Vec1Index]..[Vec1Index+Len-1] with Vec2 elements [Vec2Index]..[Vec2Index+Len-1] and add the results to the calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec1 | TMtxVec | source TVec or TMtx |
| 2 | Vec2 | TMtxVec | source TVec or TMtx |
| 3 | Vec1Index | Int32 | |
| 4 | Vec2Index | Int32 | |
| 5 | Index | Int32 | start index |
| 6 | Len | Int32 | element count |
Result: stored in self (calling object), returns self for chaining
Remarks:
An exception is raised if Dew.Math.TMtxVecBase.ConditionCheck is true and array borders are overrun.