我有一个简单的问题,即将所有元素相互比较.比较本身是对称的,因此,它不必进行两次.
以下代码示例通过显示所访问元素的索引来显示我要查找的内容:
int n = 5;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
printf("%d %d\n", i,j);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
0 1
0 2
0 3
0 4
1 2
1 3
1 4
2 3
2 4
3 4
Run Code Online (Sandbox Code Playgroud)
因此每个元素相互比较一次.当我想并行化这段代码时,我遇到的问题是首先我必须坚持动态调度,因为每次迭代的计算时间确实变化很大而且我不能使用崩溃,因为嵌套迭代是索引 - 依赖于外循环.
使用#pragma omp parallel for schedule(dynamic, 3)对于外环可导致在最后单个核心执行而使用此用于内部循环可能导致外循环的每次迭代内,处决.
是否有更复杂的做/并行化方式?
尽管图表足够宽(轴线样式),但以下图表的外列被截断。设置图表的宽度也无济于事。任何的想法?增加条宽时需要设置或放大什么?
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=0.6cm,
tick align=inside,
major grid style={draw=white},
enlarge y limits={value=.1,upper},
ymin=0, ymax=100,
axis x line*=bottom,
axis y line*=right,
hide y axis,axis line style={shorten >=-15pt, shorten <=-15pt},
symbolic x coords={Total, Women, Men},
xtick=data,
nodes near coords={\pgfmathprintnumber[precision=0]{\pgfplotspointmeta} }
]
\addplot [draw=none, fill=blue!30] coordinates {
(Total,75.4064)
(Women, 72.7961)
(Men,94.4597) };
\addplot [draw=none,fill=red!30] coordinates {
(Total,75.4064)
(Women, 89.7961)
(Men,94.4597) };
\addplot [draw=none, fill=green!30] coordinates {
(Total,75.4064)
(Women, 89.7961)
(Men,94.4597) };
\legend{}
\end{axis}
\end{tikzpicture}
Run Code Online (Sandbox Code Playgroud)
我已阅读此主题的其他帖子,但尚未找到解决此问题的方法.这是我的代码,简化为裸功能:
<?php
$password = "YS7Wde5s";
$hashA = password_hash($password, PASSWORD_BCRYPT);
echo $hashA . "<br>";
// Copied from echo above
$hashB = "$2y$10$nltCAZhbMD2OILgq2ftWNOd6kJL8oidQ12CLEM5Gi1kIj5GxKtNhm";
if (password_verify($password, $hashA)) {
echo "yes";
} else {
echo "no";
}
?>
Run Code Online (Sandbox Code Playgroud)
上面的代码适用$hashA于验证密码.但:
$hashA每当我重新加载页面时,echo 返回一个不同的哈希.$hashB,并使用它代替$hashA,我永远不会得到真正的password_verify呼叫.我错过了什么?是否存在我不知道的隐式类型转换?或者我应该如何工作?