<?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 Hi Anas, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949733#M15131</link>
    <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;MKL covariance algorithm supports the streaming way of the processing; that is, when the data comes in blocks the covariance algorithm can update the estimate using it previous value and the latest observation data. Please, have a look at the section "Processing Data in Blocks" in Summary Stats Application notes, &lt;A href="http://software.intel.com/en-us/node/497946"&gt;http://software.intel.com/en-us/node/497946&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Computational flow is mostly the same as in case of the processing of the whole dataset, but you need additionally to initialize covariance matrix with zeros (or other meaningful for you numbers), and register in the library the array which would hold&amp;nbsp;the accumulated weights.&lt;/P&gt;

&lt;P&gt;The file vslddataprocessinginblocks.c available in examples/vslc of MKL installation tree contains the example which shows how to do progressive computation of estimates.&lt;/P&gt;

&lt;P&gt;Please, let me know, if you need more details.&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Mar 2014 16:27:19 GMT</pubDate>
    <dc:creator>Andrey_N_Intel</dc:creator>
    <dc:date>2014-03-17T16:27:19Z</dc:date>
    <item>
      <title>Different matrix multiplication results between C and Matlab.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949728#M15126</link>
      <description>&lt;P&gt;Let covold be a matrix of size 72x72, theta be a vector of size 1x72 and meanold a vector of size 1x72. I want to compute&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;[(w-1)/w ]* covold + [ 1/(1+w) ] * (theta - meanold)' * (theta&amp;nbsp; - meanold)&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;where w=144.0.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I wrote a code in C and a code in Matlab in order to compare the results. I noticed that the results are different. For example the variance of the first variable is:&lt;/P&gt;

&lt;P&gt;C: 0.001890&lt;/P&gt;

&lt;P&gt;Matlab: 0.003690258&lt;/P&gt;

&lt;P&gt;I would like to ask if this is normal. I attach the data and the results using Matlab (matlabcov.txt).&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The code in C is:&lt;/P&gt;

&lt;P&gt;#include "stdafx.h"&lt;BR /&gt;
	#include &amp;lt;math.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Math stuff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISOC&amp;nbsp; */&lt;BR /&gt;
	#include &amp;lt;stdio.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* I/O lib&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISOC&amp;nbsp; */&lt;BR /&gt;
	#include &amp;lt;stdlib.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Standard Lib&amp;nbsp;&amp;nbsp;&amp;nbsp; ISOC&amp;nbsp; */&lt;BR /&gt;
	#include &amp;lt;fstream&amp;gt;&lt;BR /&gt;
	#include &amp;lt;mkl.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;conio.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;iostream&amp;gt;&lt;BR /&gt;
	#include &amp;lt;string&amp;gt;&lt;/P&gt;

&lt;P&gt;using namespace std;&lt;/P&gt;

&lt;P&gt;void fReadMtrx(string f, double *mtrx, int nrow, int ncol);&lt;/P&gt;

&lt;P&gt;#define NPARS 72&lt;BR /&gt;
	#define N 144&lt;/P&gt;

