2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011 - DIGITEO - Cedric DELAMARRE
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 /*--------------------------------------------------------------------------*/
13 #include "execvisitor.hxx"
16 #include "optimizationfunctions.hxx"
20 #include "elem_common.h"
21 #include "scioptimfunctions.h"
22 #include "localization.h"
26 ** optimization functions
30 OptimizationFunctions* Optimization::m_OptimizationFunctions;
32 void Optimization::addOptimizationFunctions(OptimizationFunctions* _opFunction)
34 m_OptimizationFunctions = _opFunction;
37 void Optimization::removeOptimizationFunctions()
39 m_OptimizationFunctions = NULL;
42 OptimizationFunctions* Optimization::getOptimizationFunctions()
44 return m_OptimizationFunctions;
52 /*--------------------------------------------------------------------------*/
53 OptimizationFunctions::OptimizationFunctions(std::wstring callerName)
58 m_wstrCaller = callerName;
61 m_pCallOptimCostfFunction = NULL;
62 m_pStringOptimCostfFunctionDyn = NULL;
63 m_pStringOptimCostfFunctionStatic = NULL;
66 m_pCallFsolveFctFunction = NULL;
67 m_pStringFsolveFctFunctionDyn = NULL;
68 m_pStringFsolveFctFunctionStatic = NULL;
70 m_pCallFsolveJacFunction = NULL;
71 m_pStringFsolveJacFunctionDyn = NULL;
72 m_pStringFsolveJacFunctionStatic = NULL;
74 // init static functions
75 if (callerName == L"optim")
77 m_staticFunctionMap[L"genros"] = (void*) C2F(genros);
78 m_staticFunctionMap[L"topt2"] = (void*) C2F(topt2);
79 m_staticFunctionMap[L"icsemc"] = (void*) C2F(icsemc);
80 m_staticFunctionMap[L"mcsec"] = (void*) C2F(mcsec);
82 else if (callerName == L"fsolve")
84 m_staticFunctionMap[L"fsol1"] = (void*) C2F(fsol1);
85 m_staticFunctionMap[L"fsolj1"] = (void*) C2F(fsolj1);
87 else if (callerName == L"lsqrsolve")
89 m_staticFunctionMap[L"lsqrsol1"] = (void*) C2F(lsqrsol1);
90 m_staticFunctionMap[L"lsqrsolj1"] = (void*) C2F(lsqrsolj1);
94 OptimizationFunctions::~OptimizationFunctions()
96 m_staticFunctionMap.clear();
99 /*------------------------------- public -------------------------------------------*/
101 void OptimizationFunctions::execCostf(int *ind, int *n, double *x, double *f, double *g, int *ti, float *tr, double *td)
104 if (m_pCallOptimCostfFunction)
106 callCostfMacro(ind, n, x, f, g, ti, tr, td);
108 else if (m_pStringOptimCostfFunctionDyn)
110 ConfigVariable::EntryPointStr* func = ConfigVariable::getEntryPoint(m_pStringOptimCostfFunctionDyn->get(0));
113 sprintf(errorMsg, _("Undefined fonction '%ls'.\n"), m_pStringOptimCostfFunctionDyn->get(0));
114 throw ast::InternalError(errorMsg);
116 ((costf_t)(func->functionPtr))(ind, n, x, f, g, ti, tr, td);
118 else if (m_pStringOptimCostfFunctionStatic)
120 ((costf_t)m_staticFunctionMap[m_pStringOptimCostfFunctionStatic->get(0)])(ind, n, x, f, g, ti, tr, td);
124 sprintf(errorMsg, _("User function '%s' have not been setted.\n"), "costf");
125 throw ast::InternalError(errorMsg);
130 void OptimizationFunctions::execFsolveFct(int* n, double* x, double* v, int* iflag)
133 if (m_pCallFsolveFctFunction)
135 callFsolveFctMacro(n, x, v, iflag);
137 else if (m_pStringFsolveFctFunctionDyn)
139 ConfigVariable::EntryPointStr* func = ConfigVariable::getEntryPoint(m_pStringFsolveFctFunctionDyn->get(0));
142 sprintf(errorMsg, _("Undefined fonction '%ls'.\n"), m_pStringFsolveFctFunctionDyn->get(0));
143 throw ast::InternalError(errorMsg);
145 ((fct_t)(func->functionPtr))(n, x, v, iflag);
147 else if (m_pStringFsolveFctFunctionStatic)
149 ((fct_t)m_staticFunctionMap[m_pStringFsolveFctFunctionStatic->get(0)])(n, x, v, iflag);
153 sprintf(errorMsg, _("User function '%s' have not been setted.\n"), "costf");
154 throw ast::InternalError(errorMsg);
157 void OptimizationFunctions::execFsolveJac(int* n, double* x, double* v, double* jac, int* ldjac, int* iflag)
160 if (m_pCallFsolveJacFunction)
162 callFsolveJacMacro(n, x, v, jac, ldjac, iflag);
164 else if (m_pStringFsolveJacFunctionDyn)
166 ConfigVariable::EntryPointStr* func = ConfigVariable::getEntryPoint(m_pStringFsolveJacFunctionDyn->get(0));
169 sprintf(errorMsg, _("Undefined fonction '%ls'.\n"), m_pStringFsolveJacFunctionDyn->get(0));
170 throw ast::InternalError(errorMsg);
172 // c or fortran jac fuction are the same proto as fct
173 ((fct_t)(func->functionPtr))(n, x, jac, iflag);
175 else if (m_pStringFsolveJacFunctionStatic)
177 // c or fortran jac fuction are the same proto as fct
178 ((fct_t)m_staticFunctionMap[m_pStringFsolveJacFunctionStatic->get(0)])(n, x, jac, iflag);
182 sprintf(errorMsg, _("User function '%s' have not been setted.\n"), "costf");
183 throw ast::InternalError(errorMsg);
188 void OptimizationFunctions::execLsqrsolveFct(int* m, int* n, double* x, double* v, int* iflag)
191 if (m_pCallFsolveFctFunction)
193 callLsqrsolveFctMacro(m, n, x, v, iflag);
195 else if (m_pStringFsolveFctFunctionDyn)
197 ConfigVariable::EntryPointStr* func = ConfigVariable::getEntryPoint(m_pStringFsolveFctFunctionDyn->get(0));
200 sprintf(errorMsg, _("Undefined fonction '%ls'.\n"), m_pStringFsolveFctFunctionDyn->get(0));
201 throw ast::InternalError(errorMsg);
203 ((lsqrfct_t)(func->functionPtr))(m, n, x, v, iflag);
205 else if (m_pStringFsolveFctFunctionStatic)
207 ((lsqrfct_t)m_staticFunctionMap[m_pStringFsolveFctFunctionStatic->get(0)])(m, n, x, v, iflag);
211 sprintf(errorMsg, _("User function '%s' have not been setted.\n"), "costf");
212 throw ast::InternalError(errorMsg);
215 void OptimizationFunctions::execLsqrsolveJac(int* m, int* n, double* x, double* v, double* jac, int* ldjac, int* iflag)
218 if (m_pCallFsolveJacFunction)
220 callLsqrsolveJacMacro(m, n, x, v, jac, ldjac, iflag);
222 else if (m_pStringFsolveJacFunctionDyn)
224 ConfigVariable::EntryPointStr* func = ConfigVariable::getEntryPoint(m_pStringFsolveJacFunctionDyn->get(0));
227 sprintf(errorMsg, _("Undefined fonction '%ls'.\n"), m_pStringFsolveJacFunctionDyn->get(0));
228 throw ast::InternalError(errorMsg);
230 // c or fortran jac fuction are the same proto as fct
231 ((lsqrjac_ext_t)(func->functionPtr))(m, n, x, jac, ldjac, iflag);
233 else if (m_pStringFsolveJacFunctionStatic)
235 // c or fortran jac fuction are the same proto as fct
236 ((lsqrjac_ext_t)m_staticFunctionMap[m_pStringFsolveJacFunctionStatic->get(0)])(m, n, x, jac, ldjac, iflag);
240 sprintf(errorMsg, _("User function '%s' have not been setted.\n"), "costf");
241 throw ast::InternalError(errorMsg);
246 void OptimizationFunctions::setXRows(int _iRows)
250 void OptimizationFunctions::setXCols(int _iCols)
256 void OptimizationFunctions::setCostfArgs(types::InternalType* _Args)
258 m_OptimArgs.push_back(_Args);
261 void OptimizationFunctions::setOptimCostfFunction(types::Callable* _func)
263 m_pCallOptimCostfFunction = _func;
266 bool OptimizationFunctions::setOptimCostfFunction(types::String* _func)
268 if (ConfigVariable::getEntryPoint(_func->get(0)))
270 m_pStringOptimCostfFunctionDyn = _func;
275 if (m_staticFunctionMap.find(_func->get(0)) != m_staticFunctionMap.end())
277 m_pStringOptimCostfFunctionStatic = _func;
285 void OptimizationFunctions::setFsolveFctArgs(types::InternalType* _Args)
287 m_fsolveFctArgs.push_back(_Args);
290 void OptimizationFunctions::setFsolveFctFunction(types::Callable* _func)
292 m_pCallFsolveFctFunction = _func;
295 bool OptimizationFunctions::setFsolveFctFunction(types::String* _func)
297 if (ConfigVariable::getEntryPoint(_func->get(0)))
299 m_pStringFsolveFctFunctionDyn = _func;
304 if (m_staticFunctionMap.find(_func->get(0)) != m_staticFunctionMap.end())
306 m_pStringFsolveFctFunctionStatic = _func;
313 void OptimizationFunctions::setFsolveJacArgs(types::InternalType* _Args)
315 m_fsolveJacArgs.push_back(_Args);
318 void OptimizationFunctions::setFsolveJacFunction(types::Callable* _func)
320 m_pCallFsolveJacFunction = _func;
323 bool OptimizationFunctions::setFsolveJacFunction(types::String* _func)
325 if (ConfigVariable::getEntryPoint(_func->get(0)))
327 m_pStringFsolveJacFunctionDyn = _func;
332 if (m_staticFunctionMap.find(_func->get(0)) != m_staticFunctionMap.end())
334 m_pStringFsolveJacFunctionStatic = _func;
342 int OptimizationFunctions::getXRows()
346 int OptimizationFunctions::getXCols()
351 /*------------------------------- private -------------------------------------------*/
353 void OptimizationFunctions::callCostfMacro(int *ind, int *n, double *x, double *f, double *g, int *ti, float *tr, double *td)
361 types::optional_list opt;
362 ast::ExecVisitor execFunc;
365 types::Double* pDblX = new types::Double(m_iXRows, m_iXCols);
366 C2F(dcopy)(n, x, &one, pDblX->get(), &one);
367 pDblX->IncreaseRef();
369 types::Double* pDblInd = new types::Double((double)(*ind));
370 pDblInd->IncreaseRef();
374 in.push_back(pDblInd);
376 for (int i = 0; i < (int)m_OptimArgs.size(); i++)
378 m_OptimArgs[i]->IncreaseRef();
379 in.push_back(m_OptimArgs[i]);
384 // new std::wstring(L"") is delete in destructor of ast::CommentExp
385 m_pCallOptimCostfFunction->invoke(in, opt, iRetCount, out, execFunc, ast::CommentExp(Location(), new std::wstring(L"")));
387 catch (const ast::InternalError& ie)
389 for (int i = 0; i < (int)m_OptimArgs.size(); i++)
391 m_OptimArgs[i]->DecreaseRef();
397 for (int i = 0; i < (int)m_OptimArgs.size(); i++)
399 m_OptimArgs[i]->DecreaseRef();
402 if (out.size() != iRetCount)
404 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
405 sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
407 throw ast::InternalError(errorMsg);
410 out[0]->IncreaseRef();
411 out[1]->IncreaseRef();
412 out[2]->IncreaseRef();
414 pDblX->DecreaseRef();
415 if (pDblX->isDeletable())
420 pDblInd->DecreaseRef();
421 if (pDblInd->isDeletable())
426 types::Double* pDblOut = NULL;
429 if (out[0]->isDouble() == false)
431 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
432 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
434 throw ast::InternalError(errorMsg);
437 pDblOut = out[0]->getAs<types::Double>();
438 if (pDblOut->isComplex() || pDblOut->isScalar() == false)
440 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
441 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
443 throw ast::InternalError(errorMsg);
446 *f = pDblOut->get(0);
448 out[0]->DecreaseRef();
449 if (out[0]->isDeletable())
455 if (out[1]->isDouble() == false)
457 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
458 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real matrix expected.\n"), pstrName, 2);
460 throw ast::InternalError(errorMsg);
463 pDblOut = out[1]->getAs<types::Double>();
464 if (pDblOut->isComplex())
466 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
467 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real matrix expected.\n"), pstrName, 2);
469 throw ast::InternalError(errorMsg);
472 C2F(dcopy)(n, pDblOut->get(), &one, g, &one);
474 out[1]->DecreaseRef();
475 if (out[1]->isDeletable())
481 if (out[2]->isDouble() == false)
483 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
484 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 3);
486 throw ast::InternalError(errorMsg);
489 pDblOut = out[2]->getAs<types::Double>();
490 if (pDblOut->isComplex() || pDblOut->isScalar() == false)
492 char* pstrName = wide_string_to_UTF8(m_pCallOptimCostfFunction->getName().c_str());
493 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 3);
495 throw ast::InternalError(errorMsg);
498 *ind = (int)pDblOut->get(0);
500 out[2]->DecreaseRef();
501 if (out[2]->isDeletable())
508 void OptimizationFunctions::callFsolveFctMacro(int *n, double *x, double *v, int *iflag)
516 types::optional_list opt;
517 ast::ExecVisitor execFunc;
520 types::Double* pDblX = new types::Double(m_iXRows, m_iXCols);
521 C2F(dcopy)(n, x, &one, pDblX->get(), &one);
522 pDblX->IncreaseRef();
527 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
529 m_fsolveFctArgs[i]->IncreaseRef();
530 in.push_back(m_fsolveFctArgs[i]);
535 // new std::wstring(L"") is delete in destructor of ast::CommentExp
536 m_pCallFsolveFctFunction->invoke(in, opt, iRetCount, out, execFunc, ast::CommentExp(Location(), new std::wstring(L"")));
538 catch (const ast::InternalError& ie)
540 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
542 m_fsolveFctArgs[i]->DecreaseRef();
548 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
550 m_fsolveFctArgs[i]->DecreaseRef();
553 if (out.size() != iRetCount)
555 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
556 sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
558 throw ast::InternalError(errorMsg);
561 out[0]->IncreaseRef();
563 pDblX->DecreaseRef();
564 if (pDblX->isDeletable())
569 types::Double* pDblOut = NULL;
572 if (out[0]->isDouble() == false)
574 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
575 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
577 throw ast::InternalError(errorMsg);
580 pDblOut = out[0]->getAs<types::Double>();
581 if (pDblOut->getRows() != m_iXRows || pDblOut->getCols() != m_iXCols)
583 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
584 sprintf(errorMsg, _("%s: Wrong size for output argument #%d: A matrix of size %d x %d expected.\n"), pstrName, 1, m_iXRows, m_iXCols);
586 throw ast::InternalError(errorMsg);
589 C2F(dcopy)(n, pDblOut->get(), &one, v, &one);
591 out[0]->DecreaseRef();
592 if (out[0]->isDeletable())
598 void OptimizationFunctions::callFsolveJacMacro(int *n, double *x, double *v, double* jac, int* ldjac, int *iflag)
606 types::optional_list opt;
607 ast::ExecVisitor execFunc;
610 types::Double* pDblX = new types::Double(m_iXRows, m_iXCols);
611 C2F(dcopy)(n, x, &one, pDblX->get(), &one);
612 pDblX->IncreaseRef();
617 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
619 m_fsolveJacArgs[i]->IncreaseRef();
620 in.push_back(m_fsolveJacArgs[i]);
625 // new std::wstring(L"") is delete in destructor of ast::CommentExp
626 m_pCallFsolveJacFunction->invoke(in, opt, iRetCount, out, execFunc, ast::CommentExp(Location(), new std::wstring(L"")));
628 catch (const ast::InternalError& ie)
630 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
632 m_fsolveJacArgs[i]->DecreaseRef();
638 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
640 m_fsolveJacArgs[i]->DecreaseRef();
643 if (out.size() != iRetCount)
645 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
646 sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
648 throw ast::InternalError(errorMsg);
651 out[0]->IncreaseRef();
653 pDblX->DecreaseRef();
654 if (pDblX->isDeletable())
659 types::Double* pDblOut = NULL;
662 if (out[0]->isDouble() == false)
664 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
665 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
667 throw ast::InternalError(errorMsg);
670 pDblOut = out[0]->getAs<types::Double>();
671 if (pDblOut->getRows() != *ldjac || pDblOut->getCols() != *n)
673 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
674 sprintf(errorMsg, _("%s: Wrong size for output argument #%d: A matrix of size %d x %d expected.\n"), pstrName, 1, *ldjac, *n);
676 throw ast::InternalError(errorMsg);
679 int iSize = (*ldjac) * (*n);
680 C2F(dcopy)(&iSize, pDblOut->get(), &one, jac, &one);
682 out[0]->DecreaseRef();
683 if (out[0]->isDeletable())
690 void OptimizationFunctions::callLsqrsolveFctMacro(int *m, int *n, double *x, double *v, int *iflag)
698 types::optional_list opt;
699 ast::ExecVisitor execFunc;
702 types::Double* pDblX = new types::Double(m_iXRows, m_iXCols);
703 C2F(dcopy)(n, x, &one, pDblX->get(), &one);
704 pDblX->IncreaseRef();
705 types::Double* pDblM = new types::Double((double)*m);
706 pDblM->IncreaseRef();
712 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
714 m_fsolveFctArgs[i]->IncreaseRef();
715 in.push_back(m_fsolveFctArgs[i]);
720 // new std::wstring(L"") is delete in destructor of ast::CommentExp
721 m_pCallFsolveFctFunction->invoke(in, opt, iRetCount, out, execFunc, ast::CommentExp(Location(), new std::wstring(L"")));
723 catch (const ast::InternalError& ie)
725 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
727 m_fsolveFctArgs[i]->DecreaseRef();
733 for (int i = 0; i < (int)m_fsolveFctArgs.size(); i++)
735 m_fsolveFctArgs[i]->DecreaseRef();
738 if (out.size() != iRetCount)
740 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
741 sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
743 throw ast::InternalError(errorMsg);
746 out[0]->IncreaseRef();
748 pDblX->DecreaseRef();
749 if (pDblX->isDeletable())
754 pDblM->DecreaseRef();
755 if (pDblM->isDeletable())
760 types::Double* pDblOut = NULL;
763 if (out[0]->isDouble() == false)
765 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
766 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
768 throw ast::InternalError(errorMsg);
771 pDblOut = out[0]->getAs<types::Double>();
772 if (pDblOut->getSize() != *m)
774 char* pstrName = wide_string_to_UTF8(m_pCallFsolveFctFunction->getName().c_str());
775 sprintf(errorMsg, _("%s: Wrong size for output argument #%d: A vector of %d expected.\n"), pstrName, 1, *m);
777 throw ast::InternalError(errorMsg);
780 C2F(dcopy)(m, pDblOut->get(), &one, v, &one);
782 out[0]->DecreaseRef();
783 if (out[0]->isDeletable())
788 void OptimizationFunctions::callLsqrsolveJacMacro(int *m, int *n, double *x, double *v, double *jac, int *ldjac, int *iflag)
796 types::optional_list opt;
797 ast::ExecVisitor execFunc;
800 types::Double* pDblX = new types::Double(m_iXRows, m_iXCols);
801 C2F(dcopy)(n, x, &one, pDblX->get(), &one);
802 pDblX->IncreaseRef();
803 types::Double* pDblM = new types::Double((double)*m);
804 pDblM->IncreaseRef();
810 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
812 m_fsolveJacArgs[i]->IncreaseRef();
813 in.push_back(m_fsolveJacArgs[i]);
818 // new std::wstring(L"") is delete in destructor of ast::CommentExp
819 m_pCallFsolveJacFunction->invoke(in, opt, iRetCount, out, execFunc, ast::CommentExp(Location(), new std::wstring(L"")));
821 catch (const ast::InternalError& ie)
823 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
825 m_fsolveJacArgs[i]->DecreaseRef();
831 for (int i = 0; i < (int)m_fsolveJacArgs.size(); i++)
833 m_fsolveJacArgs[i]->DecreaseRef();
836 if (out.size() != iRetCount)
838 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
839 sprintf(errorMsg, _("%s: Wrong number of input argument(s): %d expected.\n"), pstrName, iRetCount);
841 throw ast::InternalError(errorMsg);
844 out[0]->IncreaseRef();
846 pDblX->DecreaseRef();
847 if (pDblX->isDeletable())
852 pDblM->DecreaseRef();
853 if (pDblM->isDeletable())
858 types::Double* pDblOut = NULL;
861 if (out[0]->isDouble() == false)
863 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
864 sprintf(errorMsg, _("%s: Wrong type for output argument #%d: Real scalar expected.\n"), pstrName, 1);
866 throw ast::InternalError(errorMsg);
869 pDblOut = out[0]->getAs<types::Double>();
870 if (pDblOut->getSize() != *m **n)
872 char* pstrName = wide_string_to_UTF8(m_pCallFsolveJacFunction->getName().c_str());
873 sprintf(errorMsg, _("%s: Wrong size for output argument #%d: A vector of %d expected.\n"), pstrName, 1, *m);
875 throw ast::InternalError(errorMsg);
879 C2F(dcopy)(&iSize, pDblOut->get(), &one, jac, &one);
881 out[0]->DecreaseRef();
882 if (out[0]->isDeletable())