Beispiel #1
0
bool PARDISOSolver< valueType, zeroBased >::analyzePattern( CompressedSparseMatrix< valueType >& A )
{
    return analyzePattern( A.numRows(), A.numCols(),
        reinterpret_cast< int* >( A.outerIndexPointers().data() ),
        reinterpret_cast< int* >( A.innerIndices().data() ),
        A.numNonZeros() );
}
Beispiel #2
0
bool PARDISOSolver< valueType, zeroBased >::factorize( CompressedSparseMatrix< valueType >& A )
{
    assert( A.matrixType() == SYMMETRIC );
    assert( A.numRows() == m_nRowsA );
    assert( A.numCols() == m_nColsA );

    return factorize( A.values().data() );
}
void DictionaryOfKeysSparseMatrix< T >::compress( CompressedSparseMatrix< T >& output,
	bool oneBased, bool upperTriangleOnly ) const
{
	int nnz = numNonZeroes();
	uint m = numRows();
	uint n = numCols();

	output.reset( m, n, nnz );

	uint columnsIndex = 0;
	uint rowIndexIndex = 0;
	uint offset = oneBased ? 1 : 0;

	// if column compressed
	// then build a vector of (i,j,v) and sort into (j,i)

	auto& values = output.values();
	auto& innerIndices = output.innerIndices();
	auto& outerIndexPointers = output.outerIndexPointers();
	auto& structureMap = output.structureMap();

	for( auto itr = m_values.begin(); itr != m_values.end(); ++itr )
	{
		auto ij = itr->first;
		uint i = ij.first;
		uint j = ij.second;

		if( ( !upperTriangleOnly ) ||
			( j >= i ) )
		{
			T value = itr->second;

			values[ columnsIndex ] = value;
			innerIndices[ columnsIndex ] = j + offset;

			structureMap[ ij ] = columnsIndex;

			if( i == rowIndexIndex )
			{
				outerIndexPointers[ rowIndexIndex ] = columnsIndex;
				++rowIndexIndex;
			}

			++columnsIndex;
		}		
	}
	outerIndexPointers[ rowIndexIndex ] = columnsIndex + offset;
	++rowIndexIndex;
}