<?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 Problems using Nonlinear Least Squares Solver (without Constraints) in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-using-Nonlinear-Least-Squares-Solver-without/m-p/817944#M4450</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I'm want to use the nonlinear solverof MKL but I couldn't acomplish my mission til now! I have readthe example offered with the documentation and some forumthreads, but there might still be somethingthat I didn't understand. I would appreciate some help.&lt;BR /&gt;&lt;BR /&gt;My experimental code:&lt;BR /&gt;I tried to use the solver to fit something really easy. Let my function to be a curve with10 points (i=0:10)given by a*(i-5)^2 + b. My "true coefficients" are a = 5 and b = 6 and I give the solver a=8 and b = 10 as a first estimation. The finals coefficients I got were: a = 6.37 and b = 2.66. What's wrong? &lt;BR /&gt;&lt;BR /&gt;Here my code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;bool &lt;/P&gt;&lt;P&gt;CurveFit::executeFitting(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;int nCoefficientsSize = 2;&lt;/P&gt;&lt;P&gt;int nValuesSize = 10;&lt;/P&gt;&lt;P&gt;int nMaxNumberOfIterations = 1000000;&lt;/P&gt;&lt;P&gt;int nMaxNumberOfIterationsTrialStep = 100;&lt;/P&gt;&lt;P&gt;double dSizeOfTrueRegion = 100;&lt;/P&gt;&lt;P&gt;double coefficients[2] = {8,10};&lt;/P&gt;&lt;P&gt;double stopCriteriaPrecisions[6] = {0.00001, 0.00001, 0.00001, 0.00001, 0.00001, 0.00001};&lt;/P&gt;&lt;P&gt;double values[10];&lt;/P&gt;&lt;P&gt;double jacobian[10];&lt;/P&gt;&lt;P&gt;_TRNSP_HANDLE_t handle;&lt;/P&gt;&lt;P&gt;int nOK = dtrnlsp_init(&amp;amp;handle, &amp;amp;nCoefficientsSize, &amp;amp;nValuesSize, &amp;amp;coefficients[0], &amp;amp;stopCriteriaPrecisions[0], &amp;amp;nMaxNumberOfIterations , &amp;amp;nMaxNumberOfIterationsTrialStep, &amp;amp;dSizeOfTrueRegion);&lt;/P&gt;&lt;P&gt;memset(&amp;amp;values[0], 0, nValuesSize*sizeof(double));&lt;/P&gt;&lt;P&gt;memset(&amp;amp;jacobian[0], 0, nValuesSize*nCoefficientsSize*sizeof(double));&lt;/P&gt;&lt;P&gt;int nRCI_Request = 0;&lt;/P&gt;&lt;P&gt;while( nRCI_Request &amp;gt;= 0)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if (nRCI_Request == 2)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;djacobi (extended_powell, &amp;amp;nCoefficientsSize, &amp;amp;nValuesSize, &amp;amp;jacobian[0], &amp;amp;coefficients[0], &amp;amp;stopCriteriaPrecisions[0]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else if(nRCI_Request == 1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;extended_powell (&amp;amp;nValuesSize, &amp;amp;nCoefficientsSize, &amp;amp;coefficients[0], &amp;amp;values[0]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_solve(&amp;amp;handle, &amp;amp;values[0], &amp;amp;jacobian[0], &amp;amp;nRCI_Request);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int nNumberOfIterations, nStopCriteriaValue;&lt;/P&gt;&lt;P&gt;double nFirstResidual, nFinalResidual;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_get(&amp;amp;handle, &amp;amp;nNumberOfIterations, &amp;amp;nStopCriteriaValue, &amp;amp;nFirstResidual, &amp;amp;nFinalResidual);&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_delete(&amp;amp;handle);&lt;/P&gt;&lt;P&gt;return true;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* routine for extended powell function calculation&lt;/P&gt;&lt;P&gt;m in: dimension of function value&lt;/P&gt;&lt;P&gt;n in: number of function variables&lt;/P&gt;&lt;P&gt;x in: vector for function calculation&lt;/P&gt;&lt;P&gt;f out: function value f(x) */&lt;/P&gt;&lt;P&gt;void CurveFit::extended_powell (int *m, int *n, double *x, double *f)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;double a = *x;&lt;/P&gt;&lt;P&gt;double b = *(x+1);&lt;/P&gt;&lt;P&gt;double a0 = 5;&lt;/P&gt;&lt;P&gt;double b0 = 6;&lt;/P&gt;&lt;P&gt;int nSize = *m;&lt;/P&gt;&lt;P&gt;double dCenter = 5;&lt;/P&gt;&lt;P&gt;double dist, yValue, fValue;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; nSize; i++)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;dist = i - dCenter;&lt;/P&gt;&lt;P&gt;yValue = a0*dist*dist + b0*dist;&lt;/P&gt;&lt;P&gt;fValue = a*dist*dist + b*dist;&lt;/P&gt;&lt;P&gt;*(f + i) = yValue - fValue;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;thank you, Vanessa&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2011 11:53:07 GMT</pubDate>
    <dc:creator>queinferno</dc:creator>
    <dc:date>2011-10-05T11:53:07Z</dc:date>
    <item>
      <title>Problems using Nonlinear Least Squares Solver (without Constraints)</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-using-Nonlinear-Least-Squares-Solver-without/m-p/817944#M4450</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I'm want to use the nonlinear solverof MKL but I couldn't acomplish my mission til now! I have readthe example offered with the documentation and some forumthreads, but there might still be somethingthat I didn't understand. I would appreciate some help.&lt;BR /&gt;&lt;BR /&gt;My experimental code:&lt;BR /&gt;I tried to use the solver to fit something really easy. Let my function to be a curve with10 points (i=0:10)given by a*(i-5)^2 + b. My "true coefficients" are a = 5 and b = 6 and I give the solver a=8 and b = 10 as a first estimation. The finals coefficients I got were: a = 6.37 and b = 2.66. What's wrong? &lt;BR /&gt;&lt;BR /&gt;Here my code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;bool &lt;/P&gt;&lt;P&gt;CurveFit::executeFitting(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;int nCoefficientsSize = 2;&lt;/P&gt;&lt;P&gt;int nValuesSize = 10;&lt;/P&gt;&lt;P&gt;int nMaxNumberOfIterations = 1000000;&lt;/P&gt;&lt;P&gt;int nMaxNumberOfIterationsTrialStep = 100;&lt;/P&gt;&lt;P&gt;double dSizeOfTrueRegion = 100;&lt;/P&gt;&lt;P&gt;double coefficients[2] = {8,10};&lt;/P&gt;&lt;P&gt;double stopCriteriaPrecisions[6] = {0.00001, 0.00001, 0.00001, 0.00001, 0.00001, 0.00001};&lt;/P&gt;&lt;P&gt;double values[10];&lt;/P&gt;&lt;P&gt;double jacobian[10];&lt;/P&gt;&lt;P&gt;_TRNSP_HANDLE_t handle;&lt;/P&gt;&lt;P&gt;int nOK = dtrnlsp_init(&amp;amp;handle, &amp;amp;nCoefficientsSize, &amp;amp;nValuesSize, &amp;amp;coefficients[0], &amp;amp;stopCriteriaPrecisions[0], &amp;amp;nMaxNumberOfIterations , &amp;amp;nMaxNumberOfIterationsTrialStep, &amp;amp;dSizeOfTrueRegion);&lt;/P&gt;&lt;P&gt;memset(&amp;amp;values[0], 0, nValuesSize*sizeof(double));&lt;/P&gt;&lt;P&gt;memset(&amp;amp;jacobian[0], 0, nValuesSize*nCoefficientsSize*sizeof(double));&lt;/P&gt;&lt;P&gt;int nRCI_Request = 0;&lt;/P&gt;&lt;P&gt;while( nRCI_Request &amp;gt;= 0)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if (nRCI_Request == 2)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;djacobi (extended_powell, &amp;amp;nCoefficientsSize, &amp;amp;nValuesSize, &amp;amp;jacobian[0], &amp;amp;coefficients[0], &amp;amp;stopCriteriaPrecisions[0]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else if(nRCI_Request == 1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;extended_powell (&amp;amp;nValuesSize, &amp;amp;nCoefficientsSize, &amp;amp;coefficients[0], &amp;amp;values[0]);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_solve(&amp;amp;handle, &amp;amp;values[0], &amp;amp;jacobian[0], &amp;amp;nRCI_Request);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int nNumberOfIterations, nStopCriteriaValue;&lt;/P&gt;&lt;P&gt;double nFirstResidual, nFinalResidual;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_get(&amp;amp;handle, &amp;amp;nNumberOfIterations, &amp;amp;nStopCriteriaValue, &amp;amp;nFirstResidual, &amp;amp;nFinalResidual);&lt;/P&gt;&lt;P&gt;nOK = dtrnlsp_delete(&amp;amp;handle);&lt;/P&gt;&lt;P&gt;return true;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* routine for extended powell function calculation&lt;/P&gt;&lt;P&gt;m in: dimension of function value&lt;/P&gt;&lt;P&gt;n in: number of function variables&lt;/P&gt;&lt;P&gt;x in: vector for function calculation&lt;/P&gt;&lt;P&gt;f out: function value f(x) */&lt;/P&gt;&lt;P&gt;void CurveFit::extended_powell (int *m, int *n, double *x, double *f)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;double a = *x;&lt;/P&gt;&lt;P&gt;double b = *(x+1);&lt;/P&gt;&lt;P&gt;double a0 = 5;&lt;/P&gt;&lt;P&gt;double b0 = 6;&lt;/P&gt;&lt;P&gt;int nSize = *m;&lt;/P&gt;&lt;P&gt;double dCenter = 5;&lt;/P&gt;&lt;P&gt;double dist, yValue, fValue;&lt;/P&gt;&lt;P&gt;for (int i = 0; i &amp;lt; nSize; i++)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;dist = i - dCenter;&lt;/P&gt;&lt;P&gt;yValue = a0*dist*dist + b0*dist;&lt;/P&gt;&lt;P&gt;fValue = a*dist*dist + b*dist;&lt;/P&gt;&lt;P&gt;*(f + i) = yValue - fValue;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;thank you, Vanessa&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2011 11:53:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-using-Nonlinear-Least-Squares-Solver-without/m-p/817944#M4450</guid>
      <dc:creator>queinferno</dc:creator>
      <dc:date>2011-10-05T11:53:07Z</dc:date>
    </item>
    <item>
      <title>Problems using Nonlinear Least Squares Solver (without Constrai</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-using-Nonlinear-Least-Squares-Solver-without/m-p/817945#M4451</link>
      <description>my mistake!!! :-/ &lt;BR /&gt;the jacobian vector has wrong size....</description>
      <pubDate>Wed, 05 Oct 2011 16:11:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problems-using-Nonlinear-Least-Squares-Solver-without/m-p/817945#M4451</guid>
      <dc:creator>queinferno</dc:creator>
      <dc:date>2011-10-05T16:11:12Z</dc:date>
    </item>
  </channel>
</rss>

