Fix usage of "Index" as a compile time integral.

This commit is contained in:
Gael Guennebaud 2015-12-10 12:01:06 +01:00
parent f248249c1f
commit 75f0fe3795

View File

@ -107,32 +107,32 @@ struct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,Dynamic>
* meta-unrolling implementation * meta-unrolling implementation
***************************************************************************/ ***************************************************************************/
template<typename Lhs, typename Rhs, int Mode, int Index, int Size, template<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size,
bool Stop = Index==Size> bool Stop = LoopIndex==Size>
struct triangular_solver_unroller; struct triangular_solver_unroller;
template<typename Lhs, typename Rhs, int Mode, int Index, int Size> template<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size>
struct triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> { struct triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex,Size,false> {
enum { enum {
IsLower = ((Mode&Lower)==Lower), IsLower = ((Mode&Lower)==Lower),
RowIndex = IsLower ? Index : Size - Index - 1, RowIndex = IsLower ? LoopIndex : Size - LoopIndex - 1,
S = IsLower ? 0 : RowIndex+1 S = IsLower ? 0 : RowIndex+1
}; };
static void run(const Lhs& lhs, Rhs& rhs) static void run(const Lhs& lhs, Rhs& rhs)
{ {
if (Index>0) if (LoopIndex>0)
rhs.coeffRef(RowIndex) -= lhs.row(RowIndex).template segment<Index>(S).transpose() rhs.coeffRef(RowIndex) -= lhs.row(RowIndex).template segment<LoopIndex>(S).transpose()
.cwiseProduct(rhs.template segment<Index>(S)).sum(); .cwiseProduct(rhs.template segment<LoopIndex>(S)).sum();
if(!(Mode & UnitDiag)) if(!(Mode & UnitDiag))
rhs.coeffRef(RowIndex) /= lhs.coeff(RowIndex,RowIndex); rhs.coeffRef(RowIndex) /= lhs.coeff(RowIndex,RowIndex);
triangular_solver_unroller<Lhs,Rhs,Mode,Index+1,Size>::run(lhs,rhs); triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex+1,Size>::run(lhs,rhs);
} }
}; };
template<typename Lhs, typename Rhs, int Mode, int Index, int Size> template<typename Lhs, typename Rhs, int Mode, int LoopIndex, int Size>
struct triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,true> { struct triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex,Size,true> {
static void run(const Lhs&, Rhs&) {} static void run(const Lhs&, Rhs&) {}
}; };