<?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 Help for Jacobian calculations in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825889#M5113</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The output is as follows..&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Cost function in 1st iteration - &lt;/P&gt;&lt;P&gt;-4.600000&lt;/P&gt;&lt;P&gt;-16.000000&lt;/P&gt;&lt;P&gt;-34.200000&lt;/P&gt;&lt;P&gt;-59.200000&lt;/P&gt;&lt;P&gt;-91.000000&lt;/P&gt;&lt;P&gt;-129.600000&lt;/P&gt;&lt;P&gt;-175.000000&lt;/P&gt;&lt;P&gt;Jacobian - &lt;/P&gt;&lt;P&gt;MKL User Defined&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-2.000000 -2.000000&lt;/P&gt;&lt;P&gt;-3.000000 -3.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-5.000000 -5.000000&lt;/P&gt;&lt;P&gt;-6.000000 -6.000000&lt;/P&gt;&lt;P&gt;-7.000000 -7.000000&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-9.000000 -9.000000&lt;/P&gt;&lt;P&gt;-16.000000 -16.000000&lt;/P&gt;&lt;P&gt;-25.000000 -25.000000&lt;/P&gt;&lt;P&gt;-36.000000 -36.000000&lt;/P&gt;&lt;P&gt;-49.000000 -49.000000&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-9.000000 -9.000000&lt;/P&gt;&lt;P&gt;-16.000000 -16.000000&lt;/P&gt;&lt;P&gt;-25.000000 -25.000000&lt;/P&gt;&lt;P&gt;-36.000000 -36.000000&lt;/P&gt;&lt;P&gt;-49.000000 -49.000000&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;These are the cost function and jacobian for 1st iteration which are same..&lt;BR /&gt;&lt;BR /&gt;But the cost function( new values of variable ) with djacobi is ...&lt;BR /&gt;Cost function in 2nd iteration&lt;/P&gt;&lt;P&gt;-0.022444&lt;/P&gt;&lt;P&gt;-0.036071&lt;/P&gt;&lt;P&gt;-0.040883&lt;/P&gt;&lt;P&gt;-0.036880&lt;/P&gt;&lt;P&gt;-0.024060&lt;/P&gt;&lt;P&gt;-0.002425&lt;/P&gt;&lt;P&gt;0.028026&lt;BR /&gt;&lt;BR /&gt;whereas afterusing myjacobi the output is,&lt;/P&gt;&lt;P&gt;Cost function in 2nd iteartion&lt;/P&gt;&lt;P&gt;0.780000&lt;/P&gt;&lt;P&gt;3.120000&lt;/P&gt;&lt;P&gt;7.020000&lt;/P&gt;&lt;P&gt;12.480000&lt;/P&gt;&lt;P&gt;19.500000&lt;/P&gt;&lt;P&gt;28.080000&lt;/P&gt;&lt;P&gt;38.220000&lt;BR /&gt;&lt;BR /&gt;if i feed the same data as cost and jacobian why there should be difference in next iteration?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Suresh&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2011 11:22:56 GMT</pubDate>
    <dc:creator>sureshdeoda</dc:creator>
    <dc:date>2011-09-30T11:22:56Z</dc:date>
    <item>
      <title>Help for Jacobian calculations</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825885#M5109</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I was trying to use trust region solver for one of my code. I found that the jacobian given by the solver is calculating only half of thevalues (i.e. n*m/2)whilefor rest of thecalculation it gives zeros and brakes out with the RCI_Request == -5. ??&lt;BR /&gt;I have tested solver with some small eqation where i have calculated the jacobian(i.e. (f(x) - f(x'))/(x - x')) and compared the same with jacobian given by the solver which are same but not for my original code.&lt;BR /&gt;One more thing is i found that, though i am giving initial guess as upper bounds ,while perturbing the variable in costfun calculation goes beyond upper bounds .??&lt;BR /&gt;&lt;BR /&gt;I know without code it will be difficul to find the errors, hope someone might be able to hint the possible reasons.&lt;BR /&gt;&lt;BR /&gt;followingare thecalls which i use. it may help&lt;BR /&gt;&lt;BR /&gt;if (dtrnlspbc_init (&amp;amp;handle, &amp;amp;n, &amp;amp;m, x, LW, UP, eps, &amp;amp;iter1, &amp;amp;iter2,&amp;amp;rs) != TR_SUCCESS) {}&lt;BR /&gt;if (dtrnlspbc_solve (&amp;amp;handle, fvec, fjac, &amp;amp;RCI_Request) != TR_SUCCESS) {}&lt;BR /&gt;if (RCI_Request == 1)&lt;BR /&gt;{	&lt;BR /&gt; CostFun(&amp;amp;m,&amp;amp;n,x,fvec);&lt;BR /&gt;}&lt;BR /&gt;if (RCI_Request == 2)&lt;BR /&gt;{			&lt;BR /&gt; if (djacobi (CostFun, &amp;amp;n, &amp;amp;m, fjac, x, eps) != TR_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;	return 0;&lt;BR /&gt; }&lt;BR /&gt; fp_temp= fopen("solverResFjac.dat","w");	&lt;BR /&gt; for(i=0;i&lt;M&gt;&lt;/M&gt;	fprintf(fp_temp,"%f\\n",fjac&lt;I&gt;);&lt;BR /&gt;&lt;BR /&gt; Jacobian(fjac1,n,m,x,fvec); // user defined jacobian &lt;BR /&gt;	fp_temp= fopen("solverResFjac1.dat","w");&lt;BR /&gt; for(i=0;i&lt;M&gt;&lt;/M&gt;	 fprintf(fp_temp,"%f\\n",fjac1&lt;I&gt;);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Thanks ,&lt;BR /&gt;Suresh &lt;/P&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Thu, 22 Sep 2011 08:31:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825885#M5109</guid>
      <dc:creator>sureshdeoda</dc:creator>
      <dc:date>2011-09-22T08:31:22Z</dc:date>
    </item>
    <item>
      <title>Help for Jacobian calculations</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825886#M5110</link>
      <description>&lt;DIV&gt;&amp;gt;&amp;gt; the RCI_Request == -5. ??&lt;/DIV&gt;&lt;DIV&gt;This is an unexpected output task status - please
  show a complete example demonstrating the claimed
  bug.&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2011 10:26:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825886#M5110</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2011-09-22T10:26:58Z</dc:date>
    </item>
    <item>
      <title>Help for Jacobian calculations</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825887#M5111</link>
      <description>&lt;P&gt;Hi Gennady , &lt;/P&gt;&lt;P&gt;Thanks for the reply. I found there are someproblem with my code..:) .&lt;/P&gt;&lt;P&gt;But still if my initial guess is one of the boundary condition, in jacobian it crosses the boundary condition which i dont want to happen ,So i am calculating jacobian.&lt;/P&gt;&lt;P&gt;I found the values are same in solver calculated and user defined but still the next iteartion values are different with both the cases. &lt;/P&gt;&lt;P&gt;Please let me know if i am missing something here..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;[bash]#include &lt;STDIO.H&gt;
