【问题标题】:unable to determine cause of "no match for 'operator<'" compilation error无法确定“'operator<'不匹配”编译错误的原因
【发布时间】:2010-09-24 03:32:20
【问题描述】:

我正在使用 CodeSourcery 的 implementation 的矢量信号图像处理库 (vsipl++)。我写了一个函数,应该返回[I + a*A]^-1 B,其中I是单位矩阵,A和B是兼容的方阵,如下:

namespace vsipl {

template< class T1, class T2, class O1, class O2, class L1, class L2,
     template< dimension_type, class, class, class > class B1,
     template< dimension_type, class, class, class > class B2 >
Matrix< typename Promotion< T1, T2 >::type, 
        B1< 2, typename Promotion< T1, T2 >::type, O1, L1 > > 
inv_mult( typename Promotion< T1, T2 >::type a, 
       Matrix< T1, B1< 2, T1, O1, L1 > > const& A,
       Matrix< T2, B2< 2, T2, O2, L2 > > const& B
     ) 
{
 typedef typename Promotion< T1, T2 >::type value_type;
 typedef Matrix< value_type, B1< 2, value_type, O1, L1 > > ret_type;
 typedef lud< value_type, by_reference > lud_type;

 ret_type ret(A.size(0),A.size(1),0), denom(A.size(0),A.size(1),0);

 //I + a*A
 denom.diag() = 1;
 denom = denom + a*A;

 lud_type ld( denom.size() );
 ld.decompose( denom );

 //as a side effect of using LAPACK as a back end, this requires a template
 //param to indicate precisely what is being solved.
 ld.solve< mat_ntrans >( B, ret );  // <--- Line generating error.

 return ret;
}//inv_mult
}//vsipl

需要明确的是,在 vsipl++ 中,矩阵接受两个参数:一个类型和一个描述信息如何存储的块。该块是上面的模板汤的原因。此外,lud 对象对矩阵 A 执行 LU 分解,然后使用 A 的分解形式求解 Ax = b。

当我尝试使用 gcc(MacOs 10.6 上的 4.2.1 和 Fedora 9 上的 4.3.0)编译它时,我收到以下错误

error: no match for 'operator<' in 'ld.vsip::lud<T, by_reference>::solve [with 
 vsip::mat_op_type tr = tr, Block0 = Block0, Block1 = Block1, T = double] < mat_ntrans

我尝试通过消除类型 Promotion 来简化代码,需要单个数据和块类型,但我得到了同样的错误。

有什么想法吗?

【问题讨论】:

    标签: c++ templates matrix


    【解决方案1】:

    试试

    ld.template solve< mat_ntrans >
    

    explanation,因为同样的事情让我抓狂

    【讨论】:

    • 谢谢。我记得在某个时候读过它,但我从来没有想过这是问题所在。而且,是的,这也让我发疯了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-06
    • 2011-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多