表达式无法评估 - 为什么? [英] Expression cannot be evaluated - why?

查看:48
本文介绍了表达式无法评估 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在调试一个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


Paul

Hi everyone,
I''m debugging an FFT routine and it has thrown up a perplexing error
which I cannot trace. Cannot anyone help? I''ve included the relevant
code below with comments:

rlft3(data_in1, speq_out1,1,512,256,1); // Perform FFT on 1st set of
input data

rlft3(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 correlation

float *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 normalizing

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] has "good data"

// data_in1[1][1][1] has "good data"
// Do the same for the spectrum elements

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; // 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 FFT

Somewhere, the array data_in1 is being replaced by junk, although the
pointer value/memory address itself does not change. Whats happening?

TIA

Paul

推荐答案

pa**@paullee.com 写道:

嗨每个人,

我正在调试一个FFT例程,它抛出了一个令人困惑的错误

我无法追踪。不能有人帮忙吗?我在下面附上了相关的

代码和评论:


rlft3(data_in1,speq_out1,1,512,256,1); //对第一组

输入数据执行FFT

rlft3(data_in2,speq_out2,1,512,256,1); //现在第2集
Hi everyone,
I''m debugging an FFT routine and it has thrown up a perplexing error
which I cannot trace. Cannot anyone help? I''ve included the relevant
code below with comments:

rlft3(data_in1, speq_out1,1,512,256,1); // Perform FFT on 1st set of
input data

rlft3(data_in2, speq_out2,1,512,256,1); // Now 2nd set



你没有包含相关代码。声明

这些功能在哪里? data_in1声明为什么?什么是Speq_out?

调用者和claledd函数的定义是什么?


你似乎传递了512 256 1的大小但是你没有在功能中使用它完全没用。

什么是fac?

You''ve NOT included the relevant code. Where is the declaration
of 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 in
the function.
What is fac?


>

//注意: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]有好数据
>
// 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 correlation

float *sp1, *sp2, r, im;
sp1 = &data_in1[1][1][1];
sp2 = &data_in2[1][1][1];

// data_in1[1][1][1] has "good data"



为什么1'在这里?

Why 1''s here?


>

//循环元素乘法和规范化


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;

}
>
// Loop through elements multiplying and normalizing

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和2数组的

分配结束。

Impossible to say, but my guess is you write off the end of the
allocation of the data_in1 and 2 arrays here.


>

// 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]是垃圾 - 表达式无法评估 。
>
// data_in1[1][1][1] has "good data"

// data_in1[1][1][1] has "good data"
// Do the same for the spectrum elements

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; // Does nothing - just put here for breakpoint purposes
// data_in1[1][1][1] is junk - "Expression cannot be evaluated" .



可能是因为这个循环中有一个错误......你可能会再次在分配之外写入

Possibly because there''s a bug in this loop... again you possibly
write outside the allocation.


>

rlft3(data_in1,speq_out1,1,512,256,-1); //执行逆FFT
>
rlft3(data_in1, speq_out1, 1, 512, 256 , -1); // Do inverse FFT


这些函数中的代码是不相关的,它就在那里因为我预计有人说你想在这做什么?


我感兴趣的是介于两者之间:


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;

}


和:


rlft3(data_in1,speq_out1 ,1,512,256,-1);


data_in1数组用duff数据填充。只有没有

有改变它。我已经把断点(我正在使用VC ++ 6)和

检查数组中的数量

它们看起来很好,直到最后的rlft3之前( ...)电话。

The code in those functions isn''t relevant, its just there because I
anticipated someone saying "what are you trying to do here?"

what I''m interested in is that somewhere between:

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;
}

and:

rlft3(data_in1, speq_out1, 1, 512, 256 , -1);

the data_in1 array gets filled with duff data. Only theres nothing
there to change it. I''ve put breakdpoints in (I''m using VC++ 6) and
examined the quanities in the arrays
and they seem fine until just before the final rlft3(...) call.


pa ** @ paullee.com 写道:

这些函数中的代码是不相关的,它就在那里因为我预计会有人说什么你想在这里做什么?


我感兴趣的是介于两者之间:


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;

}


和:


rlft3(data_in1,speq_out1,1,512 ,256,-1);


data_in1数组得到fille d与duff数据。只有没有

有改变它。我已经把断点(我正在使用VC ++ 6)和

检查数组中的数量

它们看起来很好,直到最后的rlft3之前( ...)电话。
The code in those functions isn''t relevant, its just there because I
anticipated someone saying "what are you trying to do here?"

what I''m interested in is that somewhere between:

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;
}

and:

rlft3(data_in1, speq_out1, 1, 512, 256 , -1);

the data_in1 array gets filled with duff data. Only theres nothing
there to change it. I''ve put breakdpoints in (I''m using VC++ 6) and
examined the quanities in the arrays
and they seem fine until just before the final rlft3(...) call.



可能你正在编写一个数组的末尾或破坏堆栈

某处(可能在此代码被调用之前) 。你是唯一一个可以看到足够的代码来做出判断的人 - 你还没有发布
几乎足以让任何人拥有第一条线索。例如,我们

看不到data_in1等的声明,所以我们无法确定

你是否正在写任何结尾数组。


一般的评论是,从1开始的数组索引在C ++中是一个坏主意


Tom

Possibly you''re writing past the end of an array or corrupting the stack
somewhere (possibly before this code is even called). You''re the only
one who can see enough of the code to make a judgment - you haven''t
posted nearly enough for anyone to have the first clue. For example, we
can''t see declarations for data_in1 etc., so we can''t work out whether
you''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


这篇关于表达式无法评估 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