Skip to content

Commit

Permalink
forgotten delete in SparseCommon
Browse files Browse the repository at this point in the history
  • Loading branch information
hugtalbot committed Jan 26, 2025
1 parent 5019950 commit 9769a27
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 62 deletions.
1 change: 0 additions & 1 deletion Sofa/Component/LinearSolver/Direct/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ set(SOURCE_FILES
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/MatrixLinearSystem[BTDMatrix].cpp
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/PrecomputedLinearSolver.cpp
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SVDLinearSolver.cpp
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseCommon.cpp
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseLDLSolver.cpp
${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/TypedMatrixLinearSystem[BTDMatrix].cpp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,65 +23,5 @@

namespace sofa::component::linearsolver::direct
{
void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector<int>& adj, type::vector<int>& xadj , type::vector<int>& t_adj , type::vector<int>& t_xadj, type::vector<int>& tran_countvec)
{
//Compute transpose in tran_colptr, tran_rowind, tran_values, tran_D
tran_countvec.clear();
tran_countvec.resize(n);

// First we count the number of value on each row.
for (int j=0;j<n;j++)
{
for (int i=M_colptr[j];i<M_colptr[j+1];i++)
{
const int col = M_rowind[i];
if (col>j) tran_countvec[col]++;
}
}

// Now we make a scan to build tran_colptr
t_xadj.resize(n+1);
t_xadj[0] = 0;
for (int j=0;j<n;j++) t_xadj[j+1] = t_xadj[j] + tran_countvec[j];

// we clear tran_countvec because we use it now to store hown many values are written on each line
tran_countvec.clear();
tran_countvec.resize(n);

t_adj.resize(t_xadj[n]);
for (int j=0;j<n;j++)
{
for (int i=M_colptr[j];i<M_colptr[j+1];i++)
{
const int line = M_rowind[i];
if (line>j)
{
t_adj[t_xadj[line] + tran_countvec[line]] = j;
tran_countvec[line]++;
}
}
}

adj.clear();
xadj.resize(n+1);
xadj[0] = 0;
for (int j=0; j<n; j++)
{
// copy the lower part
for (int ip = t_xadj[j]; ip < t_xadj[j+1]; ip++)
{
adj.push_back(t_adj[ip]);
}

// copy only the upper part
for (int ip = M_colptr[j]; ip < M_colptr[j+1]; ip++)
{
int col = M_rowind[ip];
if (col > j) adj.push_back(col);
}

xadj[j+1] = adj.size();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ adj[xadj[i]] is the first neighbor of the i-th node
**/
SOFA_ATTRIBUTE_DISABLED__SPARSECOMMON()
SOFA_COMPONENT_LINEARSOLVER_DIRECT_API
void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector<int>& adj, type::vector<int>& xadj, type::vector<int>& t_adj, type::vector<int>& t_xadj, type::vector<int>& tran_countvec );
void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector<int>& adj, type::vector<int>& xadj, type::vector<int>& t_adj, type::vector<int>& t_xadj, type::vector<int>& tran_countvec ) = delete;

// compare the shape of two matrix given in CSR format, return false if the matrices have the same shape and return true if their shapes are different
inline bool compareMatrixShape(int s_M, int * M_colptr,int * M_rowind, int s_P, int * P_colptr,int * P_rowind) {
Expand Down

0 comments on commit 9769a27

Please sign in to comment.