trait TriangleTrait (View source)

Methods

static NdArray
triu(NdArray|array $m, int $k = 0)

Upper triangle of an array

static callable
itemTriu(int $col, int $k, int $count, int $line = 1)

Fill zeros from first item to a position

static NdArray
tril(NdArray|array $m, int $k = 0)

Lower triangle of an array

static callable
itemTril(int $col, int $k, int $count, int $line = 1)

Fill zeros from a position to the end of the array

static NdArray
tri(int $rows, int $cols = null, int $k = 0)

Construct an array with ones at and below the given diagonal and zeros elsewhere

static callable
itemTri(int $col, int $k, int $maxCols, int|null $line = 1)

Return a closure that fill a line item with ones

Details

final static NdArray triu(NdArray|array $m, int $k = 0)

Upper triangle of an array

Parameters

NdArray|array $m
int $k Offset

Return Value

NdArray

final static protected callable itemTriu(int $col, int $k, int $count, int $line = 1)

Fill zeros from first item to a position

Parameters

int $col Stop column position
int $k Offset
int $count Max column position
int $line Start line for negative offsets

Return Value

callable

final static NdArray tril(NdArray|array $m, int $k = 0)

Lower triangle of an array

Parameters

NdArray|array $m
int $k Offset

Return Value

NdArray

final static protected callable itemTril(int $col, int $k, int $count, int $line = 1)

Fill zeros from a position to the end of the array

Parameters

int $col Start column position
int $k Offset
int $count Last column position
int $line Start line for negative offsets

Return Value

callable

final static NdArray tri(int $rows, int $cols = null, int $k = 0)

Construct an array with ones at and below the given diagonal and zeros elsewhere

Parameters

int $rows Number of rows
int $cols Number of columns
int $k Offset

Return Value

NdArray

final static protected callable itemTri(int $col, int $k, int $maxCols, int|null $line = 1)

Return a closure that fill a line item with ones

Parameters

int $col Position until which filling is done
int $k Offset
int $maxCols Max position to fill
int|null $line Start at this line if offset is negative

Return Value

callable