void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs) { out.eval(); rhs.eval(); vector<bool> isSeq(4); vector<af_seq> seqs(4, af_span); // create seq vector to retrieve output dimensions, offsets & offsets for (dim_t x=0; x<4; ++x) { if (idxrs[x].isSeq) { seqs[x] = idxrs[x].idx.seq; } isSeq[x] = idxrs[x].isSeq; } vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4())); // look through indexs to read af_array indexs for (dim_t x=0; x<4; ++x) { if (!isSeq[x]) { idxArrs[x] = castArray<uint>(idxrs[x].idx.arr); idxArrs[x].eval(); } } getQueue().enqueue(kernel::assign<T>, out, rhs, std::move(isSeq), std::move(seqs), std::move(idxArrs)); }
inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4&> seqs( t0 , t1 , t2 , t3 , t4); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4>::type( seqs); }
inline typename result_of::zip<const T0 , const T1 , const T2>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2) { fusion::vector<const T0& , const T1& , const T2&> seqs( t0 , t1 , t2); return typename result_of::zip<const T0 , const T1 , const T2>::type( seqs); }
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4&> seqs( t0 , t1 , t2 , t3 , t4); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4>::type( seqs); }
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1>::type zip(T0 const& t0 , T1 const& t1) { fusion::vector<const T0& , const T1&> seqs( t0 , t1); return typename result_of::zip<const T0 , const T1>::type( seqs); }
BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3) { fusion::vector<const T0& , const T1& , const T2& , const T3&> seqs( t0 , t1 , t2 , t3); return typename result_of::zip<const T0 , const T1 , const T2 , const T3>::type( seqs); }
Array<T> index(const Array<T>& in, const af_index_t idxrs[]) { kernel::IndexKernelParam_t p; std::vector<af_seq> seqs(4, af_span); // create seq vector to retrieve output // dimensions, offsets & offsets for (dim_t x=0; x<4; ++x) { if (idxrs[x].isSeq) { seqs[x] = idxrs[x].idx.seq; } } // retrieve dimensions, strides and offsets dim4 iDims = in.dims(); dim4 dDims = in.getDataDims(); dim4 oDims = toDims (seqs, iDims); dim4 iOffs = toOffset(seqs, dDims); dim4 iStrds= toStride(seqs, dDims); for (dim_t i=0; i<4; ++i) { p.isSeq[i] = idxrs[i].isSeq; p.offs[i] = iOffs[i]; p.strds[i] = iStrds[i]; } Buffer* bPtrs[4]; std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4())); // look through indexs to read af_array indexs for (dim_t x=0; x<4; ++x) { // set index pointers were applicable if (!p.isSeq[x]) { idxArrs[x] = castArray<uint>(idxrs[x].idx.arr); bPtrs[x] = idxArrs[x].get(); // set output array ith dimension value oDims[x] = idxArrs[x].elements(); } else { // alloc an 1-element buffer to avoid OpenCL from failing bPtrs[x] = bufferAlloc(sizeof(uint)); } } Array<T> out = createEmptyArray<T>(oDims); if(oDims.elements() == 0) { return out; } kernel::index<T>(out, in, p, bPtrs); for (dim_t x=0; x<4; ++x) { if (p.isSeq[x]) bufferFree(bPtrs[x]); } return out; }
int main(int argc, const char* argv[]){ IloEnv env; try { const char* filename = "../../../examples/data/flowshop_default.data"; IloInt failLimit = IloIntMax; if (argc > 1) filename = argv[1]; if (argc > 2) failLimit = atoi(argv[2]); std::ifstream file(filename); if (!file){ env.out() << "usage: " << argv[0] << " <file> <failLimit>" << std::endl; throw FileError(); } IloInt i,j; IloModel model(env); IloInt nbJobs, nbMachines; file >> nbJobs; file >> nbMachines; IloIntervalVarArray2 machines(env, nbMachines); for (j = 0; j < nbMachines; j++) machines[j] = IloIntervalVarArray(env); IloIntExprArray ends(env); for (i = 0; i < nbJobs; i++) { IloIntervalVar prec; for (j = 0; j < nbMachines; j++) { IloInt d; file >> d; IloIntervalVar ti(env, d); machines[j].add(ti); if (0 != prec.getImpl()) model.add(IloEndBeforeStart(env, prec, ti)); prec = ti; } ends.add(IloEndOf(prec)); } IloIntervalSequenceVarArray seqs(env,nbMachines); for (j = 0; j < nbMachines; j++) { seqs[j] = IloIntervalSequenceVar(env, machines[j]); model.add(IloNoOverlap(env,seqs[j])); if (0<j) { model.add(IloSameSequence(env, seqs[0],seqs[j])); } } IloObjective objective = IloMinimize(env,IloMax(ends)); model.add(objective); IloCP cp(model); cp.setParameter(IloCP::FailLimit, failLimit); cp.setParameter(IloCP::LogPeriod, 10000); cp.out() << "Instance \t: " << filename << std::endl; if (cp.solve()) { cp.out() << "Makespan \t: " << cp.getObjValue() << std::endl; } else { cp.out() << "No solution found." << std::endl; } } catch(IloException& e){ env.out() << " ERROR: " << e << std::endl; } env.end(); return 0; }
inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5 , T6 const& t6 , T7 const& t7 , T8 const& t8 , T9 const& t9) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5& , const T6& , const T7& , const T8& , const T9&> seqs( t0 , t1 , t2 , t3 , t4 , t5 , t6 , t7 , t8 , t9); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9>::type( seqs); }
inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5 , T6 const& t6) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5& , const T6&> seqs( t0 , t1 , t2 , t3 , t4 , t5 , t6); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6>::type( seqs); }
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9 , const T10 , const T11 , const T12 , const T13 , const T14 , const T15 , const T16 , const T17 , const T18 , const T19>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5 , T6 const& t6 , T7 const& t7 , T8 const& t8 , T9 const& t9 , T10 const& t10 , T11 const& t11 , T12 const& t12 , T13 const& t13 , T14 const& t14 , T15 const& t15 , T16 const& t16 , T17 const& t17 , T18 const& t18 , T19 const& t19) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5& , const T6& , const T7& , const T8& , const T9& , const T10& , const T11& , const T12& , const T13& , const T14& , const T15& , const T16& , const T17& , const T18& , const T19&> seqs( t0 , t1 , t2 , t3 , t4 , t5 , t6 , t7 , t8 , t9 , t10 , t11 , t12 , t13 , t14 , t15 , t16 , t17 , t18 , t19); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9 , const T10 , const T11 , const T12 , const T13 , const T14 , const T15 , const T16 , const T17 , const T18 , const T19>::type( seqs); }
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5 , T6 const& t6 , T7 const& t7 , T8 const& t8) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5& , const T6& , const T7& , const T8&> seqs( t0 , t1 , t2 , t3 , t4 , t5 , t6 , t7 , t8); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8>::type( seqs); }
/** * @brief Diff を実行します。 * @param[in] pathLeft 左ペインに表示するファイルのパス * @param[in] pathRight 右ペインに表示するファイルのパス * @param[in] labelLeft 左ペインに表示するファイルのラベル (NULL ならパス名を使います) * @param[in] labelRight 右ペインに表示するファイルのラベル (NULL ならパス名を使います) */ void TextDiffView::ExecuteDiff(const BPath& pathLeft, const BPath& pathRight, const char* labelLeft, const char* labelRight) { // 初期化 textData[LeftPane].Unload(); textData[RightPane].Unload(); lineInfos.clear(); try { // 各ファイルを読み込み textData[LeftPane].Load(pathLeft); textData[RightPane].Load(pathRight); // diff 実行 LineSeparatedSequences seqs(&textData[LeftPane], &textData[RightPane]); NPDiff diffEngine; diffEngine.Detect(&seqs); // diff 結果から行情報を作成 int index; for (index = 0; ; index++) { const DiffOperation* diffOperation = diffEngine.GetOperationAt(index); if (NULL == diffOperation) { break; } LineInfo line; line.op = diffOperation->op; int count, maxCount; switch (diffOperation->op) { case DiffOperation::Inserted: line.textIndex[LeftPane] = -1; line.textIndex[RightPane] = diffOperation->from1; maxCount = diffOperation->count1; for (count = 0; count < maxCount; count++) { lineInfos.push_back(line); line.textIndex[RightPane]++; } break; case DiffOperation::Modified: line.textIndex[LeftPane] = diffOperation->from0; line.textIndex[RightPane] = diffOperation->from1; maxCount = (diffOperation->count0 > diffOperation->count1) ? diffOperation->count0 : diffOperation->count1; for (count = 0; count < maxCount; count++) { lineInfos.push_back(line); if (count + 1 < diffOperation->count0) { line.textIndex[LeftPane]++; } else { line.textIndex[LeftPane] = -1; } if (count + 1 < diffOperation->count1) { line.textIndex[RightPane]++; } else { line.textIndex[RightPane] = -1; } } break; case DiffOperation::Deleted: line.textIndex[LeftPane] = diffOperation->from0; line.textIndex[RightPane] = -1; maxCount = diffOperation->count0; for (count = 0; count < maxCount; count++) { lineInfos.push_back(line); line.textIndex[LeftPane]++; } break; case DiffOperation::NotChanged: line.textIndex[LeftPane] = diffOperation->from0; line.textIndex[RightPane] = diffOperation->from1; maxCount = diffOperation->count0; for (count = 0; count < maxCount; count++) { lineInfos.push_back(line); line.textIndex[LeftPane]++; line.textIndex[RightPane]++; } break; } } } catch (Exception* ex) { // TODO: なんかメッセージ出す ex->Delete(); } // ペインを調整 DiffPaneView* leftPaneView = dynamic_cast<DiffPaneView*>(FindView(NAME_LEFT_PANE)); if (NULL != leftPaneView) { leftPaneView->DataChanged(); } DiffPaneView* rightPaneView = dynamic_cast<DiffPaneView*>(FindView(NAME_RIGHT_PANE)); if (NULL != rightPaneView) { rightPaneView->DataChanged(); } // 左ペインにフォーカスを与えておく makeFocusToPane(LeftPane); }
BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9 , const T10 , const T11 , const T12>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5 , T6 const& t6 , T7 const& t7 , T8 const& t8 , T9 const& t9 , T10 const& t10 , T11 const& t11 , T12 const& t12) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5& , const T6& , const T7& , const T8& , const T9& , const T10& , const T11& , const T12&> seqs( t0 , t1 , t2 , t3 , t4 , t5 , t6 , t7 , t8 , t9 , t10 , t11 , t12); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5 , const T6 , const T7 , const T8 , const T9 , const T10 , const T11 , const T12>::type( seqs); }
BOOST_FUSION_GPU_ENABLED inline typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5>::type zip(T0 const& t0 , T1 const& t1 , T2 const& t2 , T3 const& t3 , T4 const& t4 , T5 const& t5) { fusion::vector<const T0& , const T1& , const T2& , const T3& , const T4& , const T5&> seqs( t0 , t1 , t2 , t3 , t4 , t5); return typename result_of::zip<const T0 , const T1 , const T2 , const T3 , const T4 , const T5>::type( seqs); }
void VMdEditor::updateHeaders(const QVector<VElementRegion> &p_headerRegions) { QTextDocument *doc = document(); QVector<VTableOfContentItem> headers; QVector<int> headerBlockNumbers; QVector<QString> headerSequences; if (!p_headerRegions.isEmpty()) { headers.reserve(p_headerRegions.size()); headerBlockNumbers.reserve(p_headerRegions.size()); headerSequences.reserve(p_headerRegions.size()); } // Assume that each block contains only one line // Only support # syntax for now QRegExp headerReg(VUtils::c_headerRegExp); int baseLevel = -1; for (auto const & reg : p_headerRegions) { QTextBlock block = doc->findBlock(reg.m_startPos); if (!block.isValid()) { continue; } if (!block.contains(reg.m_endPos - 1)) { qWarning() << "header accross multiple blocks, starting from block" << block.blockNumber() << block.text(); } if ((block.userState() == HighlightBlockState::Normal) && headerReg.exactMatch(block.text())) { int level = headerReg.cap(1).length(); VTableOfContentItem header(headerReg.cap(2).trimmed(), level, block.blockNumber(), headers.size()); headers.append(header); headerBlockNumbers.append(block.blockNumber()); headerSequences.append(headerReg.cap(3)); if (baseLevel == -1) { baseLevel = level; } else if (baseLevel > level) { baseLevel = level; } } } m_headers.clear(); bool autoSequence = m_config.m_enableHeadingSequence && !isReadOnly() && m_file->isModifiable(); int headingSequenceBaseLevel = g_config->getHeadingSequenceBaseLevel(); if (headingSequenceBaseLevel < 1 || headingSequenceBaseLevel > 6) { headingSequenceBaseLevel = 1; } QVector<int> seqs(7, 0); QRegExp preReg(VUtils::c_headerPrefixRegExp); int curLevel = baseLevel - 1; for (int i = 0; i < headers.size(); ++i) { VTableOfContentItem &item = headers[i]; while (item.m_level > curLevel + 1) { curLevel += 1; // Insert empty level which is an invalid header. m_headers.append(VTableOfContentItem(c_emptyHeaderName, curLevel, -1, m_headers.size())); if (autoSequence) { addHeaderSequence(seqs, curLevel, headingSequenceBaseLevel); } } item.m_index = m_headers.size(); m_headers.append(item); curLevel = item.m_level; if (autoSequence) { addHeaderSequence(seqs, item.m_level, headingSequenceBaseLevel); QString seqStr = headerSequenceStr(seqs); if (headerSequences[i] != seqStr) { // Insert correct sequence. insertSequenceToHeader(doc->findBlockByNumber(headerBlockNumbers[i]), headerReg, preReg, seqStr); } } } emit headersChanged(m_headers); updateCurrentHeader(); }