SimpleCallObserver::Private::Private(SimpleCallObserver *parent, const AccountPtr &account, const QString &contactIdentifier, bool requiresNormalization, CallDirection direction) : parent(parent), account(account), contactIdentifier(contactIdentifier), direction(direction) { debug() << "Creating a new SimpleCallObserver"; ChannelClassSpec channelFilterSMC = ChannelClassSpec::streamedMediaCall(); ChannelClassSpec channelFilterCall = ChannelClassSpec::mediaCall(); if (direction == CallDirectionIncoming) { channelFilterSMC.setRequested(false); channelFilterCall.setRequested(false); } else if (direction == CallDirectionOutgoing) { channelFilterSMC.setRequested(true); channelFilterCall.setRequested(true); } observer = SimpleObserver::create(account, ChannelClassSpecList() << channelFilterSMC << channelFilterCall, contactIdentifier, requiresNormalization, QList<ChannelClassFeatures>()); parent->connect(observer.data(), SIGNAL(newChannels(QList<Tp::ChannelPtr>)), SLOT(onNewChannels(QList<Tp::ChannelPtr>))); parent->connect(observer.data(), SIGNAL(channelInvalidated(Tp::ChannelPtr,QString,QString)), SLOT(onChannelInvalidated(Tp::ChannelPtr,QString,QString))); }
// Remove constant entries from data matrix. int GPCMDataReader::removeConstantEntries( MatrixXd &channels, // Final channels, returns only variable entries. MatrixXd &constantEntries, // Constant entries to return. std::vector<int> &constantIndices, // Constant indices to return. std::vector<int> &variableIndices // Variable indices to return. ) { // Compute variance in each column. int T = channels.rows(); MatrixXd means = channels.colwise().sum()/T; MatrixXd vars = (channels - means.replicate(T,1)).colwise().squaredNorm()/T; // Step over all vars and decide where they go. for (int i = 0; i < channels.cols(); i++) { if (vars(0,i) < EPS_ANGLE) constantIndices.push_back(i); else variableIndices.push_back(i); } // Distribute results. MatrixXd newChannels(channels.rows(),variableIndices.size()); constantEntries.resize(1,constantIndices.size()); int k = 0; for (std::vector<int>::iterator itr = constantIndices.begin(); itr != constantIndices.end(); itr++) { constantEntries(0,k) = means(0,*itr); k++; } k = 0; for (std::vector<int>::iterator itr = variableIndices.begin(); itr != variableIndices.end(); itr++) { newChannels.block(0,k,channels.rows(),1) = channels.block(0,*itr,channels.rows(),1); k++; } // Copy over new channels structure. channels = newChannels; // Return total elements. return constantIndices.size()+variableIndices.size(); }