<commit_before>/*
 * Copyright (c) 2014-2016, imec
 * All rights reserved.
 */

#include "error.h"
#include "bpmf.h"

#include <random>
#include <memory>
#include <cstdio>
#include <iostream>
#include <climits>
#include <stdexcept>

typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> PermMatrix;

void Sys::permuteCols(const PermMatrix &perm, Sys &other)
{
    // permute local matrices
    T = T * perm;
    Pavg = Pavg * perm;
    Pm2 = Pm2 * perm;
    M = M * perm;
    propMu * perm;
    propLambda * perm;

    // permute other matrices
    other.T = T.transpose();
    other.Pavg = Pavg.transpose();
    other.Pm2 = Pm2.transpose();
    other.M = M.transpose();
}

//
// Distributes users/movies accros several nodes
// takes into account load balance and communication cost
//
void Sys::assign(Sys &other)
{
    if (nprocs == 1) {
        dom[0] = 0; 
        dom[1] = num(); 
        return; 
    }
<commit_msg>FIX: don't permute if no propagate posterior<commit_after>/*
 * Copyright (c) 2014-2016, imec
 * All rights reserved.
 */

#include "error.h"
#include "bpmf.h"

#include <random>
#include <memory>
#include <cstdio>
#include <iostream>
#include <climits>
#include <stdexcept>

typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> PermMatrix;

void Sys::permuteCols(const PermMatrix &perm, Sys &other)
{
    // permute local matrices
    T = T * perm;
    Pavg = Pavg * perm;
    Pm2 = Pm2 * perm;
    M = M * perm;

    if (has_prop_posterior())
    {
        propMu *= perm;
        propLambda *= perm;
    }

    // permute other matrices
    other.T = T.transpose();
    other.Pavg = Pavg.transpose();
    other.Pm2 = Pm2.transpose();
    other.M = M.transpose();
}

//
// Distributes users/movies accros several nodes
// takes into account load balance and communication cost
//
void Sys::assign(Sys &other)
{
    if (nprocs == 1) {
        dom[0] = 0; 
        dom[1] = num(); 
        return; 
    }

{'fraction_non_alphanumeric': 0.14358974358974358, 'fraction_numerical': 0.01641025641025641, 'mean_word_length': 2.840551181102362, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1917959', 'n_tokens_mistral': 731, 'n_tokens_neox': 680, 'n_words': 184}