我试图在亚马逊EC2上安装RcppEigen(在t1.micro上确保它有效)和ubuntu 13.04.我尝试了两个R版本是2.15.2和3.0,32位ubuntu和64位ubuntu.任何时候我得到以下内容:
root@ip-10-224-4-239:/home/ubuntu# R CMD INSTALL RcppEigen_0.3.1.2.1.tar.gz
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c RcppEigen.cpp -o RcppEigen.o
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -O2 -pipe -g -c fastLm.cpp -o fastLm.o
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
make: …Run Code Online (Sandbox Code Playgroud) 有点奇怪:
我正在尝试将矩阵的整行设置为0,并且eigen中的四个明显构造都不会编译:
//U is a p by p matrix. I wanna set its last column to 0.0f
U=solved.eigenvectors();
U.row(p-1).array()=0; //don't compile
U.row(p-1).setZero(1,p); //don't compile
U.row(p-1).array().setZero(p); //don't compile
U.bottomRows(1).setZero(p); //don't compile
Run Code Online (Sandbox Code Playgroud)
我还尝试了这些主题的其他变体,但都没有通过编译器
最近,用户@Mooing Duck设计concatenated_range了一个优雅的自定义迭代器,解决了"链接"两个迭代器的问题.
它适用于它的预期用途:
auto range0=concatenate_ranges(x,x+i-1,x+i,x+a5+1);
a6=foo(range0.first,range0.second);
Run Code Online (Sandbox Code Playgroud)
现在,我想通过做(示例#2)来适应它:
auto range0=concatenate_ranges(x+a5+1,x+i-1,x+i+1,x+n);
a6=foo(std::reverse_iterator<float*>(range0.second),std::reverse_iterator<float*>(range0.first));
Run Code Online (Sandbox Code Playgroud)
毋庸置疑,编译器并不开心.另一种选择(不确定订购是否在这里):
auto range0=concatenate_ranges(std::reverse_iterator<float*>(x+n),x+i+1,x+i-1,std::reverse_iterator<float*>(x+a5[i]+1));
a6=foo(range0.first,range0.second);
Run Code Online (Sandbox Code Playgroud)
不被认为是理所当然的:(.
我的问题是:我怎样才能适应concatenate_ranges()它的输出可以输入std::reverse_iterator(如上面的第二个例子).另外,boost::如果它让事情变得更容易,我不介意使用.
用户@Jack报告原始答案中的链接不显示他的代码.我不知道这个问题有多普遍,所以为了清楚起见,我重现了我在这里提到的代码(请参考原始答案的解释):
#include <boost/iterator/iterator_facade.hpp>
#include <iterator>
#include <cassert>
template<class base>
class concatenated_range_iterator
: public boost::iterator_facade<
concatenated_range_iterator<base>,
typename std::iterator_traits<base>::value_type,
typename std::iterator_traits<base>::iterator_category,
typename std::iterator_traits<base>::reference,
typename std::iterator_traits<base>::difference_type
>
{
public:
typedef typename std::iterator_traits<base>::iterator_category iterator_category;
typedef typename std::iterator_traits<base>::value_type value_type;
typedef typename std::iterator_traits<base>::difference_type difference_type;
typedef typename std::iterator_traits<base>::pointer pointer;
typedef typename std::iterator_traits<base>::reference reference;
concatenated_range_iterator() = default;
concatenated_range_iterator(bool begin, base begin1, base end1, …Run Code Online (Sandbox Code Playgroud) 我正在玩LowRankQP()R中的软件包,甚至设置verbose=FALSE仍会产生大量输出(参见下面的示例).
输出来自代码的编译部分.R中是否有一种方法(包装函数?)在不修改底层编译代码的情况下调用LowRankQP()绝对静音(即不在屏幕上打印任何内容)(与此软件包关联的电子邮件地址仍未激活)?
library(LowRankQP)
Vmat <- matrix(0,6,6)
diag(Vmat) <- c(1, 1,1,0,0,0)
dvec <- c(0,-5,0,0,0,0)
Amat <- matrix(c(-4,-3,0,-1,0,0,2,1,0,0,-1,0,0,-2,1,0,0,-1),6,3)
bvec <- c(-8,2,0)
uvec <- c(100,100,100,100,100,100)
aa<-LowRankQP(Vmat,dvec,t(Amat),bvec,uvec,method="CHOL")
# LowRankQP CONVERGED IN 15 ITERATIONS
#
# Primal Feasibility = 2.5719308e-16
# Dual Feasibility = 7.1949984e-16
# Complementarity Value = 3.3066705e-11
# Duality Gap = 3.3065273e-11
# Termination Condition = 9.7802929e-12
Run Code Online (Sandbox Code Playgroud)
这是我想要的"LowRankQP收敛于15次迭代"的部分.
Ubuntu 11.04,R版本2.12.1和LowRankQP()1.0.1.
Kdevelop 维基说(页面底部)
\n\n*对于在配置构建工具链后 KDevelop 仍然无法正确确定包含路径的情况,您可以手动将每个目录的包含路径添加到 .kdev_include_paths 文件中。这可以从 KDevelop 内部通过运行与“无法找到包含文件”问题相关的“解决问题”向导来完成,例如通过悬停有问题的 #include 行。*
\n\n现在,我已经做到了这一点(并且不再有任何有问题的、下划线的、#include 行)。但是当我尝试构建时,我得到:
\n\n~/projects/mqncpptest/build> make\n[100%] Building CXX object CMakeFiles/mqncpptest.dir/main.cpp.o\n~/projects/mqncpptest/main.cpp:15:23: fatal error: Eigen/Dense: No such file or directory\ncompilation terminated.\nRun Code Online (Sandbox Code Playgroud)\n\n用户 B\xd0\x88\xd0\xbe\xd0\xb2\xd0\xb8\xd1\x9b 询问更多信息:
\n\n我按照 KDEvelop 指令进行了最小编译。项目 -> 从模板新建 -> 标准(基于简单 C make 的 C++ 应用程序)。版本控制系统为“无”,cmake 目录为:/usr/bin/cmake。然后KDEvelop下划线#include <Eigen/Dense>,我点击屏幕下端弹出的“添加自定义包含路径”,输入特征路径,它删除了下划线#include <Eigen/Dense>,然后构建,然后我得到了/home/kaveh/projects/mqn_get/main.cpp:15:23: fatal error: Eigen/Dense: No such file or directory。我应该补充一点,这段代码在 Eclipse 和 shell 中构建都没有问题。
动机:我尝试在 kdevelop 下构建它,因为我需要使用调试器(代码没有给出预期的结果)并且 Eclipse 太重了。
\n所以,我有这个循环的C++代码:
for(i=0;i<(m-1);i++) N4[i]=(i+m-1-Rigta[i]-1-N3[i])/N0;
Run Code Online (Sandbox Code Playgroud)
涉及的所有数量都是int.从GCC的矢量化报告中我得到:
babar.cpp:233: note: ===== analyze_loop_nest =====
babar.cpp:233: note: === vect_analyze_loop_form ===
babar.cpp:233: note: === get_loop_niters ===
babar.cpp:233: note: not vectorized: number of iterations cannot be computed.
babar.cpp:233: note: bad loop form.
Run Code Online (Sandbox Code Playgroud)
我想知道为什么'无法计算迭代次数'!?FWIW,m被宣布为
const int& m.更令人费解的是,我所拥有的代码与上面相同:
for(i=1;i<(m-1);i++) a2[i]=(x[i]+x[i+m-1])*0.5f;
Run Code Online (Sandbox Code Playgroud)
以上的循环被矢量化就好了(这里a2和x是floats).我正在编译
-Ofast -ftree-vectorizer-verbose=10 -mtune=native -march=native
Run Code Online (Sandbox Code Playgroud)
在i7上的GCC 4.8.1上的标志.
提前致谢,
在@nodakai的想法之后,我尝试了这个:
const int mm = m;
for(i=0;i<(m-1);i++) N4[i]=(i+m-1-Rigta[i]-1-N3[i])/N0;
Run Code Online (Sandbox Code Playgroud)
这不会让我安静下来:
babar.cpp:234: note: not vectorized: relevant stmt not supported: D.55255_812 = D.55254_811 …Run Code Online (Sandbox Code Playgroud) 我在这里画了一个空白:How do you Sample with replacement in C++(not using boost),但所有成员都std::可以。我的意思是方法是什么(或者如果我们可以扭转成员std::来做到这一点,那么函数是什么)。
为了提供一些上下文,我想从双精度数组中采样(带替换 )k元素。Data[n]n
所以我有许多带有3列分类变量的pandas数据框:
D F False
T F False
D F False
T F False
Run Code Online (Sandbox Code Playgroud)
第一列和第二列可以采用三个值中的一个.第三个是二进制.因此总共有18个可能的行(并非所有组合都可以在每个数据帧上表示).
我想为每一行分配一个数字1-18,以便具有相同组合因子的行被赋予相同的数字,反之亦然(没有哈希冲突).
在熊猫中最有效的方法是什么?
所以,all_combination_df是一个df与所有可能的因素组合.我试图将df转换为big_df 具有唯一数字的系列
import pandas, itertools
def expand_grid(data_dict):
"""Create a dataframe from every combination of given values."""
rows = itertools.product(*data_dict.values())
return pandas.DataFrame.from_records(rows, columns=data_dict.keys())
all_combination_df = expand_grid(
{'variable_1': ['D', 'A', 'T'],
'variable_2': ['C', 'A', 'B'],
'variable_3' : [True, False]})
big_df = pandas.concat([all_combination_df, all_combination_df, all_combination_df])
Run Code Online (Sandbox Code Playgroud)