ADB PolymerPropsAd::polymerWaterVelocityRatio(const ADB& c) const { const int nc = c.size(); V mc(nc); V dmc(nc); for (int i = 0; i < nc; ++i) { double m = 0; double dm = 0; polymer_props_.computeMcWithDer(c.value()(i), m, dm); mc(i) = m; dmc(i) = dm; } ADB::M dmc_diag(dmc.matrix().asDiagonal()); const int num_blocks = c.numBlocks(); std::vector<ADB::M> jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { jacs[block] = dmc_diag * c.derivative()[block]; } return ADB::function(std::move(mc), std::move(jacs)); }
void helpBrowser::processPrintAll() { // to print all we prune the individual html help files by hand and then // concatenate them QRegExp head("<html>.*</head>"); QRegExp next("Next: *<a.*\\n"); next.setMinimal(true); QRegExp top("Top: *<a.*\\n"); top.setMinimal(true); QRegExp previous("Previous: *<a.*\\n"); previous.setMinimal(true); QRegExp foot("</body>.*"); QRegExp newUser("<h1>New User.*</p>"); newUser.setMinimal(true); QRegExp dmc("<h1>A Note On DMC.*</p>"); dmc.setMinimal(true); QString overview(::readTextFile(":/overview.html")); overview.replace(next, "").replace(top, "").replace(previous, "").replace(foot, ""); QString colorChooser(::readTextFile(":/colorChooser.html")); colorChooser.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "").replace(newUser, "").replace(dmc, ""); QString colorcompare(::readTextFile(":/colorCompare.html")); colorcompare.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, ""); QString square(::readTextFile(":/square.html")); square.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, ""); QString pattern(::readTextFile(":/pattern.html")); pattern.replace(head, "").replace(top, "").replace(previous, "").replace(next, ""); QString newText(overview + colorChooser + colorcompare + square + pattern); QPrinter printer; //printer.setOutputFileName("helpOutAll.pdf"); QPrintDialog printDialog(&printer, this); const int dialogReturnCode = printDialog.exec(); if (dialogReturnCode == QDialog::Accepted) { QTextEdit editor(newText); editor.print(&printer); } }