#include &lt;MALLOC.H&gt;
#include &lt;MATH.H&gt;
#include &lt;MKL_RCI.H&gt;

void myJacobi(double *c,double *y,double *fjec,int n,int m,double *fvec);
void myCostFun(int *m, int *n, double *x, double *f);
double y[7];

int main()
{
			
	
	//double y[7];
	double xin[7];
	double c[3] = {3 ,2 ,3};
			
	/* n - number of function variables
	m - dimension of function value */
	int n = 3, m = 7;
	/* precisions for stop-criteria (see manual for more details) */
	double eps[6];
	/* solution vector. contains values x for f(x) */
	double *x;
	/* iter1 - maximum number of iterations
	iter2 - maximum number of iterations of calculation of trial-step */
	int iter1 = 1000, iter2 = 100;
	/* initial step bound */
	double rs = 100.0;
	/* reverse communication interface parameter */
	int RCI_Request;

	/* controls of rci cycle */
	int successful;
	/* function (f(x)) value vector */
	double *fvec;
	/* jacobi matrix */
	double *fjac,*fjac1;
	/* lower and upper bounds */
	double *LW, *UP;
	/* number of iterations */
	int iter;
	/* number of stop-criterion */
	int st_cr;
	/* initial and final residuals */
	double r1, r2;
	/* TR solver handle */
	_TRNSPBC_HANDLE_t handle;
	/* cycles counter */
	int i;
	
	/* memory allocation */
	x = (double*) malloc (sizeof (double)*n);
	fvec = (double*) malloc (sizeof (double)*m);
	LW = (double*) malloc (sizeof (double)*n);
	UP = (double*) malloc (sizeof (double)*n);
	fjac = (double*) malloc (sizeof (double)*m*n);
	fjac1 = (double*) calloc (m*n,sizeof (double));
	/* set precisions for stop-criteria */
	for (i = 0; i &amp;lt; 6; i++)
	{
		eps &lt;I&gt; = 0.00001;
	}

	/* set the initial guess */
	for (i = 0; i &amp;lt; n; i++)
	{
	x &lt;I&gt; = 4.2;	
	}
	/* set the initial values */
	for (i = 0; i &amp;lt; m; i++)
	fvec &lt;I&gt; = 0.0;
	for (i = 0; i &amp;lt; m*n; i++)
	fjac &lt;I&gt; = 0.0;
	/* set bounds */
	for (i = 0; i &amp;lt; n; i++)
	{
	LW &lt;I&gt; = 0;	
	UP &lt;I&gt; = 4;	
	}

	for(i=0;i&amp;lt;7;i++)
	{
		xin&lt;I&gt; = i+1;		
		y&lt;I&gt; = c[0]*xin&lt;I&gt; +c[1]*xin&lt;I&gt;*xin&lt;I&gt; +c[2]*xin&lt;I&gt;*xin&lt;I&gt;;
	}

	if (dtrnlspbc_init (&amp;amp;handle, &amp;amp;n, &amp;amp;m, x, LW, UP, eps, &amp;amp;iter1, &amp;amp;iter2,
	&amp;amp;rs) != TR_SUCCESS)
	{	
		printf ("| error in dtrnlspbc_initn");	
		return 0;
	}

	/* set initial rci cycle variables */
	RCI_Request = 0;
	successful = 0;
	/* rci cycle */
	while (successful == 0)
	{
	if (dtrnlspbc_solve (&amp;amp;handle, fvec, fjac, &amp;amp;RCI_Request) != TR_SUCCESS)
	{
		printf ("error in dtrnlspbc_solven");
		return 0;
	}
	/* according to rci_request value we do next step */
	if (RCI_Request == -1 ||
	RCI_Request == -2 ||
	RCI_Request == -3 ||
	RCI_Request == -4 ||
	RCI_Request == -5 ||
	RCI_Request == -6)
	/* exit rci cycle */
	successful = 1;

	if (RCI_Request == 1)
	{			
		myCostFun(&amp;amp;m, &amp;amp;n, x, fvec);	
		printf("Cost function n");
		for (i=0;i&lt;M&gt;);
		}
	}
	if (RCI_Request == 2)
	{
		/* compute jacobi matrix*/	
		if (djacobi(myCostFun, &amp;amp;n, &amp;amp;m, fjac, x, eps) != TR_SUCCESS)
		{			
			printf ("error in djacobin");		
			return 0;
		}
		
		myJacobi(x,y,fjac1,n,m,fvec);
		printf("Jacobiann MKLtt User definedn");
		for (i=0;i&lt;N&gt;,fjac1&lt;I&gt;);
		}
	}
	}
	
	if (dtrnlspbc_get (&amp;amp;handle, &amp;amp;iter, &amp;amp;st_cr, &amp;amp;r1, &amp;amp;r2) != TR_SUCCESS)
	{			
		return 0;
	}
	
	
	if (dtrnlspbc_delete (&amp;amp;handle) != TR_SUCCESS)
	{
		return 0;
	}


	printf ("The result isn");	
	for(i=0;i&lt;N&gt;);	
	//printf ("n The Cost is %fn");	

	/* free allocated memory */
	free (x);
	free (fvec);
	free (fjac);
	free (LW);
	free (UP);
	/* if final residual is less than required precision then print pass */
	if (r2 &amp;lt; 0.1)
	printf ("| dtrnlspbc ..........PASSn");
	/* else print failed */
	else
	printf ("| dtrnlspbc .........FAILEDn");	
	
	
	getch();

	return 0;
	
}



