View Raw SPL
/*****************************************************************************
* *
* WSSIZE.SPL Copyright (C) 2023 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Returns total number of samples in a worksheet *
* *
* Revisions: 11 Aug 2023 RRR Creation *
* *
*****************************************************************************/
#if @HELP_WSSIZE
WSSIZE
Purpose: Returns the total number of samples in a worksheet.
Syntax: WSSIZE(W1, W1, ..., WN, bytes)
WN - Optional, Zero or more Windows. Defaults to all
windows in the worksheet.
bytes - Optional. An integer, the byte size flag.
0: return total number of samples (default)
1: return total number of bytes
Returns: An integer, the total number of samples or bytes used by
the current worksheet.
Example:
newworksheet(4);
W1 := {1, 2, 4, 7}
W2 := fft(w1)
wssize()
returns 8, the total number of samples in the worksheet.
Example:
newworksheet(4);
W1 := {1, 2, 4, 7}
W2 := fft(w1)
wssize(1)
returns 96, the total number of bytes in the worksheet.
Example:
newworksheet(4);
W1 := {1, 2, 4, 7}
W2 := fft(w1)
wssize(w2)
returns 4, the total number of samples in W2.
Example:
newworksheet(4);
W1 := {1, 2, 4, 7}
W2 := fft(w1)
wssize(w2, 1)
returns 64, the total number of bytes in W2. W2 contains 4
complex values where each value is 16 bytes.
Example:
newworksheet(4);
W1 := {1, 2, 4, 7}
W2 := fft(w1)
wssize(w3, w4)
returns 0, since neither W3 nor W4 contains a series.
Remarks:
WSSIZE returns the total number of data samples in a worksheet.
All windows are processed including hidden windows.
If BYTES is nonzero, the total number of data bytes is returned.
See Also:
Length
Size
#endif
/* total number of samples for specified windows */
wssize(argv)
{
local size = 0, w, n, winlist = {}, bytes = 0, fac;
if (argc > 0)
{
loop (j = 1..argc)
{
if (isscalar(getargv(j)))
{
bytes = castint(getargv(j));
}
else if (iswindow(getargv(j)))
{
winlist @= getwnum(getargv(j));
}
}
}
if (isempty(winlist))
{
winlist = 1..numwin();
}
size = 0;
fac = bytes ? 8 : 1;
loop (w = winlist)
{
n = numel(castwin(w));
/* account for complex */
if (iscomplex(castwin(w)) && bytes)
{
n *= 2;
}
size += n * fac;
}
return(size);
}