本文介绍了表达式无法评估 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我正在调试一个FFT例程,它抛出了一个令人困惑的错误 我无法追踪。不能有人帮忙吗?我在下面附上了相关的 代码和评论: rlft3(data_in1,speq_out1,1,512,256,1); //对第一组 输入数据执行FFT rlft3(data_in2,speq_out2,1,512,256,1); //现在第2集 //注意:data_in1 / 2,speq_out1 / 2从1开始索引 // data_in *是3D数组,speq_out *是2D数组 // data_in1 [1] [1] [1]有好数据 //现在做阶段相关性 float * sp1,* sp2,r,im; sp1 =& data_in1 [1] [1] [1]; sp2 =& data_in2 [1] [1] [1]; // data_in1 [1] [1] [1]具有良好数据 //循环元素乘法和规范化 for(int j = 1; j< =(1 * 512 * 256)/ 2; j ++) { r = sp1 [0] * sp2 [0] + sp1 [1] * sp2 [1]; im = sp1 [ 1] * sp2 [0] - sp1 [0] * sp2 [1]; sp1 [0] = fac * r / sqrt(r * r + im * im); sp2 [1] = fac * im / sqrt(r * r + im * im); sp1 + = 2; sp2 + = 2; } // data_in1 [1] [1] [1]有好数据 / / data_in1 [1] [1] [1]具有良好数据 //为频谱元素做同样的事情/> sp1 =& speq_out1 [1] [1]; sp2 =& speq_out2 [1] [1]; for(j = 1; j< = 1024; j ++) { r = sp1 [0] * sp2 [0] + sp1 [1] * sp2 [1]; im = sp1 [1] * sp2 [0] - sp1 [0] * sp2 [1]; sp1 [0] = fac * r / sqrt(r * r + im * im); sp2 [1] = fac * im / sqrt(r * r + im * im); sp1 + = 2; sp2 + = 2; } int ab = 1; //什么也没做 - 只是为了断点而放在这里 // data_in1 [1] [1] [1]是垃圾 - 表达式无法评估 。 rlft3(data_in1,speq_out1,1,512,256,-1); //做逆FFT 某处,数组data_in1正被垃圾替换,尽管 指针值/内存地址本身不会改变。发生了什么事? TIA PaulHi everyone,I''m debugging an FFT routine and it has thrown up a perplexing errorwhich I cannot trace. Cannot anyone help? I''ve included the relevantcode below with comments:rlft3(data_in1, speq_out1,1,512,256,1); // Perform FFT on 1st set ofinput datarlft3(data_in2, speq_out2,1,512,256,1); // Now 2nd set// NB: data_in1/2, speq_out1/2 are indexed from 1// data_in* are 3D arrays, speq_out* are 2D arrays// data_in1[1][1][1] has "good data"// Now do phase correlationfloat *sp1, *sp2, r, im;sp1 = &data_in1[1][1][1];sp2 = &data_in2[1][1][1];// data_in1[1][1][1] has "good data"// Loop through elements multiplying and normalizingfor (int j=1;j<=(1*512*256)/2; j++){r = sp1[0]*sp2[0] + sp1[1]*sp2[1];im = sp1[1]*sp2[0] - sp1[0]*sp2[1];sp1[0] = fac*r/sqrt(r*r + im*im);sp2[1] = fac*im/sqrt(r*r + im*im);sp1+=2;sp2+=2;}// data_in1[1][1][1] has "good data"// data_in1[1][1][1] has "good data"// Do the same for the spectrum elementssp1 = &speq_out1[1][1];sp2 = &speq_out2[1][1];for (j=1;j<=1024; j++){r = sp1[0]*sp2[0] + sp1[1]*sp2[1];im = sp1[1]*sp2[0] - sp1[0]*sp2[1];sp1[0] = fac*r/sqrt(r*r + im*im);sp2[1] = fac*im/sqrt(r*r + im*im);sp1+=2;sp2+=2;}int ab=1; // Does nothing - just put here for breakpoint purposes// data_in1[1][1][1] is junk - "Expression cannot be evaluated" .rlft3(data_in1, speq_out1, 1, 512, 256 , -1); // Do inverse FFTSomewhere, the array data_in1 is being replaced by junk, although thepointer value/memory address itself does not change. Whats happening?TIAPaul推荐答案 你没有包含相关代码。声明 这些功能在哪里? data_in1声明为什么?什么是Speq_out? 调用者和claledd函数的定义是什么? 你似乎传递了512 256 1的大小但是你没有在功能中使用它完全没用。 什么是fac?You''ve NOT included the relevant code. Where is the declarationof these functions. What is data_in1 declared as? What is Speq_out?What are the definitions both in the caller and the claledd function?You seem to pass in the size 512 256 1 but you don''t use it at all inthe function.What is fac? 为什么1'在这里?Why 1''s here? 不可能说,但我的猜测是你在这里注销data_in1和2数组的 分配结束。Impossible to say, but my guess is you write off the end of theallocation of the data_in1 and 2 arrays here. 可能是因为这个循环中有一个错误......你可能会再次在分配之外写入。Possibly because there''s a bug in this loop... again you possiblywrite outside the allocation. 可能你正在编写一个数组的末尾或破坏堆栈 某处(可能在此代码被调用之前) 。你是唯一一个可以看到足够的代码来做出判断的人 - 你还没有发布几乎足以让任何人拥有第一条线索。例如,我们 看不到data_in1等的声明,所以我们无法确定 你是否正在写任何结尾数组。 一般的评论是,从1开始的数组索引在C ++中是一个坏主意 TomPossibly you''re writing past the end of an array or corrupting the stacksomewhere (possibly before this code is even called). You''re the onlyone who can see enough of the code to make a judgment - you haven''tposted nearly enough for anyone to have the first clue. For example, wecan''t see declarations for data_in1 etc., so we can''t work out whetheryou''re writing off the end of any of the arrays.One general comment is that array indexing from 1 is a bad idea in C++(and in programming in general IMHO).Tom 这篇关于表达式无法评估 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!