TMtx::AddProduct Method

Overload List

#SignatureDescription
1TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2);Add a product of two vectors.
2TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2, int Vec1Index, int Vec2Index, int Index, int 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].

Overload 1: TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2);

Add a product of two vectors.

#NameTypeDescription
1Vec1TMtxVec *
2Vec2TMtxVec *
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
#include "Math387.h"
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;
    a.SetIt(DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
    Vector x;
    x.SetIt(DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
    Vector y;
    y.SetIt(DewArray<double>{ 5.0, 6.0, 7.0, 8.0 });
    a.AddProduct(x, y);
    Vector expected;
    expected.SetIt(DewArray<double>{ 6.0, 14.0, 24.0, 36.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.AddProduct: mismatch");
}
See Also: TMtx::Mul, TMtx::Add
Declared in Dew::Math::TDenseMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 2: TMtxVec *AddProduct(TMtxVec *Vec1, TMtxVec *Vec2, int Vec1Index, int Vec2Index, int Index, int 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].

#NameTypeDescription
1Vec1TMtxVec *
2Vec2TMtxVec *
3Vec1Indexint
4Vec2Indexint
5Indexint
6Lenint
Remarks:

An exception is raised if TMtx::ConditionCheck is true and array borders are overrun.

Declared in Dew::Math::TDenseMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler