我有一个 C++/Rcpp 函数,我需要编译并链接到 pomp 包才能访问随机数生成器。我可以得到头文件,但如何让它链接到编译后的代码?
CppColonized<-cxxfunction(
sig=signature(x="numeric", t="numeric", params="numeric", dt="numeric"),
plugin='Rcpp',
includes = sprintf("#include <Rmath.h>\n#include <math.h>\n#include\"%s\"",
base:::system.file("include/pomp.h",package="pomp")),
body=Code,verbose=T)
Run Code Online (Sandbox Code Playgroud)
该代码使用了 pomp 包中的 reulermultinom 函数,当我评估它时,它给出了错误
对 `reulermultinom(int, double, double*, double, double*) 的未定义引用
发出的命令是
g++ -I"C:/PROGRA~1/R/R-211~1.1/include" -I"C:/PROGRA~1/R/R-211~1.1/library/Rcpp/include" -O2 -Wall - c file2f752742.cpp -o file2f752742.o g++ -shared -s -static-libgcc -o file2f752742.dll tmp.def file2f752742.o C:/PROGRA~1/R/R-211~1.1/library/Rcpp/lib libRcpp.a -LC:/PROGRA~1/R/R-211~1.1/bin -lR
似乎应该有一个 -lpomp 或类似的东西。
R 中的哪些包和函数可以执行二维非加性局部回归/平滑。例如考虑
b<-seq(-6*pi,6*pi,length=100)
xy<-expand.grid(b,b)
x=xy[[1]]
y=xy[[2]]
z= sin(x)+cos(y) + 2*sin(x)*cos(y)
contour(b,b,matrix(z,100,100))
Run Code Online (Sandbox Code Playgroud)

什么函数可以估计这个?
当在ggplot2中使用qplot绘制逻辑值时,False计数总是在底部,但更多时候我想在底部使用True,以便更容易阅读.这是一个例子
y<-as.logical(rbinom(100,1,0.7))
x<-factor(rep(letters[1:2], each=50))
qplot(x,fill=y, geom='bar')
Run Code Online (Sandbox Code Playgroud)
如何在堆栈底部获取TRUE计数?
我有一个模板类,它有很多功能,但本质上是一个矢量类.我想为bool类型添加一个函数.
#include <vector>
template <typename T>
class reflected{
private:
T*dev_;
T*host_;
ar_size size;
reflected<T>& operator=(reflected<T>& rhs);//do not impliment. assign not allowed.
reflected( reflected<T>& old); //do not impliment. Copy not allowed.
public:
reflected():size(0L),dev_(NULL),host_(NULL){}
reflected(ar_size n):size(n),dev_(NULL),host_(NULL){init();}
reflected(const T*x,ar_size n):size(n),dev_(NULL),host_(NULL){init();set(x);}
~reflected();
void init();
void init(ar_size n);
void init(const T*x,ar_size n);
void set(const T * x);
void setat(ar_index i, T x);
const T getat(ar_size i);
const T * devPtr();
const T operator [](const ar_index i);
ar_size length(){return size;}
};
Run Code Online (Sandbox Code Playgroud)
我想vector<ar_index> reflected<bool>::which()在反射类的特殊情况下添加一个函数,这是唯一有意义的情况.做这个的最好方式是什么.编译器似乎不喜欢添加which()来反映并仅为bool定义它.
在分析数据时,关于变量的元数据非常重要.你如何在R中管理这些信息?
例如,有没有办法指定将打印的标签而不是变量名?
R有什么设施吗?
我有这些模板功能,可以在设备上使用cuda进行内联
template <class T> __device__ inline T& cmin(T&a,T&b){return (a<b)?(a):(b);};
template <class T> __device__ inline T& cmax(T&a,T&b){return (a>b)?(a):(b);};
Run Code Online (Sandbox Code Playgroud)
在我的代码中
cmin(z[i],y[j])-cmax(x[i],z[j])
Run Code Online (Sandbox Code Playgroud)
对于int数组x,y和z.我收到错误:
错误:没有函数模板"cmax"的实例与参数列表匹配
Run Code Online (Sandbox Code Playgroud)argument types are: (int, int)
我得到cmax但不是cmin的错误.如果我更换cmax线
#define cmax(a,b) ((a)>(b))?(a):(b)
Run Code Online (Sandbox Code Playgroud)
工作正常,但我不想#defines,他们是有问题的.到底发生了什么事?
编辑:这是完整的调用功能.times是typedef int.
__global__ void compute_integral_y_isums(times * admit, times * discharge, times * Mx, times * isums, ar_size N){
// computes the sums for each j
// blocks on j,
// threads on i since we will be summing over i.
// sumation over J should be handled by either …Run Code Online (Sandbox Code Playgroud) 我的代码中有这个.
vector<unsigned int> import;
vector<unsigned int> aquired;
. . .
size_t new_size = max(import.size(),aquired.size());
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error: more than one instance of
overloaded function "max" matches the
argument list:
function "max(int, int)"
function "max(unsigned int, unsigned int)"
function "max(int, unsigned int)"
function "max(unsigned int, int)"
function "max(long long, long long)"
function "max(unsigned long long, unsigned long long)"
function "max(long long, unsigned long long)"
function "max(unsigned long long, long long)"
function "max(float, float)"
function "max(double, double)"
function "max(float, double)"
function "max(double, float)" …Run Code Online (Sandbox Code Playgroud) 我有一个正在开发的项目,我需要测试,但它不会编译,因为我有未引用的变量,并启用该选项将所有警告变成错误.我用google搜索它,看到应该有一个我找不到的构建页面.帮助我在哪里关闭它?

我正在编写一个包含4个嵌套for循环的算法.问题是在每个级别更新指针.最里面的循环只使用其中一个指针.该算法执行复杂的计数.当我包含一个记录索引组合和计数结果的调试语句时,我得到了正确的答案.省略debugging语句时,计数不正确.该程序使用gcc上的-O3选项进行编译.为什么会这样?