Link Copied
vector
vector
vector
iaV.push_back(1);
for( int y = 0; y < fileA.Rows(); y++ )
{
int numValues = 0;
bool isData = false;
for( int x = 0; x < fileA.Cols(); x++ )
{
double value = fileA.Get( y, x );
if( value != 0 )
{
numValues++;
jaV.push_back( x + 1 );
aV.push_back( value );
}
}
if( numValues != 0 )
{
iaV.push_back( iaV[ iaV.size() - 1 ] + numValues );
}
}
vector
for( int y = 0; y < fileB.Rows(); y++ )
{
double value = fileB.Get( y, 0 );
rhsV.push_back( value );
}
Solve( fileA.GetNumLines(), iaV, jaV, aV, rhsV );
bool Solve( int matrixSize, vector
{
int n = matrixSize, rci_request, itercount;
double* rhs = &rhsV[0];
int* ia = &iaV[0];
int* ja = &jaV[0];
double* a = &aV[0];
double* solution = new double[matrixSize];
int ipar[128];
double dpar[128];
double* tmp = new double[4 * matrixSize];
char tr = 'u';
for( int i = 0; i < n; i++ )
solution = 1;
dcg_init( &n, solution, rhs, &rci_request, ipar, dpar, tmp );
if( rci_request != 0 )
return false;
ipar[8] = 1;
ipar[9] = 0;
dpar[0] = 1.E-5;
dcg_check( &n, solution, rhs, &rci_request, ipar, dpar, tmp );
if (rci_request != 0)
return false;
while(true)
{
dcg( &n, solution, rhs, &rci_request, ipar, dpar, tmp );
if (rci_request == 0)
break;
if(rci_request == 1)
{
mkl_dcsrsymv( &tr, &n, a, ia, ja, tmp, &tmp
continue;
}
return false;
}
dcg_get( &n, solution, rhs, &rci_request, ipar, dpar, tmp, &itercount );
MKL_FreeBuffers();
return true;
}
Please see MKL manuals.
The mkl_?csrsymv routine performs a matrix-vector operation defined as y := A*x
where:
x and y are vectors,
A is an upper or lower triangle of the symmetrical sparse matrix in the CSR format (3-array variation).
So you may need to change the way of read matA,For more complete information about compiler optimizations, see our Optimization Notice.