函数参数变量未在范围中声明

时间:2014-07-21 19:09:53

标签: c++

我试图使用奇异值分解linalg函数,但是当我尝试编译时,我得到一个错误,其中参数值由于某种原因不在范围内try块:

bool rmatrixsvd(const real_2d_array &a, const ae_int_t m, const ae_int_t n, const ae_int_t uneeded, const ae_int_t vtneeded, const ae_int_t additionalmemory, real_1d_array &w, real_2d_array &u, real_2d_array &vt)
{

alglib_impl::ae_state _alglib_env_state;
alglib_impl::ae_state_init(&_alglib_env_state);
try
{
    ae_bool result = alglib_impl::rmatrixsvd(const_cast<alglib_impl::ae_matrix*>(a.c_ptr()), temp_m, n, uneeded, vtneeded, additionalmemory, const_cast<alglib_impl::ae_vector*>(w.c_ptr()), const_cast<alglib_impl::ae_matrix*>(u.c_ptr()), const_cast<alglib_impl::ae_matrix*>(vt.c_ptr()), &_alglib_env_state);
    alglib_impl::ae_state_clear(&_alglib_env_state);
    return *(reinterpret_cast<bool*>(&result));
}
catch(alglib_impl::ae_error_type)
  {
    throw ap_error(_alglib_env_state.error_msg);
  }

}

编译时我不断收到这些错误:

linalg.cpp:1891: error: ISO C++ forbids declaration of ‘real_2d_array’ with no type
linalg.cpp:1891: error: expected ‘,’ or ‘...’ before ‘&’ token
linalg.cpp:1893: error: ‘m’ was not declared in this scope
linalg.cpp:1899: error: ‘a’ was not declared in this scope
linalg.cpp:1899: error: ‘n’ was not declared in this scope
linalg.cpp:1899: error: ‘uneeded’ was not declared in this scope
linalg.cpp:1899: error: ‘vtneeded’ was not declared in this scope
linalg.cpp:1899: error: ‘additionalmemory’ was not declared in this scope
linalg.cpp:1899: error: ‘w’ was not declared in this scope
linalg.cpp:1899: error: ‘u’ was not declared in this scope
linalg.cpp:1899: error: ‘vt’ was not declared in this scope
linalg.cpp:1905: error: ‘ap_error’ was not declared in this scope

real_2d_array是另一个头文件中定义的类。

有人可以解释为什么我会收到这些范围错误,以及为什么real_2d_array无法正常工作?

感谢。

1 个答案:

答案 0 :(得分:2)

编译器错误告诉您编译器找不到real_2d_array的定义。要取得进展,您需要弄清楚为什么认为应该定义real_2d_array,但编译器看不到该名称的任何内容。也许您未能包含必要的文件。或者可能在命名空间中定义了real_2d_array