Vector::AddScaledSqr Method

Overload List

#SignatureDescription
1TMtxVec *AddScaledSqr(TMtxVec *X, TMtxVec *Y, const double yScale) const;Compute sqr(X + Y*yScale)
2TMtxVec *AddScaledSqr(TMtxVec *X, TMtxVec *Y, const TCplx &yScale) const;Compute sqr(X + Y*yScale)
3TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const double yScale, int Index, int Len) const;Compute sqr(X + Y*yScale) on sub arrays
4TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const TCplx &yScale, int Index, int Len) const;Compute sqr(X + Y*yScale) on sub arrays
5TMtxVec *AddScaledSqr(TMtxVec *X, const double xScale, TMtxVec *Y, const double yScale) const;Compute sqr(X*xScale + Y*yScale)
6TMtxVec *AddScaledSqr(TMtxVec *X, const TCplx &xScale, TMtxVec *Y, const TCplx &yScale) const;Compute sqr(X*xScale + Y*yScale)
7TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, const double xScale, TMtxVec *Y, int YIndex, const double yScale, int Index, int Len) const;Compute sqr(X*xScale + Y*yScale) on sub arrays
8TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, const TCplx &xScale, TMtxVec *Y, int YIndex, const TCplx &yScale, int Index, int Len) const;Compute sqr(X*xScale + Y*yScale) on sub arrays

Overload 1: TMtxVec *AddScaledSqr(TMtxVec *X, TMtxVec *Y, const double yScale) const;

Compute sqr(X + Y*yScale)

#NameTypeDescription
1XTMtxVec *
2YTMtxVec *
3yScaleconst double
Remarks:

By making use of yScale, it is also possible to compute the following (at the same or higher speed):

(X - Y)^2 = X^2 - 2XY +Y^2

Examples
#include "MtxExpr.h"
#include "Units.Math387.h"
#include "Units.MtxExpr.h"
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    Vector X, Y, A1, A2, A3;
    double xScale, yScale;

    xScale = 1.5;
    yScale = -1.5;
    X = {1, 2, 3, 4};
    Y = {2, 3, 4, 5};
    A1 = Sqr(X * xScale + Y * yScale);
    A2 = AddScaledSqr(X, xScale, Y, yScale);
    A3.AddScaledSqr(X, xScale, Y, yScale);

    if (!A2.IsEqual(A1))
        ERaise("Problem");
    if (!A3.IsEqual(A1))
        ERaise("Problem");
}
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 2: TMtxVec *AddScaledSqr(TMtxVec *X, TMtxVec *Y, const TCplx &yScale) const;

Compute sqr(X + Y*yScale)

#NameTypeDescription
1XTMtxVec *
2YTMtxVec *
3yScaleconst TCplx &
Examples
#include "MtxExpr.h"
#include "Units.Math387.h"
#include "Units.MtxExpr.h"
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    Vector X, Y, A1, A2, A3;
    double yScale;

    yScale = 1.5;
    X = {1, 2, 3, 4};
    Y = {2, 3, 4, 5};
    A1 = Sqr(X + Y * yScale);
    A2 = AddScaledSqr(X, Y, yScale);
    A3.AddScaledSqr(X, Y, yScale);

    if (!A2.IsEqual(A1))
        ERaise("Problem");
    if (!A3.IsEqual(A1))
        ERaise("Problem");
}
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 3: TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const double yScale, int Index, int Len) const;

Compute sqr(X + Y*yScale) on sub arrays

#NameTypeDescription
1XTMtxVec *
2XIndexint
3YTMtxVec *
4YIndexint
5yScaleconst double
6Indexint
7Lenint
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 4: TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const TCplx &yScale, int Index, int Len) const;

Compute sqr(X + Y*yScale) on sub arrays

#NameTypeDescription
1XTMtxVec *
2XIndexint
3YTMtxVec *
4YIndexint
5yScaleconst TCplx &
6Indexint
7Lenint
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 5: TMtxVec *AddScaledSqr(TMtxVec *X, const double xScale, TMtxVec *Y, const double yScale) const;

Compute sqr(X*xScale + Y*yScale)

#NameTypeDescription
1XTMtxVec *
2xScaleconst double
3YTMtxVec *
4yScaleconst double
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 6: TMtxVec *AddScaledSqr(TMtxVec *X, const TCplx &xScale, TMtxVec *Y, const TCplx &yScale) const;

Compute sqr(X*xScale + Y*yScale)

#NameTypeDescription
1XTMtxVec *
2xScaleconst TCplx &
3YTMtxVec *
4yScaleconst TCplx &
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 7: TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, const double xScale, TMtxVec *Y, int YIndex, const double yScale, int Index, int Len) const;

Compute sqr(X*xScale + Y*yScale) on sub arrays

#NameTypeDescription
1XTMtxVec *
2XIndexint
3xScaleconst double
4YTMtxVec *
5YIndexint
6yScaleconst double
7Indexint
8Lenint
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler

Overload 8: TMtxVec *AddScaledSqr(TMtxVec *X, int XIndex, const TCplx &xScale, TMtxVec *Y, int YIndex, const TCplx &yScale, int Index, int Len) const;

Compute sqr(X*xScale + Y*yScale) on sub arrays

#NameTypeDescription
1XTMtxVec *
2XIndexint
3xScaleconst TCplx &
4YTMtxVec *
5YIndexint
6yScaleconst TCplx &
7Indexint
8Lenint
Declared in Dew::Math::Vector · Dew.Math/MtxExpr.h · Cross-compiler