externals/SuiteSparse/LDL/ldl_di.c
/* ========================================================================== */
/* === ldl_valid_perm: check if a permutation vector is valid =============== */
/* ========================================================================== */
check if a permutation vector is valid
check if a permutation vector is valid
LDL_int LDL_valid_perm	    
(
    LDL_int n,
    LDL_int P [ ],	    
    LDL_int Flag [ ]	    
)
{
    LDL_int j, k ;
    if (n < 0 || !Flag)
    {
	return (0) ;	    
    }
    if (!P)
    {
	return (1) ;	    
    }
    for (j = 0 ; j < n ; j++)
    {
	Flag [j] = 0 ;	    
    }
    for (k = 0 ; k < n ; k++)
    {
	j = P [k] ;
	if (j < 0 || j >= n || Flag [j] != 0)
	{
	    return (0) ;    
	}
	Flag [j] = 1 ;
    }
    return (1) ;	    
}
LDL_int LDL_valid_perm ( LDL_int n , LDL_int P [ ] , LDL_int Flag [ ] ) { LDL_int j , k ; if ( n < 0 || ! Flag ) { return ( 0 ) ; } if ( ! P ) { return ( 1 ) ; } for ( j = 0 ; j < n ; j ++ ) { Flag [ j ] = 0 ; } for ( k = 0 ; k < n ; k ++ ) { j = P [ k ] ; if ( j < 0 || j >= n || Flag [ j ] != 0 ) { return ( 0 ) ; } Flag [ j ] = 1 ; } return ( 1 ) ; }
ldl_valid_perm: check if a permutation vector is valid
ldl_valid_perm : check if a permutation vector is valid
/* returns 1 if valid, 0 otherwise */ /* input of size n, a permutation of 0:n-1 */ /* workspace of size n */ /* n must be >= 0, and Flag must be present */ /* If NULL, P is assumed to be the identity perm. */ /* clear the Flag array */ /* P is not valid */ /* P is valid */