I am stumped. It's allocating float* variables, but I cannot seem to convert this to float.
threadprobs_[index0] = probs[0] + (size_t)(threadstart - start) * num_samples_use;
threadprobs_[index1] = probs[1] + (size_t)(threadstart - start) * num_samples_use;
The whole code for the function is:
int read_data_fly(char* datafile, int dtype, double* data, float** probs,
int num_samples_use, int* keepsamps, int start, int end,
int* keeppreds_use, gzFile inputgz, size_t current,
int num_samples, int num_preds, int genskip, int genheaders,
int genprobs, size_t* bgen_indexes, double missingvalue,
double threshold, double minprob, int nonsnp,
int maxthreads)
{
int thread;
int threadstart;
int threadend;
int threadlength;
// float*** threadprobs;
vector<float> threadprobs_;
if (dtype == 1 || dtype == 2 || dtype == 3 ||
dtype == 4) // can read in parallel
{
threadlength = (end - start - 1) / maxthreads + 1;
if (dtype == 2) {
//threadprobs = malloc(sizeof(float**) * maxthreads);
threadprobs_.resize(maxthreads);
}
#pragma omp parallel for private(thread, threadstart, threadend) schedule(static, 1)
for (thread = 0; thread < maxthreads; thread++) {
;
threadstart = start + thread * threadlength;
threadend = start + (thread + 1) * threadlength;
if (threadend > end) {
threadend = end;
}
if (dtype == 1) {
read_bed_fly(
datafile, data + (size_t)(threadstart - start) * num_samples_use,
num_samples_use, keepsamps, threadend - threadstart,
keeppreds_use + threadstart, num_samples, num_preds, missingvalue);
}
if (dtype == 2) {
if (probs == NULL) {
read_bgen_fly(datafile,
data + (size_t)(threadstart - start) * num_samples_use,
NULL, num_samples_use, keepsamps, threadstart,
threadend, keeppreds_use, num_samples, num_preds,
bgen_indexes, missingvalue, threshold, minprob);
}
else {
//threadprobs[thread] = malloc(sizeof(float*) * 2);
size_t index0 = thread * threadprobs_.size() + 0;
size_t index1 = thread * threadprobs_.size() + 1;
threadprobs_.resize(threadprobs_.size() * 2);
//threadprobs_[thread][0] =
// probs[0] + (size_t)(threadstart - start) * num_samples_use;
//
//threadprobs_[thread][1] =
// probs[1] + (size_t)(threadstart - start) * num_samples_use;
const float* ptr1 = &threadprobs_[0];// +column_number * size_x * size_y];
const float** ptr2 = &ptr1;
// These fail because the righthand side is a float*
threadprobs_[index0] = probs[0] + (size_t)(threadstart - start) * num_samples_use;
threadprobs_[index1] = probs[1] + (size_t)(threadstart - start) * num_samples_use;
//read_bgen_fly(
// datafile, data + (size_t)(threadstart - start) * num_samples_use,
// threadprobs_[index0], num_samples_use, keepsamps, threadstart,
// threadend, keeppreds_use, num_samples, num_preds, bgen_indexes,
// missingvalue, threshold, minprob);
read_bgen_fly(
datafile, data + (size_t)(threadstart - start) * num_samples_use,
ptr2, num_samples_use, keepsamps, threadstart,
threadend, keeppreds_use, num_samples, num_preds, bgen_indexes,
missingvalue, threshold, minprob);
//free(threadprobs[thread]);
}
}
if (dtype == 3) {
read_sped_fly(
datafile, data + (size_t)(threadstart - start) * num_samples_use,
num_samples_use, keepsamps, threadstart, threadend, keeppreds_use,
num_samples, num_preds, missingvalue, threshold, nonsnp);
}
if (dtype == 4) {
read_speed_fly(
datafile, data + (size_t)(threadstart - start) * num_samples_use,
num_samples_use, keepsamps, threadstart, threadend, keeppreds_use,
num_samples, num_preds, missingvalue, threshold, nonsnp);
}
}
if (dtype == 2) {
// free(threadprobs);
}
}
if (dtype == 5) {
(void)read_gen_fly(datafile, data, probs, num_samples_use, keepsamps, start,
end, keeppreds_use, inputgz, current, num_samples,
num_preds, genskip, genheaders, genprobs, missingvalue,
threshold, minprob, nonsnp);
}
return (current + end);
}