TMtx.Sum Method

Overload List

#SignatureDescription
1Double SumSums vector values.
└ indexed: Double Sum(Int32 Index, Int32 Len)
2void Sum(ref TCplx ASum)Calculates the sum of all calling object complex elements.
└ indexed: void Sum(ref TCplx ASum, Int32 Index, Int32 Len)
3void Sum(ref Double ASum, Int32 Index, Int32 Len)Calculates the sum of calling object elements [Index]..[Index+Len-1].

Overload 1: Double Sum

Sums vector values.

Returns: Double - the sum of all calling object elements. An exception is raised if calling object Dew.Math.TMtxVec.Complex property is true.

Examples
Matrix a = new Matrix();
a.SetIt(2, 2, false, new double[] { 1.0, 2.0, 3.0, 4.0 });
double result = a.Sum();
if (Math.Abs(result - 10.0) > 1e-10)
    throw new Exception("Matrix.Sum: expected 10.0, got " + result);
Matrix a;
double b;
a.SetIt(1,4,false,new double[] {1,2,3,4});
b = a.Sum; // b = 10

Indexed: Double Sum(Int32 Index, Int32 Len)

Returns the sum of calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1IndexInt32start index
2LenInt32element count

Returns: Double

Remarks:

An exception is raised if calling object Dew.Math.TMtxVec.Complex property is True or array borders are overrun/underrun.

Overload 2: void Sum(ref TCplx ASum)

Calculates the sum of all calling object complex elements.

#NameTypeDescription
1ASumTCplx (ref)output sum

Result: stored in self (calling object)

Remarks:

Stores the result in complex ASum variable. An exception is raised if calling object Dew.Math.TMtxVec.Complex property is False.

Indexed: void Sum(ref TCplx ASum, Int32 Index, Int32 Len)

Calculates the sum of calling object complex elements [Index]..[Index+Len-1].

#NameTypeDescription
1ASumTCplx (ref)output sum
2IndexInt32start index
3LenInt32element count

Result: stored in self (calling object)

Remarks:

Stores the result in complex ASum variable. An exception is raised if calling object Dew.Math.TMtxVec.Complex property is False or array borders are overrun/underrun.

Overload 3: void Sum(ref Double ASum, Int32 Index, Int32 Len)

Calculates the sum of calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1ASumDouble (ref)output sum
2IndexInt32start index
3LenInt32element count

Result: stored in self (calling object)

Remarks:

Stores the result in real ASum variable. An exception is raised if calling object Dew.Math.TMtxVec.Complex property is True or array borders are overrun/underrun.