Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TMtxVec *Sgn(); | Computes signum function of calling object elements. |
| 2 | TMtxVec *Sgn(int Index, int Len); | Computes signum function of calling object elements [Index..Index+Len-1]. |
| 3 | TMtxVec *Sgn(TMtxVec *Src); | Computes signum function from Src elements and stores the result in the calling object. |
| 4 | TMtxVec *Sgn(TMtxVec *Src, int SrcIndex, int Index, int Len); | Computes signum function from Src elements [SrcIndex..SrcIndex+Len-1] and stores the result in the calling object [Index..Index+Len-1]. |
Overload 1: TMtxVec *Sgn();
Computes signum function of calling object elements.
Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.
#include "Math387.h"
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Vector a;
a.SetIt(DewArray<double>{ -3.0, -1.0, 1.0, 2.0 });
a.Sgn();
Vector expected;
expected.SetIt(DewArray<double>{ -1.0, -1.0, 1.0, 1.0 });
if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
throw tException("Vector.Sgn: mismatch");
}
Overload 2: TMtxVec *Sgn(int Index, int Len);
Computes signum function of calling object elements [Index..Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Index | int | |
| 2 | Len | int |
Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.
Overload 3: TMtxVec *Sgn(TMtxVec *Src);
Computes signum function from Src elements and stores the result in the calling object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TMtxVec * |
Size and TMtx::Complex properties of calling object are adjusted automatically. Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.
#include "Math387.h"
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Vector a;
Vector x;
x.SetIt(DewArray<double>{ -3.0, -1.0, 1.0, 2.0 });
a.Sgn(x);
Vector expected;
expected.SetIt(DewArray<double>{ -1.0, -1.0, 1.0, 1.0 });
if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
throw tException("Vector.Sgn: mismatch");
}
Overload 4: TMtxVec *Sgn(TMtxVec *Src, int SrcIndex, int Index, int Len);
Computes signum function from Src elements [SrcIndex..SrcIndex+Len-1] and stores the result in the calling object [Index..Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TMtxVec * | |
| 2 | SrcIndex | int | |
| 3 | Index | int | |
| 4 | Len | int |
Size and TMtx::Complex properties of calling object are adjusted automatically. Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.