SERPAD

Purpose:

Pads a series or table with a specified value.

Syntax:

SERPAD(series, padlen, val)

series

-

A series or table, the input to pad.

padlen

-

An integer or series, the desired output length.

val

-

Optional. A real, the padding value. Defaults to 0.0.

Returns:

A series or table, the padded result.

Example:

W1: 1..5

W2: serpad(w1, 8, -1)

 

W1 contains the series {1, 2, 3, 4, 5}. W2 pads the series to a length of 8 with the value -1. The resulting series is {1, 2, 3, 4, 5, -1, -1, -1}.

Example:

W1: 1..5

W2: serpad(w1, 3, -1)

 

W1 contains the series {1, 2, 3, 4, 5}. Because the padding length is less than the original series length, the resulting series is {1, 2, 3}.

Example:

W1: reshape(1..9, {2, 3, 4, 2})

W2: serpad(w1, 4, -1)

 

W1 contains the table:

 

  1  3  6

  2  4  7

     5  8

        9

 

W2 pads each column with a value of -1 so the desired length of each column is 4. The resulting 4x3 table is:

 

 {{ 1,  3, 6},

  { 2,  4, 7},

  {-1,  5, 8},

  {-1, -1, 9}}

Example:

W1: reshape(1..9, {2, 3, 4, 2})

W2: serpad(w1, {3, 5, 6}, -1)

 

W1 contains the table:

 

 1  3  6

 2  4  7

    5  8

       9

 

W2 pads each column with a value of -1 such that the desired length of column 1 is 3, the length of column 2 is 5 and the length of column 3 is 6. The resulting table is:

 

 1  3  6

 2  4  7

-1  5  8

   -1  9

   -1 -1

      -1

Remarks:

If the padding length is less than the series length, the input is extracted to the smaller length.

 

To apply separate padding lengths for each column of an input table, set padlen to a series containing the desired lengths.

See Also:

APPEND

COLEXTRACT

CONCAT

EXTRACT

REGION

RESHAPE