mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-01 16:24:28 +08:00
some cleaning
This commit is contained in:
parent
f3fde74695
commit
1d4d9a37fd
@ -50,41 +50,38 @@ struct ei_triangular_solver_selector<Lhs,Rhs,Mode,NoUnrolling,RowMajor,1>
|
|||||||
const ActualLhsType& actualLhs = LhsProductTraits::extract(lhs);
|
const ActualLhsType& actualLhs = LhsProductTraits::extract(lhs);
|
||||||
|
|
||||||
const int size = lhs.cols();
|
const int size = lhs.cols();
|
||||||
for(int c=0 ; c<other.cols() ; ++c)
|
for(int pi=IsLowerTriangular ? 0 : size;
|
||||||
|
IsLowerTriangular ? pi<size : pi>0;
|
||||||
|
IsLowerTriangular ? pi+=PanelWidth : pi-=PanelWidth)
|
||||||
{
|
{
|
||||||
for(int pi=IsLowerTriangular ? 0 : size;
|
int actualPanelWidth = std::min(IsLowerTriangular ? size - pi : pi, PanelWidth);
|
||||||
IsLowerTriangular ? pi<size : pi>0;
|
|
||||||
IsLowerTriangular ? pi+=PanelWidth : pi-=PanelWidth)
|
int r = IsLowerTriangular ? pi : size - pi; // remaining size
|
||||||
|
if (r > 0)
|
||||||
{
|
{
|
||||||
int actualPanelWidth = std::min(IsLowerTriangular ? size - pi : pi, PanelWidth);
|
// let's directly call the low level product function because:
|
||||||
|
// 1 - it is faster to compile
|
||||||
|
// 2 - it is slighlty faster at runtime
|
||||||
|
int startRow = IsLowerTriangular ? pi : pi-actualPanelWidth;
|
||||||
|
int startCol = IsLowerTriangular ? 0 : pi;
|
||||||
|
VectorBlock<Rhs,Dynamic> target(other,startRow,actualPanelWidth);
|
||||||
|
|
||||||
int r = IsLowerTriangular ? pi : size - pi; // remaining size
|
ei_cache_friendly_product_rowmajor_times_vector<LhsProductTraits::NeedToConjugate,false>(
|
||||||
if (r > 0)
|
&(actualLhs.const_cast_derived().coeffRef(startRow,startCol)), actualLhs.stride(),
|
||||||
{
|
&(other.coeffRef(startCol)), r,
|
||||||
// let's directly call the low level product function because:
|
target, Scalar(-1));
|
||||||
// 1 - it is faster to compile
|
}
|
||||||
// 2 - it is slighlty faster at runtime
|
|
||||||
int startRow = IsLowerTriangular ? pi : pi-actualPanelWidth;
|
|
||||||
int startCol = IsLowerTriangular ? 0 : pi;
|
|
||||||
Block<Rhs,Dynamic,1> target(other,startRow,c,actualPanelWidth,1);
|
|
||||||
|
|
||||||
ei_cache_friendly_product_rowmajor_times_vector<LhsProductTraits::NeedToConjugate,false>(
|
for(int k=0; k<actualPanelWidth; ++k)
|
||||||
&(actualLhs.const_cast_derived().coeffRef(startRow,startCol)), actualLhs.stride(),
|
{
|
||||||
&(other.coeffRef(startCol, c)), r,
|
int i = IsLowerTriangular ? pi+k : pi-k-1;
|
||||||
target, Scalar(-1));
|
int s = IsLowerTriangular ? pi : i+1;
|
||||||
}
|
if (k>0)
|
||||||
|
other.coeffRef(i) -= ((lhs.row(i).segment(s,k).transpose())
|
||||||
|
.cwise()*(other.segment(s,k))).sum();
|
||||||
|
|
||||||
for(int k=0; k<actualPanelWidth; ++k)
|
if(!(Mode & UnitDiagBit))
|
||||||
{
|
other.coeffRef(i) /= lhs.coeff(i,i);
|
||||||
int i = IsLowerTriangular ? pi+k : pi-k-1;
|
|
||||||
int s = IsLowerTriangular ? pi : i+1;
|
|
||||||
if (k>0)
|
|
||||||
other.coeffRef(i,c) -= ((lhs.row(i).segment(s,k).transpose())
|
|
||||||
.cwise()*(other.col(c).segment(s,k))).sum();
|
|
||||||
|
|
||||||
if(!(Mode & UnitDiagBit))
|
|
||||||
other.coeffRef(i,c) /= lhs.coeff(i,i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,43 +106,37 @@ struct ei_triangular_solver_selector<Lhs,Rhs,Mode,NoUnrolling,ColMajor,1>
|
|||||||
const ActualLhsType& actualLhs = LhsProductTraits::extract(lhs);
|
const ActualLhsType& actualLhs = LhsProductTraits::extract(lhs);
|
||||||
|
|
||||||
const int size = lhs.cols();
|
const int size = lhs.cols();
|
||||||
for(int c=0 ; c<other.cols() ; ++c)
|
for(int pi=IsLowerTriangular ? 0 : size;
|
||||||
|
IsLowerTriangular ? pi<size : pi>0;
|
||||||
|
IsLowerTriangular ? pi+=PanelWidth : pi-=PanelWidth)
|
||||||
{
|
{
|
||||||
for(int pi=IsLowerTriangular ? 0 : size;
|
int actualPanelWidth = std::min(IsLowerTriangular ? size - pi : pi, PanelWidth);
|
||||||
IsLowerTriangular ? pi<size : pi>0;
|
int startBlock = IsLowerTriangular ? pi : pi-actualPanelWidth;
|
||||||
IsLowerTriangular ? pi+=PanelWidth : pi-=PanelWidth)
|
int endBlock = IsLowerTriangular ? pi + actualPanelWidth : 0;
|
||||||
|
|
||||||
|
for(int k=0; k<actualPanelWidth; ++k)
|
||||||
{
|
{
|
||||||
int actualPanelWidth = std::min(IsLowerTriangular ? size - pi : pi, PanelWidth);
|
int i = IsLowerTriangular ? pi+k : pi-k-1;
|
||||||
int startBlock = IsLowerTriangular ? pi : pi-actualPanelWidth;
|
if(!(Mode & UnitDiagBit))
|
||||||
int endBlock = IsLowerTriangular ? pi + actualPanelWidth : 0;
|
other.coeffRef(i) /= lhs.coeff(i,i);
|
||||||
|
|
||||||
for(int k=0; k<actualPanelWidth; ++k)
|
int r = actualPanelWidth - k - 1; // remaining size
|
||||||
{
|
int s = IsLowerTriangular ? i+1 : i-r;
|
||||||
int i = IsLowerTriangular ? pi+k : pi-k-1;
|
if (r>0)
|
||||||
if(!(Mode & UnitDiagBit))
|
other.segment(s,r) -= other.coeffRef(i) * Block<Lhs,Dynamic,1>(lhs, s, i, r, 1);
|
||||||
other.coeffRef(i,c) /= lhs.coeff(i,i);
|
}
|
||||||
|
int r = IsLowerTriangular ? size - endBlock : startBlock; // remaining size
|
||||||
int r = actualPanelWidth - k - 1; // remaining size
|
if (r > 0)
|
||||||
if (r>0)
|
{
|
||||||
{
|
// let's directly call the low level product function because:
|
||||||
other.col(c).segment((IsLowerTriangular ? i+1 : i-r), r) -=
|
// 1 - it is faster to compile
|
||||||
other.coeffRef(i,c)
|
// 2 - it is slighlty faster at runtime
|
||||||
* Block<Lhs,Dynamic,1>(lhs, (IsLowerTriangular ? i+1 : i-r), i, r, 1);
|
ei_cache_friendly_product_colmajor_times_vector<LhsProductTraits::NeedToConjugate,false>(
|
||||||
}
|
r,
|
||||||
}
|
&(actualLhs.const_cast_derived().coeffRef(endBlock,startBlock)), actualLhs.stride(),
|
||||||
int r = IsLowerTriangular ? size - endBlock : startBlock; // remaining size
|
other.segment(startBlock, actualPanelWidth),
|
||||||
if (r > 0)
|
&(other.coeffRef(endBlock, 0)),
|
||||||
{
|
Scalar(-1));
|
||||||
// let's directly call the low level product function because:
|
|
||||||
// 1 - it is faster to compile
|
|
||||||
// 2 - it is slighlty faster at runtime
|
|
||||||
ei_cache_friendly_product_colmajor_times_vector<LhsProductTraits::NeedToConjugate,false>(
|
|
||||||
r,
|
|
||||||
&(actualLhs.const_cast_derived().coeffRef(endBlock,startBlock)), actualLhs.stride(),
|
|
||||||
other.col(c).segment(startBlock, actualPanelWidth),
|
|
||||||
&(other.coeffRef(endBlock, c)),
|
|
||||||
Scalar(-1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user