Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading num_threads子句的用户错误1001参数必须为正_Multithreading_K Means_Flann - Fatal编程技术网

Multithreading num_threads子句的用户错误1001参数必须为正

Multithreading num_threads子句的用户错误1001参数必须为正,multithreading,k-means,flann,Multithreading,K Means,Flann,我正在使用vcpkg的flann。代码给出了正确的输出。但是它也在打印此错误语句用户错误1001:num_threads子句的参数必须为正。我读过这篇文章,人们只建议使用setNumberOfThreads(正数),也就是说,给线程数一个正数。但在我的代码中没有OMP的实现或任何并行性,甚至我也找不到任何地方可以为flann库中的线程数指定正数。有人能帮我解决这个问题吗。提前谢谢 Output - User Error 1001: argument to num_threads

我正在使用vcpkg的flann。代码给出了正确的输出。但是它也在打印此错误语句用户错误1001:num_threads子句的参数必须为正。我读过这篇文章,人们只建议使用setNumberOfThreads(正数),也就是说,给线程数一个正数。但在我的代码中没有OMP的实现或任何并行性,甚至我也找不到任何地方可以为flann库中的线程数指定正数。有人能帮我解决这个问题吗。提前谢谢

    Output -
    User Error 1001: argument to num_threads clause must be positive
     2 34
     3 34
     1 41

 CODE
 #define _CRT_SECURE_NO_WARNINGS
 #include <iostream>
 #include<fstream>
 #include<vector>
 #include"rapidcsv.h"
 #include<iomanip>
 #include "flann/flann.h"

 float* read_points(const char* filename, int rows, int cols) {
float* data;
float *p;
FILE* fin;
int i, j;

fin = fopen(filename, "r");
if (!fin) {
    printf("Cannot open input file.\n");
    exit(1);
}

data = (float*)malloc(rows*cols * sizeof(float));
if (!data) {
    printf("Cannot allocate memory.\n");
    exit(1);
}
p = data;

for (i = 0; i < rows; ++i) {
    for (j = 0; j < cols; ++j) {
        fscanf(fin, "%g ", p);
        p++;
    }
}

fclose(fin);

return data;
 }

 using namespace std;
 int main()
 {
int rows = 4, cols = 2, t_rows = 1, t_cols = 2;
double ds[8] = { 788674.31,6786348.08 , 788675.31,6786348.08,788676.31,6786348.08,788676.31,6786348.08 };
ofstream dsq("dataset.dat");
dsq << setprecision(10) << ds[0] << " " << setprecision(10) << ds[1] << endl;
dsq << setprecision(10) << ds[2] << " " << setprecision(10) << ds[3] << endl;
dsq << setprecision(10) << ds[4] << " " << setprecision(10) << ds[5] << endl;
dsq << setprecision(10) << ds[6] << " " << setprecision(10) << ds[7] << endl;

double ts[2] = { 788679.31 , 6786343.08 };
ofstream tsq("testset.dat");
tsq << setprecision(10) << ts[0] << " " << setprecision(10) << ts[1] << endl;

// read dataset points from file dataset.dat
float* dataset = read_points("dataset.dat", rows, cols);
float* testset = read_points("testset.dat", t_rows, t_cols);

// points in dataset and testset should have the same dimensionality
assert(cols == t_cols);
// number of nearest neighbors to search
int nn = 3;
// allocate memory for the nearest-neighbors indices
int* result = new int[t_rows*nn];
// allocate memory for the distances
float* dists = new float[t_rows*nn];

// index parameters are stored here
struct FLANNParameters p = DEFAULT_FLANN_PARAMETERS;

// the rest of the parameters are automatically computed
//p.target_precision = 0.9;
p.algorithm = FLANN_INDEX_KMEANS;
p.centers_init = FLANN_CENTERS_KMEANSPP;
// compute the 3 nearest-neighbors of each point in the testset
//#pragma warning(push)
//#pragma warning(disable: 1001)
// here goes your code where the warning occurs
flann_find_nearest_neighbors(dataset, rows, cols, testset, t_rows, result, dists, nn, &p);
//#pragma warning(pop)
for (int i = 0; i < (t_rows*nn); i++) {
    cout << result[i] << " " << dists[i] << endl;
}
delete[] dataset;
delete[] testset;
delete[] result;
delete[] dists;
输出-
用户错误1001:num_threads子句的参数必须为正
2 34
3 34
1 41
代码
#定义\u CRT\u安全\u无\u警告
#包括
#包括
#包括
#包括“rapidcsv.h”
#包括
#包括“法兰/法兰h”
浮点*读取点(常量字符*文件名、整数行、整数列){
浮动*数据;
浮动*p;
文件*fin;
int i,j;
fin=fopen(文件名为“r”);
如果(!fin){
printf(“无法打开输入文件。\n”);
出口(1);
}
数据=(浮点*)malloc(行*cols*sizeof(浮点));
如果(!数据){
printf(“无法分配内存。\n”);
出口(1);
}
p=数据;
对于(i=0;i