Fix a bug introduced in !751.

This commit is contained in:
Rasmus Munk Larsen 2021-12-15 22:00:40 +00:00
parent e939c06b0e
commit e93a071774

View File

@ -31,15 +31,16 @@ struct packed_triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsS
typedef typename conj_expr_if<ConjLhs,LhsMap>::type ConjLhsType; typedef typename conj_expr_if<ConjLhs,LhsMap>::type ConjLhsType;
typedef Map<Matrix<ResScalar,Dynamic,1> > ResMap; typedef Map<Matrix<ResScalar,Dynamic,1> > ResMap;
for (Index i=0; i<size; ++i) for (Index i = 0; i < size; ++i) {
{ Index s = IsLower && (HasUnitDiag || HasZeroDiag) ? 1 : 0;
Index s = IsLower&&(HasUnitDiag||HasZeroDiag) ? 1 : 0; Index r = IsLower ? size - i : i + 1;
Index r = IsLower ? size-i: i+1; if (!(HasUnitDiag || HasZeroDiag) || (--r > 0)) {
if (internal::check_implication(HasUnitDiag||HasZeroDiag, (--r)>0)) ResMap(res + (IsLower ? s + i : 0), r) += alpha * cj(rhs[i]) * ConjLhsType(LhsMap(lhs + s, r));
ResMap(res+(IsLower ? s+i : 0),r) += alpha * cj(rhs[i]) * ConjLhsType(LhsMap(lhs+s,r)); }
if (HasUnitDiag) if (HasUnitDiag) {
res[i] += alpha * cj(rhs[i]); res[i] += alpha * cj(rhs[i]);
lhs += IsLower ? size-i: i+1; }
lhs += IsLower ? size - i : i + 1;
} }
}; };
}; };
@ -61,15 +62,16 @@ struct packed_triangular_matrix_vector_product<Index,Mode,LhsScalar,ConjLhs,RhsS
typedef Map<const Matrix<RhsScalar,Dynamic,1> > RhsMap; typedef Map<const Matrix<RhsScalar,Dynamic,1> > RhsMap;
typedef typename conj_expr_if<ConjRhs,RhsMap>::type ConjRhsType; typedef typename conj_expr_if<ConjRhs,RhsMap>::type ConjRhsType;
for (Index i=0; i<size; ++i) for (Index i = 0; i < size; ++i) {
{ Index s = !IsLower && (HasUnitDiag || HasZeroDiag) ? 1 : 0;
Index s = !IsLower&&(HasUnitDiag||HasZeroDiag) ? 1 : 0; Index r = IsLower ? i + 1 : size - i;
Index r = IsLower ? i+1 : size-i; if (!(HasUnitDiag || HasZeroDiag) || (--r > 0)) {
if (internal::check_implication(HasUnitDiag||HasZeroDiag, (--r)>0)) res[i] += alpha * (ConjLhsType(LhsMap(lhs + s, r)).cwiseProduct(ConjRhsType(RhsMap(rhs + (IsLower ? 0 : s + i), r)))).sum();
res[i] += alpha * (ConjLhsType(LhsMap(lhs+s,r)).cwiseProduct(ConjRhsType(RhsMap(rhs+(IsLower ? 0 : s+i),r)))).sum(); }
if (HasUnitDiag) if (HasUnitDiag) {
res[i] += alpha * cj(rhs[i]); res[i] += alpha * cj(rhs[i]);
lhs += IsLower ? i+1 : size-i; }
lhs += IsLower ? i + 1 : size - i;
} }
}; };
}; };