mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
add unit tests for sparse LU and fix a couple of warnings
This commit is contained in:
@@ -124,7 +124,7 @@ void AmbiVector<Scalar>::nonZeros() const
|
||||
template<typename Scalar>
|
||||
void AmbiVector<Scalar>::init(RealScalar estimatedDensity)
|
||||
{
|
||||
if (m_mode = estimatedDensity>0.1)
|
||||
if (estimatedDensity>0.1)
|
||||
init(IsDense);
|
||||
else
|
||||
init(IsSparse);
|
||||
|
||||
@@ -43,7 +43,7 @@ struct ei_traits<LinkedVectorMatrix<_Scalar,_Flags> >
|
||||
template<typename Element, int ChunkSize = 8>
|
||||
struct LinkedVectorChunk
|
||||
{
|
||||
LinkedVectorChunk() : size(0), next(0), prev(0) {}
|
||||
LinkedVectorChunk() : next(0), prev(0), size(0) {}
|
||||
Element data[ChunkSize];
|
||||
LinkedVectorChunk* next;
|
||||
LinkedVectorChunk* prev;
|
||||
@@ -141,7 +141,7 @@ class LinkedVectorMatrix
|
||||
inline void startFill(int reserveSize = 1000)
|
||||
{
|
||||
clear();
|
||||
for (int i=0; i<m_data.size(); ++i)
|
||||
for (unsigned int i=0; i<m_data.size(); ++i)
|
||||
m_ends[i] = m_data[i] = 0;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ class LinkedVectorMatrix
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (int i=0; i<m_data.size(); ++i)
|
||||
for (unsigned int i=0; i<m_data.size(); ++i)
|
||||
{
|
||||
VectorChunk* el = m_data[i];
|
||||
while (el)
|
||||
@@ -224,7 +224,7 @@ class LinkedVectorMatrix
|
||||
clear();
|
||||
m_data.resize(outers);
|
||||
m_ends.resize(outers);
|
||||
for (int i=0; i<m_data.size(); ++i)
|
||||
for (unsigned int i=0; i<m_data.size(); ++i)
|
||||
m_ends[i] = m_data[i] = 0;
|
||||
}
|
||||
m_innerSize = inners;
|
||||
|
||||
@@ -64,11 +64,8 @@ struct SluMatrix : SuperMatrix
|
||||
SluMatrix(const SluMatrix& other)
|
||||
: SuperMatrix(other)
|
||||
{
|
||||
Store = &nnz;
|
||||
nnz = other.nnz;
|
||||
values = other.values;
|
||||
innerInd = other.innerInd;
|
||||
outerInd = other.outerInd;
|
||||
Store = &storage;
|
||||
storage = other.storage;
|
||||
}
|
||||
|
||||
struct
|
||||
@@ -77,13 +74,13 @@ struct SluMatrix : SuperMatrix
|
||||
void *values;
|
||||
int *innerInd;
|
||||
int *outerInd;
|
||||
};
|
||||
} storage;
|
||||
|
||||
void setStorageType(Stype_t t)
|
||||
{
|
||||
Stype = t;
|
||||
if (t==SLU_NC || t==SLU_NR || t==SLU_DN)
|
||||
Store = &nnz;
|
||||
Store = &storage;
|
||||
else
|
||||
{
|
||||
ei_assert(false && "storage type not supported");
|
||||
@@ -131,8 +128,8 @@ struct SluMatrixMapHelper<Matrix<Scalar,Rows,Cols,StorageOrder,MRows,MCols> >
|
||||
res.nrow = mat.rows();
|
||||
res.ncol = mat.cols();
|
||||
|
||||
res.lda = mat.stride();
|
||||
res.values = mat.data();
|
||||
res.storage.lda = mat.stride();
|
||||
res.storage.values = mat.data();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,10 +154,10 @@ struct SluMatrixMapHelper<SparseMatrix<Scalar,Flags> >
|
||||
|
||||
res.Mtype = SLU_GE;
|
||||
|
||||
res.nnz = mat.nonZeros();
|
||||
res.values = mat._valuePtr();
|
||||
res.innerInd = mat._innerIndexPtr();
|
||||
res.outerInd = mat._outerIndexPtr();
|
||||
res.storage.nnz = mat.nonZeros();
|
||||
res.storage.values = mat._valuePtr();
|
||||
res.storage.innerInd = mat._innerIndexPtr();
|
||||
res.storage.outerInd = mat._outerIndexPtr();
|
||||
|
||||
res.setScalarType<Scalar>();
|
||||
|
||||
@@ -196,11 +193,11 @@ SparseMatrix<Scalar,Flags> SparseMatrix<Scalar,Flags>::Map(SluMatrix& sluMat)
|
||||
res.m_innerSize = sluMat.nrow;
|
||||
res.m_outerSize = sluMat.ncol;
|
||||
}
|
||||
res.m_outerIndex = sluMat.outerInd;
|
||||
res.m_outerIndex = sluMat.storage.outerInd;
|
||||
SparseArray<Scalar> data = SparseArray<Scalar>::Map(
|
||||
sluMat.innerInd,
|
||||
reinterpret_cast<Scalar*>(sluMat.values),
|
||||
sluMat.outerInd[res.m_outerSize]);
|
||||
sluMat.storage.innerInd,
|
||||
reinterpret_cast<Scalar*>(sluMat.storage.values),
|
||||
sluMat.storage.outerInd[res.m_outerSize]);
|
||||
res.m_data.swap(data);
|
||||
res.markAsRValue();
|
||||
return res;
|
||||
@@ -295,9 +292,9 @@ void SparseLU<MatrixType,SuperLU>::compute(const MatrixType& a)
|
||||
m_sluB.setStorageType(SLU_DN);
|
||||
m_sluB.setScalarType<Scalar>();
|
||||
m_sluB.Mtype = SLU_GE;
|
||||
m_sluB.values = 0;
|
||||
m_sluB.storage.values = 0;
|
||||
m_sluB.nrow = m_sluB.ncol = 0;
|
||||
m_sluB.lda = size;
|
||||
m_sluB.storage.lda = size;
|
||||
m_sluX = m_sluB;
|
||||
|
||||
StatInit(&m_sluStat);
|
||||
|
||||
Reference in New Issue
Block a user