Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2) const; | Add a product of two matrices. |
| 2 | TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2, int Vec1Index, int Vec2Index, int Index, int Len) const; | Multiply Vec1 elements [Vec1Index]..[Vec1Index+Len-1] with Vec2 elements [Vec2Index]..[Vec2Index+Len-1]. |
Overload 1: TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2) const;
Add a product of two matrices.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec1 | TMtxVec * | |
| 2 | Vec2 | TMtxVec * |
Remarks:
Multiply Vec1 elements with coresponding Vec2 elements and add the result to the calling Matrix. The size of the calling Matrix is set implicitly.
Examples
#include "Math387.h"
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Matrix a;
a.SetIt(2, 2, false, DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
Matrix x;
x.SetIt(2, 2, false, DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
Matrix y;
y.SetIt(2, 2, false, DewArray<double>{ 5.0, 6.0, 7.0, 8.0 });
a.AddProduct(x, y);
Matrix expected;
expected.SetIt(2, 2, false, DewArray<double>{ 6.0, 14.0, 24.0, 36.0 });
if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
throw tException("Matrix.AddProduct: mismatch");
}
See Also: Matrix::Mul, Matrix::Add
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler
Overload 2: TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2, int Vec1Index, int Vec2Index, int Index, int Len) const;
Multiply Vec1 elements [Vec1Index]..[Vec1Index+Len-1] with Vec2 elements [Vec2Index]..[Vec2Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec1 | TMtxVec * | |
| 2 | Vec2 | TMtxVec * | |
| 3 | Vec1Index | int | |
| 4 | Vec2Index | int | |
| 5 | Index | int | |
| 6 | Len | int |
Remarks:
Ad the results to the calling object elements [Index]..[Index+Len-1]. An exception is raised if Matrix::ConditionCheck is true and array borders are overrun.
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler