View Raw SPL
/*****************************************************************************
* *
* UPTRIX.SPL Copyright (C) 2000 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Returns the upper triangle of an array *
* *
* Revisions: 3 Apr 2000 RRR Creation - from MATRIX.MAC by *
* Kevin Carmondy *
* *
*****************************************************************************/
#if @HELP_UPTRIX
UPTRIX
Purpose: Returns the upper triangle of a matrix excluding the main diagonal
Syntax: UPTRIX(m)
m - input array
Returns: An array of size(m) consisting of the upper triangle of m
excluding the main diagonal with the other elements set
to 0.
Example:
W1: ones(3)
W2: UPTRIX(W1)
W2 == {{0, 1, 1},
{0, 0, 1},
{0, 0, 0}}
Remarks:
UPTRIX excludes the main diagonal. Use UPTRI to include
the main diagonal.
See Also:
Colnos
Lotri
Lotrix
Rownos
Uptri
#endif
/*
* UPTRIX returns the upper triangle of a matrix, excluding the main
* diagnonal, with the lower triangle zeroed out.
*/
uptrix(M)
{
return((M)*(rownos(M) < colnos(M)));
}