MAL.Sum

Previous  Next

 

sum = MAL.Sum( BYREF data    AS ARRAY,

              [BYVAL vixa    AS INTEGER=ML_ALL],

              [BYVAL nFrames AS INTEGER=ML_ALL] ) AS REAL

 


 

Returns the maximum value of a 1 dimensional array.  If bIndex is set, then the index into the array is returned instead of the value.

 

You can specify array index using a VIX if the input is a multidimensional array.  If the nFrames parameter is specified, the sum will only used the number of frames specified.  The frame offset can be set using the Vixa argument.

 

Example:

 

OPTION EXPLICIT ON

OPTION BASE 1

 

' Include C3D Support

$INCLUDE "MyBASIC2_C3DFile"

$LIBRARY "MyBASIC2_C3DFileLib"

 

' Include the MaxMAL Library

$INCLUDE "MyBASIC2_MaxMAL"

$LIBRARY "MyBASIC2_MaxMALLib"

 

' Forward Declare PrintArray

DECLARE SUB PrintArray

 

' Declare variables and arrays

DIM nPoints AS INTEGER

DIM nFrames AS INTEGER

DIM hFile   AS INTEGER

DIM fid     AS HANDLE

 

' Name of Test File

CONST cFileName = "e:\walk8.c3d"

 

CLS

 

' Open the Test File

hFile = C3DFile.Open( cFileName );

 

IF NOT hFile > 0 THEN

  PRINT "Error Opening File ";cFileName,

  STOP

ENDIF

 

' Get the no of points and frames

nFrames = C3DFile.GetNoOfFrames( hFile )

nPoints = C3DFile.GetNoOfPoints( hFile )

 

' Dimension the arrays

DIM arrPoints(nFrames,nPoints,3) AS REAL

 

IF C3DFile.GetPoints( hFile, arrPoints ) <> nFrames THEN

  C3DFile.Close( hFile )

  PRINT "Error Reading ";nPoints;" from file ";cFileName,

  STOP

ENDIF

 

' Array to receive the calculated Vector Length

DIM arrVLen(nFrames,nPoints,1) AS REAL

 

DIM i AS INTEGER

 

FOR i = 1 TO nPoints

  ' Calculate Distance travelled of the Points

  PRINT "Total Distance Travelled Point #";i;": "; MAL.Sum( MAL.Distance( arrVLen, arrPoints, i ) )

ENDFOR

 

' Close Test File

C3DFile.Close( hFile )

 

END