void ReconnectRouterOp::onDiscoverRouterFinished() { AsyncOp *op = m_op; m_op->deleteLater(); m_op = NULL; if (isAborted()) { LOG_DEBUG(QString::fromUtf8("discoverRouter self aborted!")); return; } if (op->isAborted()) { LOG_DEBUG(QString::fromUtf8("discoverRouter op aborted!")); return notifyFinished(AbortedError); } int result = op->result(); LOG_DEBUG(QString::fromUtf8("discoverRouterSoap result: %1").arg(result)); if (result != NoError) { return retry(); } int matchIndex = op->value("matchIndex").toInt(); LOG_DEBUG(QString::fromUtf8("matchIndex %1").arg(matchIndex)); if (matchIndex < 0) { return retry(); } copyValues(op); notifyFinished(NoError); }
void MasterDiscoverRouterSoapOp::onOpFinished() { AsyncOp *op = m_op; m_op->deleteLater(); m_op = NULL; if (op->isAborted()) { LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp::onOpFinished() aborted")); return; } int result = op->result(); LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp::onOpFinished() %1").arg(result)); if (result != NoError) { if (m_retryCount < m_maxRetryCount) { LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp Failed, but will retry later")); ++m_retryCount; m_timer1.setSingleShot(true); m_timer1.setInterval(m_retryDelay); connect(&m_timer1, SIGNAL(timeout()), SLOT(onRetryTimeout())); m_timer1.start(); return; } LOG_DEBUG(QString::fromUtf8("MasterDiscoverRouterSoapOp Failed, no more retry chance!")); return notifyFinished(UnknownError); } copyValues(op); notifyFinished(NoError); }
void SymmAnisotropicElasticityTensor::form_transformed_material_dmat_matrix() { // THIS TRANSFORMATION IS VALID ONLY WHEN THE INCOMING MATRIX HAS NOT BEEN ROTATED // The function makes use of TransD6toD9 matrix to transfrom // Dt[6][6] to Dmat[9][9] // Dmat = T * Dt * TT // DenseMatrix<Real> outputMatrix(9,6); // outputMatrix = _trans_d6_to_d9; // outputMatrix.right_multiply(_dt); //_dmat = outputMatrix; //_dmat.right_multiply_transpose(_trans_d6_to_d9); // Use the plug-and-chug functions given in SymmElasticityTensor // to take the existing _val[] and put them into the 9x9 _dmat matrix. SymmElasticityTensor temp_dt; copyValues(temp_dt); ColumnMajorMatrix temp_dmat = temp_dt.columnMajorMatrix9x9(); for (unsigned j(0); j < 9; ++j) { for (unsigned i(0); i < 9; ++i) { _dmat(i, j) = temp_dmat(i, j); } } }
// set a new size for the queue (recopy the values) // s > 0 Queue setSize(Queue q, int s){ Queue nq = newQueue(s); setQHead(nq, getQHead(q)); setQTail(nq, getQTail(q)); setQSize(nq, s); copyValues(q, nq); deleteQueue(q); free(q); return nq; }
bool AMExternalScanDataSourceAB::refreshData() { AMDbObject* dbObject = 0; AMnDIndex oldSize = size(); try { // We might have a scan_ loaded already from the constructor. If not, attempt to load ourselves. if(!scan_) { dbObject = AMDbObjectSupport::s()->createAndLoadObjectAt(sourceDb_, AMDbObjectSupport::s()->tableNameForClass<AMScan>(), sourceScanId_); scan_ = qobject_cast<AMScan*>(dbObject); if(!scan_) throw -1; } scan_->retain(this); int dataSourceIndex = scan_->indexOfDataSource(sourceDataSourceName_); if(dataSourceIndex < 0) throw -2; // get the axes from the source data. Since we're using AMStandardAnalysisBlock, this will automatically expose everything we need. axes_ = scan_->dataSourceAt(dataSourceIndex)->axes(); // grab the data copyValues(dataSourceIndex); copyAxisValues(dataSourceIndex); setState(scan_->dataSourceAt(dataSourceIndex)->state()); // delete the scan scan_->release(this); scan_ = 0; // signalling: emitAxisInfoChanged(); if(oldSize != size()) emitSizeChanged(); emitValuesChanged(); return true; } catch(int errCode) { if(dbObject) delete dbObject; if(scan_) { scan_->release(this); scan_ = 0; } setState(AMDataSource::InvalidFlag); AMErrorMon::report(AMErrorReport(this, AMErrorReport::Serious, errCode, "Could not load external scan data.")); return false; } }
void SequentialHeapMerger::mergeValues(const std::vector<c_atable_ptr_t > &input_tables, atable_ptr_t merged_table, const column_mapping_t &column_mapping, const uint64_t newSize, bool useValid, const std::vector<bool>& valid) { //if (input_tables.size () != 2) // throw std::runtime_error("Merging more than 2 tables is not supported with this merger..."); std::vector<value_id_mapping_t> mappingPerAtrtibute(input_tables[0]->columnCount()); for (const auto & kv: column_mapping) { const auto &source = kv.first; const auto &destination = kv.second; switch (merged_table->metadataAt(destination).getType()) { case IntegerType: case IntegerTypeDelta: case IntegerTypeDeltaConcurrent: mergeValues<hyrise_int_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source], useValid, valid); break; case FloatType: case FloatTypeDelta: case FloatTypeDeltaConcurrent: mergeValues<hyrise_float_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source], useValid, valid); break; case StringType: case StringTypeDelta: case StringTypeDeltaConcurrent: mergeValues<hyrise_string_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source], useValid, valid); break; case IntegerNoDictType: case FloatNoDictType: merged_table->setDictionaryAt(makeDictionary(merged_table->typeOfColumn(destination)), destination); default: break; } } merged_table->resize(newSize); // Only after the dictionaries are merged copy the values for (const auto & kv: column_mapping) { const auto &source = kv.first; const auto &destination = kv.second; // copy the actual values and apply mapping copyValues(input_tables, source, merged_table, destination, mappingPerAtrtibute[source], useValid, valid); } }
std::ostream& RecordSet::copy(std::ostream& os, std::size_t offset, std::size_t length) const { RowFormatter& rf = const_cast<RowFormatter&>((*_pBegin)->getFormatter()); rf.setTotalRowCount(static_cast<int>(getTotalRowCount())); if (RowFormatter::FORMAT_PROGRESSIVE == rf.getMode()) { os << rf.prefix(); copyNames(os); copyValues(os, offset, length); os << rf.postfix(); } else { formatNames(); formatValues(offset, length); os << rf.toString(); } return os; }
void SequentialHeapMerger::mergeValues(const std::vector<hyrise::storage::c_atable_ptr_t > &input_tables, hyrise::storage::atable_ptr_t merged_table, const hyrise::storage::column_mapping_t &column_mapping, const uint64_t newSize) { std::vector<value_id_mapping_t> mappingPerAtrtibute(input_tables[0]->columnCount()); for (const auto & kv: column_mapping) { const auto &source = kv.first; const auto &destination = kv.second; switch (merged_table->metadataAt(destination)->getType()) { case IntegerType: mergeValues<hyrise_int_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source]); break; case FloatType: mergeValues<hyrise_float_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source]); break; case StringType: mergeValues<hyrise_string_t>(input_tables, source, merged_table, destination, mappingPerAtrtibute[source]); break; default: break; } } merged_table->resize(newSize); // Only after the dictionaries are merged copy the values for (const auto & kv: column_mapping) { const auto &source = kv.first; const auto &destination = kv.second; // copy the actual values and apply mapping copyValues(input_tables, source, merged_table, destination, mappingPerAtrtibute[source]); } }
Collection& Collection::operator=(Collection &obj) { m_size = obj.m_size; //std::cout << "Size set in = operator " << m_size << std::endl; copyValues(obj.m_values); return *this; }
Collection::Collection(Collection &obj) : m_size(obj.m_size), m_values(NULL) { copyValues(obj.m_values); //std::cout << "Size set in copy constructor " << m_size << std::endl; }
Groundfloor::StringVectorRange::StringVectorRange( Groundfloor::StringVectorRange *aRange ) { copyValues( aRange ); }
int main() { /************************************************************/ /* */ /* ここに課題のプログラムを書く. */ /* */ /* 関数 read_matrix() を呼ぶことで,標準入力から連立一次 */ /* 方程式の次数および各係数を読み込む.その結果, */ /* 次数が大域変数 n に, */ /* 係数行列 A と右辺ベクトル b を合わせた拡大行列 [A b] が */ /* 帯域変数 a[][] に,それぞれ格納される. */ /* なお,a[][]の内部は */ /* A → a[1][1] ... a[n][n] , */ /* b → a[1][n+1] ... a[n][n+1] */ /* のようになっている. */ /* */ /* 関数 print_matrix() は a[][] の内容を標準出力に */ /* 出力する.アルゴリズムのデバッグに活用すべし. */ /* */ /************************************************************/ /* 以下はサンプルプログラムで,行列を読み込んでそのまま出力する.*/ /* 標準入力を読み込んで,係数行列を a[][] に,次数を n に格納する */ if (read_matrix() != 0) { /* 返り値が 0 以外であればエラー */ fprintf(stderr, "input error!\n"); return -1; } /* 現在の係数行列 a[][] の内容を出力する */ print_matrix(); /* ここにガウス消去法などの課題のプログラムを書く */ // Instead of Gaussian elimination, we'll use gauss-seidel method this // These 2 variables are used to test every cases of swapping (like a // bubble sort) int rowToSwap; int rowToSwap2; int allCombinations; for (allCombinations = 0; allCombinations < n; allCombinations++) { for (rowToSwap = 1; rowToSwap < n; rowToSwap++) { for (rowToSwap2 = n; rowToSwap2 >= 1; rowToSwap2--) { double values[MAXN] = {0}; double prev_values[MAXN] = {0}; // Checking if the equations are solved for x_1, x_2 ... print_matrix(); // Repeat this loop N times at maximum int i, j, k; int invalidDivision = 0; for (i = 0; i < N; i++) { for (j = 1; j <= n; j++) { if (a[j][j] == 0) { invalidDivision = 1; break; } // Initialize before starting values[j - 1] = 0; for (k = 1; k <= n; k++) { double multi = values[k - 1]; if (k == j) multi = 0; // Since j starts from 1 // The sign will be flipped when moving to the right side //printf("values[%d]: %f += %f * %f\n", j - 1, values[j - 1], -(a[j][k] / a[j][j]), multi); values[j - 1] += -(a[j][k] / a[j][j]) * multi; } if (a[j][j] == 0) break; //printf("values[%d] = %f (%f += %f)\n", j - 1, values[j - 1] + a[j][n + 1] / a[j][j], values[j - 1], a[j][n + 1] / a[j][j]); // Add the integer (= Matrix "b") values[j - 1] += a[j][n + 1] / a[j][j]; } if (invalidDivision == 1) break; // After the whole matrix has been processed, check if the result // was accurate enough. double d = findMaxDelta(values, prev_values); printf("d: %f\n", d); // Stop when it becomes accurate enough if (d <= epsilon) { printValues(values); return 0; } // Now, make a backup of the current values (so that we can // calculate the delta in the next loop copyValues(values, prev_values); } // If the program comes out of this loop, it means that N trials were done // but the solutions didn't get accurate enough. swapRow(rowToSwap, rowToSwap2); //printf("swapped %d <=> %d\n", rowToSwap, rowToSwap2); } } } // Coming here means there were many attempts of estimating the solution // but all the attempts ended up not being accurate enough. It is possible // that the epsilon is too small or maybe there's something wrong with the // equation. printf("The equation set is likely it does not converge.\n"); /* プログラムの終了 */ return 0; }