&lt;P&gt;int main()&lt;BR /&gt;
	{&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;int i, j, info, dimen = NPARS;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;double meanold[NPARS], covold[NPARS*NPARS], subvec[NPARS], theta[NPARS];&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double weight = 144.0;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;fReadMtrx("MEAN.txt", meanold, NPARS, 1);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;fReadMtrx("thetacan.txt", theta, NPARS, 1);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; fReadMtrx("COVFILE.txt", covold, NPARS, NPARS);&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;/*Update Covariance and Mean */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;vdSub(NPARS, theta, meanold, subvec );&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, NPARS, NPARS, 1, 1.0/(1.0+weight), subvec,&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NPARS,&amp;nbsp; subvec,&amp;nbsp; NPARS, (weight-1.0)/weight, covold, NPARS);&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;for(i=0; i&amp;lt;NPARS; i++){&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(j=0; j&amp;lt;NPARS; j++){&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printf("%lf \t", covold[i*NPARS+j]);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printf("%lf \n \n");&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;return 0;&lt;BR /&gt;
	}&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	void fReadMtrx(string f, double *mtrx, int nrow, int ncol)&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp; ifstream data(f.c_str(), ios::in);&lt;BR /&gt;
	&amp;nbsp; if (!data) {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; cerr &amp;lt;&amp;lt; "File " &amp;lt;&amp;lt; f &amp;lt;&amp;lt; " could not be opened." &amp;lt;&amp;lt; endl;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;BR /&gt;
	&amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp; for(int i = 0; i &amp;lt; nrow; i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j = 0; j &amp;lt; ncol; j++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data &amp;gt;&amp;gt; mtrx[i*ncol+j];&lt;BR /&gt;
	} // end of function fReadMtrx&lt;/P&gt;

&lt;P&gt;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;

&lt;P&gt;The node in Matlab:&lt;/P&gt;

&lt;P&gt;covold=load('COVFILE.txt');&lt;BR /&gt;
	meanold=load('MEAN.txt');&lt;BR /&gt;
	theta=load('thetacan.txt')';&lt;/P&gt;

&lt;P&gt;&amp;nbsp;weightold = 144; npars=72;&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;% Recursive form of covariance matrix&lt;BR /&gt;
	&amp;nbsp;covold= ((weightold-1)/weightold)*covold + ...&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (1/(1+weightold))* ((theta - meanold)*(theta-meanold)');&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;fcov = fopen('matlabcov.txt', 'wt');&lt;BR /&gt;
	&amp;nbsp;for i=1:npars&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for j =1:npars&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(fcov, '%0.9f \t', covold(i,j));&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(fcov,'\n');&lt;BR /&gt;
	&amp;nbsp;end&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;fclose(fcov);&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:04:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949728#M15126</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-17T14:04:14Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949729#M15127</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;I wonder if you evaluated algorithms for covariance matrix computation available in Statistical component of Intel MKL and compared their output against Matlab? In MKL we support several methods for computation of covariance/correlation. Fast and single pass methods are among them. The library also allows re-using the mean estimate obtained earlier instead of its computation during evaluation of covariance&amp;nbsp;- "user mean" method supports this use model.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:28:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949729#M15127</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-17T14:28:56Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey! Thanks for the</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949730#M15128</link>
      <description>&lt;P&gt;Hi Andrey! Thanks for the help.&lt;/P&gt;

&lt;P&gt;The first time I computed the covariance matrix and the mean the results between Matlab and C were similar. I wanted to compute the covariance matrix and the mean sequentially but I didn't know how to do that with MKL so I tried to compute it by myself. Also do you know if MKL has a routine to force the covariance matrix to me positive define? I think I could do that with the routine of the robust covariance matrix but the first time I compute the covariance matrix the data are 144 and the parameters 72.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:54:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949730#M15128</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-17T14:54:48Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949731#M15129</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;Can you please clarify what you mean by computation of the covariance matrix and the mean sequentially? Does it mean that you compute the average first, and compute the covariance after that, and computation of the covariance relies on the pre-computed mean (in other terms, you need two pass approach for computation of the covariance matrix)?&lt;/P&gt;

&lt;P&gt;Answering your second question - yes, In Statistical component of Intel MKL we provide the algorithm for stabilization of the correlation matrix. The input to the algorithm is the symmetric matrix which is not positively definite, and the output is the matrix which is "close" to the original and is positively semi-defined. The method &lt;SPAN class="keyword"&gt;VSL_SS_METHOD_SD, s&lt;/SPAN&gt;pectral decomposition method for parameterization of a correlation matrix&amp;nbsp;is responsible for this type of the computations. Please, see additional details in Summary Stats application notes, &lt;A href="http://software.intel.com/en-us/node/497944"&gt;http://software.intel.com/en-us/node/497944&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks, Andrey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 15:30:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949731#M15129</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-17T15:30:04Z</dc:date>
    </item>
    <item>
      <title>By saying sequentially I mean</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949732#M15130</link>
      <description>&lt;P&gt;By saying sequentially I mean:&lt;/P&gt;

&lt;P&gt;for t =145 :T&lt;/P&gt;

&lt;P&gt;I have available t-1 observations and I need to simulate from a d-dimensional Normal distribution with mean the vector theta and variance covariance matrix the current empirical estimate of&amp;nbsp; the covariance matrix.&lt;/P&gt;

&lt;P&gt;end&lt;/P&gt;

&lt;P&gt;Each time&amp;nbsp; I add a new&amp;nbsp; observation so, instead of estimate each time the covariance matrix from the beginning I use a recursive formula for the covariance matrix. As you said I compute the mean first, and compute the covariance after that, and computation of the covariance relies on the pre-computed mean.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 15:54:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949732#M15130</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-17T15:54:47Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949733#M15131</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;MKL covariance algorithm supports the streaming way of the processing; that is, when the data comes in blocks the covariance algorithm can update the estimate using it previous value and the latest observation data. Please, have a look at the section "Processing Data in Blocks" in Summary Stats Application notes, &lt;A href="http://software.intel.com/en-us/node/497946"&gt;http://software.intel.com/en-us/node/497946&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Computational flow is mostly the same as in case of the processing of the whole dataset, but you need additionally to initialize covariance matrix with zeros (or other meaningful for you numbers), and register in the library the array which would hold&amp;nbsp;the accumulated weights.&lt;/P&gt;

&lt;P&gt;The file vslddataprocessinginblocks.c available in examples/vslc of MKL installation tree contains the example which shows how to do progressive computation of estimates.&lt;/P&gt;

&lt;P&gt;Please, let me know, if you need more details.&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 16:27:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949733#M15131</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-17T16:27:19Z</dc:date>
    </item>
    <item>
      <title>I didn't find the file</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949734#M15132</link>
      <description>&lt;P&gt;I didn't find the file vslddataprocessinginblocks.c but I read the notes about Summary Statistics Application. I tried to compute the covariance matrix and the mean sequentially. If I have understood right the blocks must be of the same size. So I thought to compute the covariance matrix (C) and the mean (M) of the first data and then to use the recursive form and to initialize the mean and the covariance matrix with C and the mean with M. Then I say that the blocks have size 1.&lt;/P&gt;

&lt;P&gt;Let a be the matrix that I want to find the covariance matrix.&lt;/P&gt;

&lt;P&gt;a =&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; 11&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;

&lt;P&gt;The true covariance matrix is&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; 21.2857&amp;nbsp;&amp;nbsp; 17.5238&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.7143&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; 17.5238&amp;nbsp;&amp;nbsp; 15.9048&amp;nbsp;&amp;nbsp; 11.8095&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.7143&amp;nbsp;&amp;nbsp; 11.8095&amp;nbsp;&amp;nbsp; 14.6190&lt;/P&gt;

&lt;P&gt;and the true mean is&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.5714&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.7143&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.4286&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	( I found it with Matlab.)&lt;/P&gt;

&lt;P&gt;I computed the covariance matrix and the mean of the first 4 data. So as initial covariance matrix I chose &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;/P&gt;

&lt;P&gt;and initial mean&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.5000&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.5000&amp;nbsp;&amp;nbsp;&amp;nbsp; 7.5000.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The result I got is wrong. I would like to ask you if you could help me to understand what I have done wrong.&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;/P&gt;

&lt;P&gt;The C code is:&lt;/P&gt;

&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* I/O lib&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISOC&amp;nbsp; */&lt;BR /&gt;
	#include &amp;lt;mkl.h&amp;gt;&lt;/P&gt;

&lt;P&gt;#define DIM 3 /* Task dimension */&lt;BR /&gt;
	#define N 1 /* Number of observations */&lt;BR /&gt;
	#define NBLOCK 4 /* Number of blocks */&lt;/P&gt;

&lt;P&gt;int main()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; VSLSSTaskPtr task; /* SS task descriptor */&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int&amp;nbsp; i, j;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double x[DIM]={13, 10, 4}; /* Array for dataset */&lt;BR /&gt;
	&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; double W[2]; /* Array of accumulated weights */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; MKL_INT p, n, xstorage = VSL_SS_MATRIX_STORAGE_ROWS; ;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;MKL_INT covstorage = VSL_SS_MATRIX_STORAGE_FULL;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int status, block_idx;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize variables used in the computation of mean */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; p = DIM; n = N;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;double mean[3] = {5.5 ,6.5 ,7.5};&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;double cov[DIM*DIM] = {15, 15, 15, 15, 15, 15, 15, 15, 15};&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; W[0] = 4.0; W[1] = 16.0;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Create task */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSNewTask( &amp;amp;task, &amp;amp;p, &amp;amp;n, &amp;amp;xstorage, x, 0, 0 );&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;status = vsldSSEditCovCor( task, mean, cov, &amp;amp;covstorage, 0, 0 );&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize task parameters */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; // status = vsldSSEditTask( task, VSL_SS_ED_MEAN, &amp;amp;mean );&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSEditTask( task, VSL_SS_ED_ACCUM_WEIGHT, W );&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double theta[6]={1,1,2,3,3,2};&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Compute the mean estimate for block-based data using SS one-pass method */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; for( block_idx = 1;&amp;nbsp; block_idx&amp;lt;=NBLOCK; block_idx++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_1PASS );&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //GetNextDataBlock( x, N );&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; for( i=0; i&amp;lt;3; i++){&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; x&lt;I&gt; = theta[i + block_idx - 1];&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; printf(" covariance estimate:\n");&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; for ( i = 0; i &amp;lt; p; i++ ){&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( j = 0; j &amp;lt; p; j++ ) printf("%lf \t", cov[i*p+j]);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\n");&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; }&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; printf(" mean estimate:\n");&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; for ( i = 0; i &amp;lt; p; i++ ) {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%lf \n", mean&lt;I&gt;);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; }&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* De-allocate task resources */&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vslSSDeleteTask( &amp;amp;task );&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; }&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 22:55:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949734#M15132</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-17T22:55:28Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949735#M15133</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;I made several modifications in your example. Among them&lt;/P&gt;

&lt;P&gt;- number of blocks is set ot 3 as you process three additional blocks&lt;/P&gt;

&lt;P&gt;- both elements in the array W are set to 4 as you do not assign weights to observation vectors what means that each vector is assigned weight 1, by default; this means that accumulated weights/squares of weights are both equal to 4.&lt;/P&gt;

&lt;P&gt;-&amp;nbsp; modified copy loop as shown&amp;nbsp; &lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;x&lt;I&gt; = theta[i + DIM*block_idx]; &lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;and re-worked the major computation loop.&lt;/P&gt;

&lt;P&gt;Please, have a look.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
#include &amp;lt;stdio.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* I/O lib&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISOC&amp;nbsp; */
#include &amp;lt;mkl.h&amp;gt;

#define DIM 3 /* Task dimension */
#define N 1 /* Number of observations */
#define NBLOCK 3 /* Number of blocks */

int main()
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VSLSSTaskPtr task; /* SS task descriptor */

&amp;nbsp;&amp;nbsp;&amp;nbsp; int&amp;nbsp; i, j;

&amp;nbsp;&amp;nbsp;&amp;nbsp; double x[DIM]; /* Array for dataset */

&amp;nbsp;&amp;nbsp;&amp;nbsp; double W[2]; /* Array of accumulated weights */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MKL_INT p, n, xstorage = VSL_SS_MATRIX_STORAGE_ROWS; ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MKL_INT covstorage = VSL_SS_MATRIX_STORAGE_FULL;

&amp;nbsp;&amp;nbsp;&amp;nbsp; int status, block_idx;

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize variables used in the computation of mean */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p = DIM; n = N;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; double mean[3] = {5.5 ,6.5 ,7.5};
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; double cov[DIM*DIM] = {15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0};

&amp;nbsp;&amp;nbsp;&amp;nbsp; W[0] = 4.0; W[1] = 4.0;

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Create task */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSNewTask( &amp;amp;task, &amp;amp;p, &amp;amp;n, &amp;amp;xstorage, x, 0, 0 );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSEditCovCor( task, mean, cov, &amp;amp;covstorage, 0, 0 );

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize task parameters */
&amp;nbsp;&amp;nbsp;&amp;nbsp; // status = vsldSSEditTask( task, VSL_SS_ED_MEAN, &amp;amp;mean );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSEditTask( task, VSL_SS_ED_ACCUM_WEIGHT, W );

&amp;nbsp;&amp;nbsp;&amp;nbsp; double theta[]={13.0,10.0,4.0,1.0,1.0,2.0,3.0,3.0,2.0};

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Compute the mean estimate for block-based data using SS one-pass method */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( block_idx = 0;&amp;nbsp; block_idx&amp;lt;NBLOCK; block_idx++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( i=0; i&amp;lt;DIM; i++)
&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;I&gt; = theta[i + DIM*block_idx];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_1PASS );
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(" covariance estimate:\n");
&amp;nbsp;&amp;nbsp;&amp;nbsp; for ( i = 0; i &amp;lt; p; i++ ){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( j = 0; j &amp;lt; p; j++ ) printf("%lf \t", cov[i*p+j]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\n");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; printf(" mean estimate:\n");
&amp;nbsp;&amp;nbsp;&amp;nbsp; for ( i = 0; i &amp;lt; p; i++ ) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%lf \n", mean&lt;I&gt;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* De-allocate task resources */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vslSSDeleteTask( &amp;amp;task );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;The library allows you to avoid copy operation, and&amp;nbsp;you just need to register the address of the next vector (block) in the library as shown below&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
for( block_idx = 0; block_idx&amp;lt;NBLOCK; block_idx++)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSEditTask( task, VSL_SS_ED_OBSERV, theta+block_idx*DIM );
&amp;nbsp;&amp;nbsp;&amp;nbsp; status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_1PASS );
}
&lt;/PRE&gt;

&lt;P&gt;Generally, the library does not require you to provide the blocks of the equal size on each iteration. You just need to register the address of the next block&amp;nbsp;in the library using the proper editor as one above (or just copy the data to the same address given the array has sufficient room to store the data) and properly modify number of observations.&lt;/P&gt;

&lt;P&gt;Please, let me know if you have more questions.&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 09:49:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949735#M15133</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-18T09:49:30Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey!</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949736#M15134</link>
      <description>&lt;P&gt;Hi Andrey!&lt;/P&gt;

&lt;P&gt;Thank you very much for your help. Can I use this routine with the Robust Estimation of Covariance Matrix/ Mean? And if I do I replace this&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
status = vsldSSEditCovCor( task, mean, cov, &amp;amp;covstorage, 0, 0 );

status = vsldSSCompute( task, VSL_SS_COV, VSL_SS_METHOD_1PASS );&lt;/PRE&gt;

&lt;P&gt;&lt;CODE class="plain"&gt;with this&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
status = vsldSSEditRobustCovariance( task, &amp;amp;covstorage, &amp;amp;nparams, params, mean, cov );

status = vsldSSCompute( task, VSL_SS_ROBUST_COV, VSL_SS_METHOD_TBS );&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I ask you this because sometimes the covariance matrix is not positive define and the Cholesky decomposition fails. I read how to Parametrize a Correlation Matrix&amp;nbsp; ( &lt;A href="http://software.intel.com/en-us/node/497944" target="_blank"&gt;http://software.intel.com/en-us/node/497944&lt;/A&gt; ) but it is about the correlation matrix.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks again for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 12:50:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949736#M15134</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-18T12:50:16Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949737#M15135</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;Current version of Intel MKL robust covariance estimator does not support streaming mode.&lt;/P&gt;

&lt;P&gt;I just wonder if you investigated the reasons of why your covariance matrix fails the Cholesky decomposition? Do you work with the real data which&amp;nbsp;may result in&amp;nbsp;(tiny) negative eigenvalue of the covariance matrix? If so, what is output of the MKL Lapack pstf2 routine which does Cholesky decomposition with the full pivoting? If the issue is related to numerical aspects, would use of more robust decomposition such as SVD help?&amp;nbsp; Another thought is&amp;nbsp;to investigate presence of the&amp;nbsp;outliers in&amp;nbsp;your dataset. Have you run MKL Summary Stats&amp;nbsp;algorithm for detection of outliers?&lt;/P&gt;

&lt;P&gt;Thanks, Andrey&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 14:52:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949737#M15135</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-18T14:52:47Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey. I followed your</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949738#M15136</link>
      <description>&lt;P&gt;Hi Andrey. I followed your suggestions and I found out that the covariance matrix is symmetric but has negative eigenvalues. The problem I face is:&lt;/P&gt;

&lt;P&gt;I want to simulate from a multivariate normal distribution. When I try to do it with Matlab everything works. Matlab uses the function cholcov to factorize the covariance matrix. The description of this function is:&lt;/P&gt;

&lt;PRE&gt;
function [T,p] = cholcov(Sigma,flag)
%CHOLCOV  Cholesky-like decomposition for covariance matrix.
%   If SIGMA is not positive definite, T is computed from an eigenvalue
%   decomposition of SIGMA.  T is not necessarily triangular or square in
%   this case.  Any eigenvectors whose corresponding eigenvalue is close to
%   zero (within a small tolerance) are omitted.  If any remaining
%   eigenvalues are negative, T is empty.
&lt;/PRE&gt;

&lt;P&gt;I wrote a similar code in C but the factorization still fails. I tested my code with a small matrix and it is correct. I noticed that the eigenvectors/eigenvalues are different and so I think this is the reason.&amp;nbsp; For example the first 5 elements of the first row using Matlab is:&lt;/P&gt;

&lt;P&gt;-0.178640536933692&amp;nbsp; -0.171785233742083&amp;nbsp;&amp;nbsp; 0.003536032250076&amp;nbsp;&amp;nbsp; 0.215976356770781&amp;nbsp;&amp;nbsp; 0.047220738084061&lt;/P&gt;

&lt;P&gt;and using the function LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, a, lda, w ); is:&lt;/P&gt;

&lt;P&gt;-0.128768 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.028550 &amp;nbsp;&amp;nbsp; &amp;nbsp;0.101975 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.159201 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.099586 .&lt;/P&gt;

&lt;P&gt;The first five eigenvalues with C is -0.000004 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.000004 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.000004 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.000004 &amp;nbsp;&amp;nbsp; &amp;nbsp;-0.000003&lt;/P&gt;

&lt;P&gt;and with Matlab&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; 1.0e-12 *&lt;/P&gt;

&lt;P&gt;&amp;nbsp; -0.286064537835538&amp;nbsp; -0.254355758173010&amp;nbsp; -0.227684048920343&amp;nbsp; -0.211110573333574&amp;nbsp; -0.126353300135388.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I would like to ask you if&amp;nbsp; I am using a wrong function to calculate the eigenvalues.&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Mar 2014 12:12:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949738#M15136</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-23T12:12:00Z</dc:date>
    </item>
    <item>
      <title>I found why the eigenvalues</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949739#M15137</link>
      <description>&lt;P&gt;I found why the eigenvalues are not the same. It is because the covariance matrix calculated by Matlab and my C are similar but&amp;nbsp; not identical. I would like to ask you if there is a way to find the weighted covariance matrix using this type&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;IMG alt="Χωρίς τίτλο" height="78px" src="http://s27.postimg.org/uxkrg9io3/image.png" width="301px" /&gt;&lt;/P&gt;

&lt;P&gt;I think intel&amp;nbsp; by default computes the covariance matrix divided by one minus the sum of squares of the weights.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
	
&amp;nbsp;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Mar 2014 16:14:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949739#M15137</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-23T16:14:52Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949740#M15138</link>
      <description>&lt;P&gt;Hi Anas,&lt;/P&gt;

&lt;P&gt;What is maximal absolute difference between elements of the matrices calculated in C and Matlab?&lt;/P&gt;

&lt;P&gt;Yes, [d|s]syev function can be used to calculate eigen-values and, optionally, eigen-vectors of real symmetric matrix.&lt;/P&gt;

&lt;P&gt;Answering your question about weighted covariance matrix: yes, Intel MKL covers this case as well. To calculate, weighted covariance matrix you need to provide array w of weights (non-negative floating-point numbers) assigned to vectors of your data matrix on the stage of the task construction: status = vsl[d|s]SSNewTask(&amp;amp;task, p, n, xstorage, x, w, indices);&lt;/P&gt;

&lt;P&gt;or later, on the stage of setting parameters of the task:&amp;nbsp; status = vsldSSEditTask(task, VSL_SS_ED_WEIGHTS, w);&lt;/P&gt;

&lt;P&gt;The library returns unbiased estimate of the covariance matrix by dividing by B=W[0] - W[1] / W[0] where W[0] = sum {w(i), i=1,...,n} and W[1]= sum { w(i) * w(i), i=1,...,n}, n is number of observation vectors. In specific case when all w(i)=1, B=n-1. I believe Matlab version of covariance algorithm also applies the same approach&amp;nbsp;:"&lt;FONT face="Courier New"&gt;C = cov(x)&lt;/FONT&gt; or &lt;SPAN itemprop="syntax"&gt;&lt;TT&gt;&lt;FONT face="Courier New"&gt;C = cov(x,y)&lt;/FONT&gt;&lt;/TT&gt;&lt;/SPAN&gt; normalizes by &lt;TT&gt;&lt;FONT face="Courier New"&gt;N&lt;/FONT&gt;&lt;/TT&gt;&amp;nbsp;–&amp;nbsp;1, if &lt;TT&gt;&lt;FONT face="Courier New"&gt;N&lt;/FONT&gt;&lt;/TT&gt;&amp;nbsp;&amp;gt;&amp;nbsp;1, where &lt;TT&gt;&lt;FONT face="Courier New"&gt;N&lt;/FONT&gt;&lt;/TT&gt; is the number of observations. "&lt;/P&gt;

&lt;P&gt;If for some reasons you need another scaling factor, you can do this by using one of approaches below:&lt;/P&gt;

&lt;P&gt;- calculate weighted covariance matrix with MKL as described above and use the scaling factor you need: for example multiply elements of the covariance matrix by B / W[0]&lt;/P&gt;

&lt;P&gt;- calculate cross-product matrix &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;VSL_SS_CP &lt;/FONT&gt;&lt;/SPAN&gt;with MKL&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper" image-alt="F4D80E2E-BE33-447B-A28B-6006140000C5.gif"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/10186i214D5F1AE2DE72B9/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="F4D80E2E-BE33-447B-A28B-6006140000C5.gif" alt="F4D80E2E-BE33-447B-A28B-6006140000C5.gif" /&gt;&lt;/span&gt; (also see "Mathematical Notation and Definitions" section in Summary Statistics Chapter in MKL Manual), and normalize it by the factor you need: for example, multiply all elements of the cross-product matrix by 1 / W[0].&lt;/P&gt;

&lt;P&gt;Please, let me know, if you have additional questions&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2014 07:48:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949740#M15138</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-24T07:48:39Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey!</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949741#M15139</link>
      <description>&lt;P&gt;Hi Andrey!&lt;/P&gt;

&lt;P&gt;I computed the weighted covariance matrix with the routine of MKL and the maximal absolute difference between elements of the matrices calculated in C and Matlab is 4.9964e-07.&lt;/P&gt;

&lt;P&gt;I think that the problem is with the way I compute eigenvectors. The weighted covariance matrix is of size 72x72. When I compute the eigenvetors of the maxtrix cov(1:8, 1:8) the results are similar:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
C:

LAPACKE_dsyev (row-major, high-level) Example Program Results

 Eigenvalues
 -0.000054 1.427183 10.758958 52.897686 74.362089 136.253008 194.688280 350.1769
50

 Eigenvectors (stored columnwise)
 0.515386 0.159367 -0.286849 -0.669017 0.235831 0.099866 -0.294156 -0.164305
 0.405829 0.150487 0.037140 0.077003 -0.548590 -0.441154 0.265017 -0.489435
 0.285582 0.123878 0.309648 0.362790 0.128867 0.698942 0.011544 -0.412722
 -0.046588 0.166949 -0.275717 0.392072 0.671869 -0.415776 -0.026933 -0.339432
 -0.013717 -0.799634 -0.464384 0.020837 -0.051799 0.167395 0.135810 -0.308485
 0.505743 -0.166573 0.123221 0.014151 0.321240 -0.059478 0.644899 0.422453
 0.454486 -0.335560 0.153900 0.367831 -0.062415 -0.210976 -0.637902 0.257939
 0.153075 0.359133 -0.699940 0.353858 -0.256212 0.240732 0.033498 0.328240


&amp;gt;&amp;gt;MATLAB

&amp;gt;&amp;gt; [U,D] = eig(Sigma(1:N,1:N))
U =
    0.5154    0.1594   -0.2868   -0.6690    0.2358    0.0999   -0.2942   -0.1643
    0.4058    0.1505    0.0371    0.0770   -0.5486   -0.4412    0.2650   -0.4894
    0.2856    0.1239    0.3096    0.3628    0.1289    0.6989    0.0115   -0.4127
   -0.0466    0.1670   -0.2757    0.3921    0.6719   -0.4158   -0.0269   -0.3394
   -0.0137   -0.7996   -0.4644    0.0208   -0.0518    0.1674    0.1358   -0.3085
    0.5057   -0.1666    0.1232    0.0142    0.3212   -0.0595    0.6449    0.4225
    0.4545   -0.3356    0.1539    0.3678   -0.0624   -0.2110   -0.6379    0.2579
    0.1531    0.3591   -0.6999    0.3539   -0.2562    0.2407    0.0335    0.3282
D = -0.0000    1.4272   10.7589   52.8977   74.3620  136.2530  194.6883  350.1770
&amp;gt;&amp;gt;
------------------------------------------------------------------------------------------------&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;When I compute the eigenvetors of the maxtrix cov(1:9, 1:9) the first two columns are not similar anymore.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
LAPACKE_dsyev (row-major, high-level) Example Program Results
Weighted Covariance Matrix:

   56.3916   -5.4461   21.0892   14.2106   11.8545  -57.3334    4.1571  -32.3024   15.2373
   -5.4461  146.8146   25.6903   55.8912   51.6568  -48.5882  -60.4055  -57.3076  -16.0235
   21.0892   25.6903  135.4878   22.4742   59.0458  -61.5392  -51.8902  -22.3711  -37.1519
   14.2106   55.8912   22.4742  106.5974   25.5030  -34.2876  -11.3883  -56.1283   33.8852
   11.8545   51.6568   59.0458   25.5030   44.1879  -31.5876  -49.2822  -24.6174  -28.2669
  -57.3334  -48.5882  -61.5392  -34.2876  -31.5876  151.8341  -41.1556   43.9437  -35.8322
    4.1571  -60.4055  -51.8902  -11.3883  -49.2822  -41.1556  116.4474   25.3112   64.5246
  -32.3024  -57.3076  -22.3711  -56.1283  -24.6174   43.9437   25.3112   62.8033   -4.9204
   15.2373  -16.0235  -37.1519   33.8852  -28.2669  -35.8322   64.5246   -4.9204   84.1603

LAPACKE_dsyev (row-major, high-level) Example Program Results

 Eigenvalues:
 -0.000057 0.000023 10.019260 21.561065 54.367911 78.008325 148.580208 240.545184 351.642481

 Eigenvectors (stored columnwise)
 0.464211 0.286119 -0.253666 -0.138729 -0.688994 -0.161246 -0.197438 0.236286 -0.153382
 0.369437 0.207801 0.075771 -0.113015 0.137812 0.547265 0.479130 -0.106393 -0.492387
 0.266667 0.116239 0.350457 -0.079392 0.401792 -0.271112 -0.597882 -0.122541 -0.422891
 -0.102864 0.247021 -0.323244 0.270853 0.259084 -0.606857 0.415646 0.193232 -0.324115
 0.153243 -0.749641 -0.529701 -0.054766 0.048735 0.005765 -0.098534 -0.136057 -0.316769
 0.537240 -0.085383 0.121956 -0.028795 0.011747 -0.373801 0.306880 -0.544996 0.396636
 0.497502 -0.142657 0.019880 0.474899 0.280762 0.162971 -0.060372 0.561165 0.286842
 0.066352 0.405470 -0.608450 -0.322486 0.415615 0.164747 -0.207056 -0.103762 0.321663
 0.048082 -0.215439 0.191162 -0.744958 0.153808 -0.198146 0.225448 0.489173 0.082056


&amp;gt;&amp;gt;MATLAB

    0.0888   -0.5380   -0.2537   -0.1387   -0.6890   -0.1612   -0.1974    0.2363   -0.1534
    0.0522   -0.4206    0.0758   -0.1130    0.1378    0.5473    0.4791   -0.1064   -0.4924
    0.0065   -0.2908    0.3505   -0.0794    0.4018   -0.2711   -0.5979   -0.1225   -0.4229
    0.2676    0.0015   -0.3232    0.2709    0.2591   -0.6069    0.4156    0.1932   -0.3241
   -0.7518    0.1424   -0.5297   -0.0548    0.0487    0.0058   -0.0985   -0.1361   -0.3168
   -0.2827   -0.4648    0.1220   -0.0288    0.0117   -0.3738    0.3069   -0.5450    0.3966
   -0.3206   -0.4063    0.0199    0.4749    0.2808    0.1630   -0.0604    0.5612    0.2868
    0.3501   -0.2151   -0.6084   -0.3225    0.4156    0.1647   -0.2071   -0.1038    0.3217
   -0.2176    0.0372    0.1912   -0.7450    0.1538   -0.1981    0.2254    0.4892    0.0821

D =  -0.0000   -0.0000   10.0193   21.5611   54.3679   78.0083  148.5802  240.5452  351.6425&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;When I compute the eigenvetors of the maxtrix cov(1:10, 1:10) the first three columns are not similar anymore.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
Weighted Covariance Matrix:
   56.3916   -5.4461   21.0892   14.2106   11.8545  -57.3334    4.1571  -32.3024   15.2373  -12.0170
   -5.4461  146.8146   25.6903   55.8912   51.6568  -48.5882  -60.4055  -57.3076  -16.0235   23.2106
   21.0892   25.6903  135.4878   22.4742   59.0458  -61.5392  -51.8902  -22.3711  -37.1519   18.9639
   14.2106   55.8912   22.4742  106.5974   25.5030  -34.2876  -11.3883  -56.1283   33.8852   23.7952
   11.8545   51.6568   59.0458   25.5030   44.1879  -31.5876  -49.2822  -24.6174  -28.2669    7.0779
  -57.3334  -48.5882  -61.5392  -34.2876  -31.5876  151.8341  -41.1556   43.9437  -35.8322   10.3152
    4.1571  -60.4055  -51.8902  -11.3883  -49.2822  -41.1556  116.4474   25.3112   64.5246  -18.7151
  -32.3024  -57.3076  -22.3711  -56.1283  -24.6174   43.9437   25.3112   62.8033   -4.9204  -27.0933
   15.2373  -16.0235  -37.1519   33.8852  -28.2669  -35.8322   64.5246   -4.9204   84.1603  -23.3719
  -12.0170   23.2106   18.9639   23.7952    7.0779   10.3152  -18.7151  -27.0933  -23.3719   48.1540

LAPACKE_dsyev (row-major, high-level) Example Program Results

 Eigenvalues
 -0.000074 -0.000007 0.000069 14.383856 47.663747 56.938335 81.601720 150.841004 244.580663 356.869088

 Eigenvectors (stored columnwise)
 -0.481945 0.238691 -0.296280 -0.058899 -0.224708 -0.661197 -0.103156 -0.197077 -0.250968 0.139158
 -0.286255 0.310447 -0.042790 0.117771 0.076327 0.153157 0.575001 0.442529 0.085 446 0.492887
 -0.121402 0.321346 0.153835 0.274036 0.222007 0.314981 -0.307425 -0.595861 0.091624 0.420454
 0.138479 0.147031 -0.175741 -0.457146 0.261977 0.083460 -0.565433 0.428019 -0.190057 0.323579
 -0.414390 -0.691821 0.256296 -0.343323 0.189936 -0.044647 0.049596 -0.119904 0.111411 0.314305
 -0.444848 0.216592 0.258796 0.073873 0.130422 -0.097410 -0.323642 0.299107 0.570384 -0.369756
 -0.389791 0.198062 0.340298 -0.282169 -0.207850 0.437734 0.042489 -0.017191 -0.535665 -0.299269
 -0.229001 0.004085 -0.678527 -0.201394 0.422988 0.276068 0.171912 -0.215680 0.105579 -0.322852
 -0.179141 -0.272966 -0.026355 0.632220 0.416494 -0.041068 -0.145469 0.238512 -0.479687 -0.098481
 -0.213996 -0.287199 -0.382463 0.235318 -0.614075 0.390115 -0.291176 0.139765 0.138791 0.131193

&amp;gt;&amp;gt;MATLAB

&amp;gt;&amp;gt; [U,D] = eig(Sigma(1:N,1:N))
U =
   -0.3277    0.4663   -0.2286   -0.0589   -0.2247   -0.6612   -0.1032   -0.1971   -0.2510    0.1392
   -0.0137    0.3774   -0.1938    0.1178    0.0763    0.1532    0.5750    0.4425    0.0854    0.4929
    0.2155    0.2775   -0.1350    0.2740    0.2220    0.3150   -0.3074   -0.5959    0.0916    0.4205
   -0.0207   -0.0933   -0.2501   -0.4571    0.2620    0.0835   -0.5654    0.4280   -0.1901    0.3236
   -0.2651    0.1150    0.7953   -0.3433    0.1899   -0.0446    0.0496   -0.1199    0.1114    0.3143
    0.1233    0.5371    0.0902    0.0739    0.1304   -0.0974   -0.3236    0.2991    0.5704   -0.3698
    0.2028    0.4973    0.1361   -0.2822   -0.2078    0.4377    0.0425   -0.0172   -0.5357   -0.2993
   -0.6354    0.0646   -0.3240   -0.2014    0.4230    0.2761    0.1719   -0.2157    0.1056   -0.3229
   -0.2132    0.0332    0.2464    0.6322    0.4165   -0.0411   -0.1455    0.2385   -0.4797   -0.0985
   -0.5194   -0.0149    0.0671    0.2353   -0.6141    0.3901   -0.2912    0.1398    0.1388    0.1312

D =  -0.0000   -0.0000   -0.0000   14.3839   47.6638   56.9384   81.6017  150.8410  244.5806  356.8691&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	The eigenvectos change when the eigenvalues are close to zero. I did some search and found that MATLAB uses LAPACK routines to compute eigenvalues and eigenvectors: If the matrix is Real Symmetric it uses the dsyev (http://nf.nci.org.au/facilities/software/Matlab/techdoc/ref/eig.html)&lt;BR /&gt;
	Isn't it strange that the results are different?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;Matlab computes eigenvectors with this way:&lt;/P&gt;

&lt;P&gt;&amp;nbsp; [V,D] = eig(A) returns matrix V, whose columns are the right eigenvectors of A such that A*V = V*D. The eigenvectors in V are normalized so that the 2-norm of each is 1. Method: 'chol'Computes the generalized eigenvalues of A and B using the Cholesky factorization of B.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	The code I used is:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
/* Parameters */
#define N 9
#define LDA N

/* Main program */
int main() {

        /* Locals */
        MKL_INT n = N, lda = LDA, info;

        /* Local arrays */
        double w&lt;N&gt;;
        double a[LDA*N];

        fReadMtrx("weightedcov.txt", a, N, N);


        /* Executable statements */
        printf( "LAPACKE_dsyev (row-major, high-level) Example Program Results\n" );

        /* Solve eigenproblem */
        info = LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, a, lda, w );

        /* Check for convergence */
        if( info &amp;gt; 0 ) {
                printf( "The algorithm failed to compute eigenvalues.\n" );
                exit( 1 );
        }

        /* Print eigenvalues */
        print_matrix( "Eigenvalues", 1, n, w, 1 );

        /* Print eigenvectors */
        print_matrix( "Eigenvectors (stored columnwise)", n, n, a, lda );

        exit( 0 );
} /* End of LAPACKE_dsyev Example */

/* Auxiliary routine: printing a matrix */
void print_matrix( char* desc, MKL_INT m, MKL_INT n, double* a, MKL_INT lda ) {
        MKL_INT i, j;
        printf( "\n %s\n", desc );
        for( i = 0; i &amp;lt; m; i++ ) {
                for( j = 0; j &amp;lt; n; j++ ) printf( " %lf", a[i*lda+j] );
                printf( "\n" );
        }
}
void fReadMtrx(string f, double *mtrx, int nrow, int ncol)
{
  ifstream data(f.c_str(), ios::in);
  if (!data) {
    cerr &amp;lt;&amp;lt; "File " &amp;lt;&amp;lt; f &amp;lt;&amp;lt; " could not be opened." &amp;lt;&amp;lt; endl;
    exit(1);
  }
  for(int i = 0; i &amp;lt; nrow; i++)
    for(int j = 0; j &amp;lt; ncol; j++)
      data &amp;gt;&amp;gt; mtrx[i*ncol+j];
} // end of function fReadMtrx&lt;/N&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	Thank you very much for helping&amp;nbsp; me.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2014 23:09:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949741#M15139</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-25T23:09:27Z</dc:date>
    </item>
    <item>
      <title>Hi Anas,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949742#M15140</link>
      <description>&lt;P&gt;&lt;SPAN lang="EN"&gt;Hi Anas,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;per my discussion with Intel MKL Lapack team, we have few comments related to your question on eigen solver output:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;- you see the different eigen-vectors that correspond to eigen-values close to zero. We can consider those eigen-values as multiple up to some tolerance. In this case you can't expect that corresponding eigen-vectors are uniquely defined: if Au = lambda u and Av = lambda v, than linear combination of u and v is the eigen-vector corresponding to the same value, A (c1 u + c2 v) = lamba (c1 u + c2 v). It defines the sensitivity of resulting eigen-vectors to floating-point errors/perturbations in the matrix.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;- Thus, it does not make big sense to compare eigen-values/vectors returned by different algorithms. More reliable way to evaluate correctness of the algorithm is calculation of the quality metrics || A - U Lambda U^t || / || A || and |U^t U - I|| where A=U Lambda U^t is full eigen-decomposition of the matrix A of size n x n. Both metrics should be small ~O( n * eps ). Additional ways to evaluate correctness of the eigen-solver exist, but it makes sense to start with the one described above.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;Please, let me know if this answers your question&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN lang="EN"&gt;Andrey&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2014 09:39:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949742#M15140</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2014-03-26T09:39:04Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey!</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949743#M15141</link>
      <description>&lt;P&gt;Hi Andrey!&lt;/P&gt;

&lt;P&gt;I appreciate your help. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2014 08:32:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Different-matrix-multiplication-results-between-C-and-Matlab/m-p/949743#M15141</guid>
      <dc:creator>Anas_A_</dc:creator>
      <dc:date>2014-03-27T08:32:27Z</dc:date>
    </item>
  </channel>
</rss>

