<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic sparse equation system in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/sparse-equation-system/m-p/984518#M17682</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;In the below code, I have declared one matrix and one vector: A[3][3] and B[3]. The &amp;nbsp;matrix A is symmetric from main diagonal. I converted the matrix A from dense format to CSR format, and from CSR format to coordinate format using the function&amp;nbsp;&lt;EM&gt;mkl_dcsrcoo. &lt;/EM&gt;All conversions are ok, but I can not solve correctly the system&amp;nbsp;&lt;STRONG&gt;AxY=B. &lt;/STRONG&gt;I obtained a wrong solution. The correct solution is: Y=[0.5 0.5 0.5]&lt;/P&gt;

&lt;P&gt;How can I obtain the correct solution?&lt;/P&gt;

&lt;P&gt;The code is following:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
#include "stdafx.h"
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;math.h&amp;gt;
#include "mkl.h"
#include "mkl_lapacke.h"

int _tmain(int argc, _TCHAR* argv[])
{
	double A[3][3] = {{2.5,-0.5,0.},{-0.5,5,-0.5},{0,-0.5,2.5}};
	double B[3]={1.0,2.0,1.0};
	MKL_INT  rows = 3, cols = 3, nnz = 7,info;
	MKL_INT job[6]={0,0,0,2,nnz,2}; 
	//for conversion of matrix A to CSR format
	double  *arrV      = new double[nnz]; 
    MKL_INT *Columns   = new MKL_INT[nnz];
    MKL_INT *Rows      = new MKL_INT[rows+1];

	mkl_ddnscsr(job,&amp;amp;rows, &amp;amp;cols, A[0], &amp;amp;rows, arrV, Columns, Rows,&amp;amp;info);

	printf("\Values\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%.3f ",arrV&lt;I&gt;);
	printf("\nColumns\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",Columns&lt;I&gt;);
 	printf("\nRows\n");
	for(int i=0;i&amp;lt;rows+1;i++)
		printf("%d ",Rows&lt;I&gt;);
	printf("\n");
	
	//convert to column format
	double  *acoo      = new double[nnz]; 
	int     *rowind    = new int[nnz]; 
	int     *colind	   = new int[nnz]; 
	
	MKL_INT job1[6]={0,0,0,0,nnz,3}; 
	mkl_dcsrcoo(job1,&amp;amp;rows,arrV,Columns,Rows,&amp;amp;nnz,acoo,rowind,colind,&amp;amp;info);
	printf("info mkl_dcsrcoo=%d\nacoo\n",info);
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%.3f ",acoo&lt;I&gt;);
	printf("\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",rowind&lt;I&gt;);
	printf("\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",colind&lt;I&gt;);

	MKL_INT colsC=3;
	double alpha=1;
	double *Y=new double[3];
	mkl_dcoosm ("n",&amp;amp;rows,&amp;amp;colsC,&amp;amp;alpha,"TUNC",acoo,rowind,colind,&amp;amp;nnz,B,&amp;amp;rows,Y,&amp;amp;colsC);
	printf("\n");
	for(int i=0;i&amp;lt;3;i++)
		printf("%.3f ",Y&lt;I&gt;);

	delete[] arrV;
	delete[] Columns;
	delete[] Rows;
	delete[] acoo;
	delete[] rowind;
	delete[] colind;
	_getch();
	return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Feb 2014 07:10:33 GMT</pubDate>
    <dc:creator>Ion_C_</dc:creator>
    <dc:date>2014-02-14T07:10:33Z</dc:date>
    <item>
      <title>sparse equation system</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/sparse-equation-system/m-p/984518#M17682</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;In the below code, I have declared one matrix and one vector: A[3][3] and B[3]. The &amp;nbsp;matrix A is symmetric from main diagonal. I converted the matrix A from dense format to CSR format, and from CSR format to coordinate format using the function&amp;nbsp;&lt;EM&gt;mkl_dcsrcoo. &lt;/EM&gt;All conversions are ok, but I can not solve correctly the system&amp;nbsp;&lt;STRONG&gt;AxY=B. &lt;/STRONG&gt;I obtained a wrong solution. The correct solution is: Y=[0.5 0.5 0.5]&lt;/P&gt;

&lt;P&gt;How can I obtain the correct solution?&lt;/P&gt;

&lt;P&gt;The code is following:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
#include "stdafx.h"
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;math.h&amp;gt;
#include "mkl.h"
#include "mkl_lapacke.h"

int _tmain(int argc, _TCHAR* argv[])
{
	double A[3][3] = {{2.5,-0.5,0.},{-0.5,5,-0.5},{0,-0.5,2.5}};
	double B[3]={1.0,2.0,1.0};
	MKL_INT  rows = 3, cols = 3, nnz = 7,info;
	MKL_INT job[6]={0,0,0,2,nnz,2}; 
	//for conversion of matrix A to CSR format
	double  *arrV      = new double[nnz]; 
    MKL_INT *Columns   = new MKL_INT[nnz];
    MKL_INT *Rows      = new MKL_INT[rows+1];

	mkl_ddnscsr(job,&amp;amp;rows, &amp;amp;cols, A[0], &amp;amp;rows, arrV, Columns, Rows,&amp;amp;info);

	printf("\Values\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%.3f ",arrV&lt;I&gt;);
	printf("\nColumns\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",Columns&lt;I&gt;);
 	printf("\nRows\n");
	for(int i=0;i&amp;lt;rows+1;i++)
		printf("%d ",Rows&lt;I&gt;);
	printf("\n");
	
	//convert to column format
	double  *acoo      = new double[nnz]; 
	int     *rowind    = new int[nnz]; 
	int     *colind	   = new int[nnz]; 
	
	MKL_INT job1[6]={0,0,0,0,nnz,3}; 
	mkl_dcsrcoo(job1,&amp;amp;rows,arrV,Columns,Rows,&amp;amp;nnz,acoo,rowind,colind,&amp;amp;info);
	printf("info mkl_dcsrcoo=%d\nacoo\n",info);
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%.3f ",acoo&lt;I&gt;);
	printf("\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",rowind&lt;I&gt;);
	printf("\n");
	for(int i=0;i&amp;lt;nnz;i++)
		printf("%d ",colind&lt;I&gt;);

	MKL_INT colsC=3;
	double alpha=1;
	double *Y=new double[3];
	mkl_dcoosm ("n",&amp;amp;rows,&amp;amp;colsC,&amp;amp;alpha,"TUNC",acoo,rowind,colind,&amp;amp;nnz,B,&amp;amp;rows,Y,&amp;amp;colsC);
	printf("\n");
	for(int i=0;i&amp;lt;3;i++)
		printf("%.3f ",Y&lt;I&gt;);

	delete[] arrV;
	delete[] Columns;
	delete[] Rows;
	delete[] acoo;
	delete[] rowind;
	delete[] colind;
	_getch();
	return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2014 07:10:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/sparse-equation-system/m-p/984518#M17682</guid>
      <dc:creator>Ion_C_</dc:creator>
      <dc:date>2014-02-14T07:10:33Z</dc:date>
    </item>
    <item>
      <title>For the MATDESCRA argument,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/sparse-equation-system/m-p/984519#M17683</link>
      <description>&lt;P&gt;For the MATDESCRA argument, you gave "TUNC". The first letter signifies that the matrix being passed is upper triangular. This would make sense only if your matrix, which is a square matrix, has already been factorized into an LU or LDU product. Please note that with some Lapack/MKL routines a symmetric matrix is passed with the convention of including only the upper triangular part. However, this part is NOT the U factor that I just mentioned.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2014 20:42:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/sparse-equation-system/m-p/984519#M17683</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-02-14T20:42:14Z</dc:date>
    </item>
  </channel>
</rss>

