libs/besiq/prior.cpp
arma::vec
permute_phenotype(const arma::vec &phenotype, arma::vec &weight)
{
    arma::vec permuted_phenotype = phenotype;
    for(int i = phenotype.n_elem - 1; i > 0; --i)
    {
        int j = random( ) % ( i + 1 );

        std::swap( permuted_phenotype[ i ], permuted_phenotype[ j ] );
        std::swap( weight[ i ], weight[ j ] );
    }
    
    return permuted_phenotype;
}
/**
 * Permutes the given phenotype and returns a new
 * vector containing the permuted phenotype.
 *
 * @param phenotype A vector containing phenotypes.
 * @param weight Weight for each individual, will be changed
 *               after this call to ensure that individuals with
 *               weight 0 always are ignored.
 *
 * @return Permuted phenotypes.
 */
Permutes the given phenotype and returns a new
vector containing the permuted phenotype.

@param phenotype A vector containing phenotypes.
@param weight Weight for each individual, will be changed
after this call to ensure that individuals with
weight 0 always are ignored.

@return Permuted phenotypes.
Permutes the given phenotype and returns a new vector containing the permuted phenotype . @param phenotype A vector containing phenotypes . @param weight Weight for each individual will be changed after this call to ensure that individuals with weight 0 always are ignored . @return Permuted phenotypes .
arma::vec
permute_phenotype(const arma::vec &phenotype, arma::vec &weight)
{
    arma::vec permuted_phenotype = phenotype;
    for(int i = phenotype.n_elem - 1; i > 0; --i)
    {
        int j = random( ) % ( i + 1 );
        std::swap( permuted_phenotype[ i ], permuted_phenotype[ j ] );
        std::swap( weight[ i ], weight[ j ] );
    }
    return permuted_phenotype;
}
arma :: vec permute_phenotype ( const arma :: vec & phenotype , arma :: vec & weight ) { arma :: vec permuted_phenotype = phenotype ; for ( int i = phenotype . n_elem - 1 ; i > 0 ; -- i ) { int j = random ( ) % ( i + 1 ) ; std :: swap ( permuted_phenotype [ i ] , permuted_phenotype [ j ] ) ; std :: swap ( weight [ i ] , weight [ j ] ) ; } return permuted_phenotype ; }
Permutes the given phenotype and returns a new
 vector containing the permuted phenotype.
Permutes the given phenotype and returns a new vector containing the permuted phenotype .