Overload List
| # | Signature | Description |
|---|---|---|
| 1 | double Sum(); | Sums vector values. |
| 2 | double Sum(int Index, int Len); | Returns the sum of calling object elements [Index]..[Index+Len-1]. |
| 3 | void Sum(double &ASum, int Index, int Len); | Calculates the sum of calling object elements [Index]..[Index+Len-1]. |
| 4 | void Sum(TCplx &ASum); | Calculates the sum of all calling object complex elements. |
| 5 | void Sum(TCplx &ASum, int Index, int Len); | Calculates the sum of calling object complex elements [Index]..[Index+Len-1]. |
Overload 1: double Sum();
Sums vector values.
Returns: the sum of all calling object elements. An exception is raised if calling object TSparseMtx::Complex property is true.
#include "MtxVec.h"
#include "Units.MtxVec.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;
void Example()
{
TVec* a;
CreateIt(a);
a->SetIt(false, DewArray<double>{1, 3, -2});
double s = a->Sum(); // s = 2
FreeIt(a);
}
#include "MtxExpr.h"
#include "Units.Math387.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
void Example()
{
Vector a;
a.SetIt(DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
double result = a.Sum();
if (Abs(result - 10.0) > 1e-10)
throw tException(DewString("Vector.Sum: expected 10.0, got ") + SampleToStr(result));
}
Overload 2: double Sum(int Index, int Len);
Returns the sum of calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Index | int | |
| 2 | Len | int |
An exception is raised if calling object TSparseMtx::Complex property is True or array borders are overrun/underrun.
Overload 3: void Sum(double &ASum, int Index, int Len);
Calculates the sum of calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | ASum | double & | |
| 2 | Index | int | |
| 3 | Len | int |
Stores the result in real ASum variable. An exception is raised if calling object TSparseMtx::Complex property is True or array borders are overrun/underrun.
Overload 4: void Sum(TCplx &ASum);
Calculates the sum of all calling object complex elements.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | ASum | TCplx & |
Stores the result in complex ASum variable. An exception is raised if calling object TSparseMtx::Complex property is False.
Overload 5: void Sum(TCplx &ASum, int Index, int Len);
Calculates the sum of calling object complex elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | ASum | TCplx & | |
| 2 | Index | int | |
| 3 | Len | int |
Stores the result in complex ASum variable. An exception is raised if calling object TSparseMtx::Complex property is False or array borders are overrun/underrun.