From 49b32975e9963de01b2ecc102b95488e4fdbf975 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Fri, 22 May 2015 12:17:09 -0300 Subject: Optimized InteractionHandler to minimze allocations; view updates now happen whenever a point is moved. --- interactionhandler.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'interactionhandler.cpp') diff --git a/interactionhandler.cpp b/interactionhandler.cpp index 217f4a5..5225be9 100644 --- a/interactionhandler.cpp +++ b/interactionhandler.cpp @@ -8,24 +8,21 @@ InteractionHandler::InteractionHandler(const arma::mat &X, : m_X(X) , m_labels(labels) , m_sampleIndices(sampleIndices) + , m_Y(X.n_rows, 3) , m_technique(TECHNIQUE_LAMP) { + m_Y.col(2) = m_labels; } void InteractionHandler::setSubsample(const arma::mat &Ys) { - arma::mat embedding(m_X.n_rows, Ys.n_cols); switch (m_technique) { case TECHNIQUE_PLMP: case TECHNIQUE_LSP: case TECHNIQUE_LAMP: - embedding = mp::lamp(m_X, m_sampleIndices, Ys); + m_Y.cols(0, 1) = mp::lamp(m_X, m_sampleIndices, Ys); break; } - arma::mat Y(embedding.n_rows, embedding.n_cols + 1); - Y.cols(0, embedding.n_cols - 1) = embedding; - Y.col(Y.n_cols - 1) = m_labels; - - emit subsampleChanged(Y); + emit subsampleChanged(m_Y); } -- cgit v1.2.3