我不想在这里做任何想象.我试图在以下脚本中自动绘制一些实验数据:
print "processing: ", filename
gnuplot = Popen(gnuplot_bin,stdin = PIPE).stdin
if state_plot:
gnuplot.write( "set term x11\n".encode())
gnuplot.write( "set term png size 1920,1010 \n".encode() )
gnuplot.write( "set output \"acceleration.png\" \n".encode() )
gnuplot.write( "set xlabel \"timesteps\" \n".encode() )
gnuplot.write( "set ylabel \"acceleration\" \n".encode() )
gnuplot.write( "plot " %filename " using 1 with lines lt -1 lw 0.5 title 'X axis' \n " .encode() )
gnuplot.write( " " %filename " using 2 with lines lt 1 lw 0.5 title 'Y axis' \n " …Run Code Online (Sandbox Code Playgroud) 简要背景:我正在构建一个语义图,使用带有邻接列表的BGL有向图:
class SemanticGraph
{
public:
typedef std::shared_ptr< Node > Node_ptr;
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, Node_ptr > Graph;
typedef boost::graph_traits< Graph >::vertex_descriptor Vertex;
typedef boost::graph_traits< Graph >::edge_descriptor Edge;
Run Code Online (Sandbox Code Playgroud)
我需要做的一件事就是将一个较小的图形(子图)处理到我的主图中.
这样做,包括如果需要复制节点指针,从复制子图的顶点到主图形,如果他们不存在,而最重要的是,复制在子图中每个顶点的边缘,进入主之一,如果还没有建立.
前两个任务并不复杂.但是,我不能为我的生活,找到一种比较两个边缘的方法:
void AddSubGraph( SemanticGraph subgraph )
{
typename boost::graph_traits<Graph>::vertex_iterator it, end;
Vertex vertex;
for ( auto node : subgraph._nodes )
{
if ( !findNode( node ) )
_nodes.push_back( node );
boost::tie( it, end ) = boost::vertices( _graph );
std::find_if( it, end, [&]( const Vertex vertex ){ return _graph[*it]->Hash() == node->Hash(); …Run Code Online (Sandbox Code Playgroud) 我一直在寻找Sigmoid内核的Sigmoid函数和Sigmoid Prime实现,但我偶然发现偶然收到了对SO 的答复,其中使用了SO __fmul_rz和其他一些CUDA函数名称。因此,出于好奇,我用谷歌搜索了它们,发现它们是单精度函数,如下所示(注意:这些是针对4.1的)。
文档说这些是快速的近似值,因此直觉说它们跳过精度以提高计算速度?
以前我有:
float x = 1.f / (1.f + exp ( -1.f * input ) );
return x * ( 1.f - x );
Run Code Online (Sandbox Code Playgroud)
现在,我有:
float s = __fdividef( 1.f, (1.f + __expf(-1.f*input)));
return x = s * (1.f - s);
Run Code Online (Sandbox Code Playgroud)
我是否可以假设上述两个结果可能不同?
我试图caffee从BVLC(https://github.com/BVLC/caffe)编译,但我遇到了一个特殊的错误:
NVCC src/caffe/util/math_functions.cu
/usr/local/boost/config/suffix.hpp(510): error: identifier "__float128" is undefined
Run Code Online (Sandbox Code Playgroud)
它似乎是在运行nvcc时boost就抱怨了这种__float128类型.
我google了一下,发现了一个devtalk.nvidia论坛帖子,但我真的不明白如何解决这个问题.
我甚至打开了一个github问题,但尚未得到答复.
我在Debian 8上使用nvcc-6.5 boost 1.60和gcc-4.8.4(我手动安装了boost),违规行似乎在#510行:
506 // same again for __float128:
507 #if defined(BOOST_HAS_FLOAT128) && defined(__cplusplus)
508 namespace boost {
509 # ifdef __GNUC__
510 __extension__ typedef __float128 float128_type;
511 # else
512 typedef __float128 float128_type;
513 # endif
514 }
515 #endif
Run Code Online (Sandbox Code Playgroud)
fftw3中的类似问题似乎表明nvcc自我认同__GNUC__因此造成了他的问题?
这有什么解决方法吗?
我有点挑剔,跟进我之前的问题并使用类似于我在这里发布的代码.
visitor成语迭代它们而不是如下所示的原始缩小示例:
template <typename... Args>
void make_classes(Args... args)
{
auto t = std::tuple<Args...>(args...);
unsigned int size = std::tuple_size<decltype(t)>::value;
auto execute = [](auto & obj){ obj.operator()(); };
for (int i = 0; i < size; i++) {
visit_at(t, i, execute);
}
}
Run Code Online (Sandbox Code Playgroud)
我试图理解如何推断autolambda 的模板类型,以便我可以绑定它:
template <typename... Args>
void make_classes(Args... args)
{
auto t = std::tuple<Args...>(args...);
unsigned int size = std::tuple_size<decltype(t)>::value;
auto execute = [](auto & obj){
// obtain type …Run Code Online (Sandbox Code Playgroud) 除非我遗漏了某些东西或误解了机制(很可能)不应该在这个载体中不存在"1"重复?
chunks.erase( std::unique ( chunks.begin(), chunks.end(),
[]( std::string &s1, std::string &s2 ){
return ( s1.compare(s2) == 0 ? true : false );}),
chunks.end() );
Run Code Online (Sandbox Code Playgroud)
在执行上述之前:
1 l:1
1+ l:2
1+1 l:3
1+1= l:4
+ l:1
+1 l:2
+1= l:3
1 l:1
1= l:2
= l:1
Run Code Online (Sandbox Code Playgroud)
执行上面的代码后:
1 l:1
1+ l:2
1+1 l:3
1+1= l:4
+ l:1
+1 l:2
+1= l:3
1 l:1
1= l:2
= l:1
Run Code Online (Sandbox Code Playgroud)
我试过没有谓词(假设std ::相同的字符串将被删除).出于某种原因,"那些"被认为是相同的?我已经查看了它们的长度(假设空格被卡住作为前缀或后缀),但它们具有相同的长度.
我错过了什么吗?
我本周首次尝试建立公司iOS库/框架,遵循此博客文章中的步骤.
由于超出此问题的原因,我只能在为设备构建而不是为模拟器建立链接.
但是,现在我收到一个非常奇怪的错误:
ld:架构armv7 clang的2个重复符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
有问题的线条表明:
重复符号_OBJC_CLASS _ $ _ iContactsGridCell in:/ Users/* /Desktop/Projects/contactservice/branch/ContactServicesClient/DerivedData/iContacts/Build/Intermediates/iContacts.build/Debug-iphoneos/iContacts-5.1.build/Objects-normal/armv7/ iContactsGridCell.o /Applications/Xcode.app/Contents/Developer/Library/Frameworks/athium-iOS.framework/athium-iOS重复符号_OBJC_METACLASS _ $ _ iContactsGridCell in:/ Users/*/Desktop/Projects/contactservice/branch/ContactServicesClient/DerivedData /iContacts/Build/Intermediates/iContacts.build/Debug-iphoneos/iContacts-5.1.build/Objects-normal/armv7/iContactsGridCell.o /Applications/Xcode.app/Contents/Developer/Library/Frameworks/athium-iOS.framework/athium-IOS
显然,有问题的类是iContactsGridCell.h
该类本身继承自Cell.h
@interface iContactsGridCell : Cell
Run Code Online (Sandbox Code Playgroud)
类Cell.h是框架的一部分,如果我不输入正确的文件,然后按预期我得到一个语义错误:无法找到电池接口声明等等等等.
但是,当我导入它时,我得到以下重复错误.除了iContactsGridCell.h之外,该文件不包含在项目的任何其他位置!
反过来,文件Cell.h只是在框架下找到的一个类:
@interface Cell : NSObject
@property (strong,nonatomic) UIView *view;
@property CGRect rect;
@property int UID;
@property BOOL highlighted;
@property UIColor *b_colr;
- (id) initWithRect:(CGRect)frame;
- (BOOL) hasCoordinates:(CGPoint)coord;
- (void) ripple;
- (void) cubefy;
- (void) flipfy;
- …Run Code Online (Sandbox Code Playgroud) 我遇到了一个我无法弄清楚的特殊问题:
for ( const auto & p : _patterns )
{
auto it = std::find_if( p->Tokens().begin(),p->Tokens().end(),
[&]( const Token & lhs )
{
return ( lhs == query );
});
if ( it != p->Tokens().end() )
d_freq++;
}
Run Code Online (Sandbox Code Playgroud)
代币是:
std::vector<Token>
Run Code Online (Sandbox Code Playgroud)
并且std :: find_if lambda内部的实际运算符被定义并实现为:
bool Token::operator== ( const Token & rhs ) const
{
if ( !this->_value.empty() && !rhs._value.empty() )
{
return boost::iequals( this->_value, rhs._value );
}
else
throw
std::runtime_error ( "[Token::operator==] empty string" );
}
Run Code Online (Sandbox Code Playgroud)
运行我的调试版本只是使用SEGFAULT崩溃.
只有当我运行gdb,然后回溯时,我得到:
Program received …Run Code Online (Sandbox Code Playgroud) 我有一个graph有成员的班级:
std::vector<std::unique_ptr<layer>> _layers;
Run Code Online (Sandbox Code Playgroud)
我理解其性质std::unique_ptr是不可复制的.我的graph::graph(const graph & rhs);拷贝构造函数产生编译错误,因为我的普通实现违反了本质std::unique_ptr.
graph::graph(const graph & rhs)
: _layers(rhs._layers) {}
Run Code Online (Sandbox Code Playgroud)
如果我这样做,std::move那么我将违反param 的常量rhs,这不是我想要的.我知道我可以制作深层副本(例如,为存储的每个对象创建新的唯一指针rhs._layers)但除了迭代每个项目rhs._layers并分配新的唯一指针之外,还有一些优雅的方法吗?
gcc/g ++是c ++ 11而不是c ++ 14
我目前的解决方案是深度复制对象并分配新指针:
graph::graph(const graph & rhs)
{
for (const auto & ptr : rhs._layers)
_layers.emplace_back(std::unique_ptr<layer>(new layer(*ptr)));
}
Run Code Online (Sandbox Code Playgroud)