在 C++ 中查找局部极值
Find local extrema in c++
我试图在根直方图中找到局部极值。我的想法是将垃圾箱内容放在数组中并使用 pesistence1d 类。
第一步是创建一个简单的float
数组并使用该类,使用以下简单代码
#include "persistence1d.hpp"
using namespace std;
using namespace p1d;
int main()
{
float y[3] = {2,1,2};
//cout << y[0] << y[1] << y[2] << endl;
//Run persistence on data - this is the main call.
Persistence1D p;
p.RunPersistence(y);
return 0;
}
问题是当我使用 g++ extrema.cpp
编译此代码时,出现以下错误
extrema.cpp: In function ‘int main()’:
extrema.cpp:20: error: no matching function for call to ‘p1d::Persistence1D::RunPersistence(float [3])’
persistence1d.hpp:128: note: candidates are: bool p1d::Persistence1D::RunPersistence(const std::vector<float, std::allocator<float> >&)
我不明白为什么会发生此错误!任何想法或建议将非常受欢迎!
尝试传递向量而不是数组:
std::vector<float> y;
y.push_back(2); y.push_back(1); y.push_back(2);
Persistence1D p;
p.RunPersistence(y);
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 在C++中查找文件
- 模板元程序查找相似的连续类型名称
- 在UNIX系统中使用DIR查找文件的字节大小
- 查找最接近的大于当前数字的数字的索引
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 查找后更改类变量
- 使用正则表达式regex_search在字符串中查找字符串
- 使用gcc从静态链接的文件中查找可选符号
- 在C++中查找范围的长度
- 算法问题:查找从堆栈中弹出的所有序列
- 在Windows中查找扬声器输出的当前音量级别
- 如何在C++中使用X509证书模在令牌中查找私钥
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在 for 循环中查找问题时遇到困难
- 如何在文件中查找字节序列
- 试图创建一个多线程程序来查找0-100000000之间的总素数
- 使用堆查找第K个最大元素的时间复杂性
- 你能用一个函数局部类作为谓词来查找if吗