void myCostFun(int *m, int *n, double *x, double *f) //  (double* c,double *y,double *fvec)
{	
	int  i= 0;
	double fx[7];
	double xin[7];

	for(i=0;i&amp;lt;7;i++)
	{
		xin&lt;I&gt; = i+1;
		fx&lt;I&gt; = x[0]*xin&lt;I&gt; +x[1]*xin&lt;I&gt;*xin&lt;I&gt; +x[2]*xin&lt;I&gt;*xin&lt;I&gt;;		
		f&lt;I&gt; = (y&lt;I&gt;-fx&lt;I&gt;);
	}	
	//return resCost;
}



void myJacobi(double *c1,double *y,double *fjec,int n,int m,double *fvec)
{
	int i =0,j=0,k=0;
	float x[7];
	double fx[7];
	double fv[7];
	float var = 0.01;
	float del;
	double c[3];
	
	for(j = 0;j&lt;N&gt; = c1&lt;K&gt;;
		}
		del = (c&lt;J&gt;+var*c&lt;J&gt;)- c&lt;J&gt;;
		c&lt;J&gt;= c&lt;J&gt;+var*c&lt;J&gt;;
		for(i=0;i&lt;M&gt; = i+1;
						
			fx&lt;I&gt; = c[0]*x&lt;I&gt; +c[1]*x&lt;I&gt;*x&lt;I&gt; +c[2]*x&lt;I&gt;*x&lt;I&gt;;			
			fv&lt;I&gt; = (y&lt;I&gt;-fx&lt;I&gt;);

			fjec[j*m+i] = (fv&lt;I&gt; - fvec&lt;I&gt;)/del;

		}
	}


}[/bash]&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/M&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/K&gt;&lt;/N&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/N&gt;&lt;/I&gt;&lt;/N&gt;&lt;/M&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/MKL_RCI.H&gt;&lt;/MATH.H&gt;&lt;/MALLOC.H&gt;&lt;/STDIO.H&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Suresh</description>
      <pubDate>Fri, 30 Sep 2011 06:08:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825887#M5111</guid>
      <dc:creator>sureshdeoda</dc:creator>
      <dc:date>2011-09-30T06:08:18Z</dc:date>
    </item>
    <item>
      <title>Help for Jacobian calculations</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825888#M5112</link>
      <description>well, sounds better :), b&lt;SPAN style="font-family: verdana, sans-serif;"&gt;ut somehow I don't see when the&lt;/SPAN&gt;&lt;SPAN style="font-family: verdana, sans-serif;"&gt;next iteration values are different with both the cases.&lt;/SPAN&gt;&lt;DIV&gt;please show these values which you received.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 30 Sep 2011 10:42:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825888#M5112</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2011-09-30T10:42:20Z</dc:date>
    </item>
    <item>
      <title>Help for Jacobian calculations</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825889#M5113</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The output is as follows..&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Cost function in 1st iteration - &lt;/P&gt;&lt;P&gt;-4.600000&lt;/P&gt;&lt;P&gt;-16.000000&lt;/P&gt;&lt;P&gt;-34.200000&lt;/P&gt;&lt;P&gt;-59.200000&lt;/P&gt;&lt;P&gt;-91.000000&lt;/P&gt;&lt;P&gt;-129.600000&lt;/P&gt;&lt;P&gt;-175.000000&lt;/P&gt;&lt;P&gt;Jacobian - &lt;/P&gt;&lt;P&gt;MKL User Defined&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-2.000000 -2.000000&lt;/P&gt;&lt;P&gt;-3.000000 -3.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-5.000000 -5.000000&lt;/P&gt;&lt;P&gt;-6.000000 -6.000000&lt;/P&gt;&lt;P&gt;-7.000000 -7.000000&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-9.000000 -9.000000&lt;/P&gt;&lt;P&gt;-16.000000 -16.000000&lt;/P&gt;&lt;P&gt;-25.000000 -25.000000&lt;/P&gt;&lt;P&gt;-36.000000 -36.000000&lt;/P&gt;&lt;P&gt;-49.000000 -49.000000&lt;/P&gt;&lt;P&gt;-1.000000 -1.000000&lt;/P&gt;&lt;P&gt;-4.000000 -4.000000&lt;/P&gt;&lt;P&gt;-9.000000 -9.000000&lt;/P&gt;&lt;P&gt;-16.000000 -16.000000&lt;/P&gt;&lt;P&gt;-25.000000 -25.000000&lt;/P&gt;&lt;P&gt;-36.000000 -36.000000&lt;/P&gt;&lt;P&gt;-49.000000 -49.000000&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;These are the cost function and jacobian for 1st iteration which are same..&lt;BR /&gt;&lt;BR /&gt;But the cost function( new values of variable ) with djacobi is ...&lt;BR /&gt;Cost function in 2nd iteration&lt;/P&gt;&lt;P&gt;-0.022444&lt;/P&gt;&lt;P&gt;-0.036071&lt;/P&gt;&lt;P&gt;-0.040883&lt;/P&gt;&lt;P&gt;-0.036880&lt;/P&gt;&lt;P&gt;-0.024060&lt;/P&gt;&lt;P&gt;-0.002425&lt;/P&gt;&lt;P&gt;0.028026&lt;BR /&gt;&lt;BR /&gt;whereas afterusing myjacobi the output is,&lt;/P&gt;&lt;P&gt;Cost function in 2nd iteartion&lt;/P&gt;&lt;P&gt;0.780000&lt;/P&gt;&lt;P&gt;3.120000&lt;/P&gt;&lt;P&gt;7.020000&lt;/P&gt;&lt;P&gt;12.480000&lt;/P&gt;&lt;P&gt;19.500000&lt;/P&gt;&lt;P&gt;28.080000&lt;/P&gt;&lt;P&gt;38.220000&lt;BR /&gt;&lt;BR /&gt;if i feed the same data as cost and jacobian why there should be difference in next iteration?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Suresh&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2011 11:22:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Help-for-Jacobian-calculations/m-p/825889#M5113</guid>
      <dc:creator>sureshdeoda</dc:creator>
      <dc:date>2011-09-30T11:22:56Z</dc:date>
    </item>
  </channel>
</rss>

