<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aptech &#187; Answers for "dllcall with function as input"</title>
	<atom:link href="http://www.aptech.com/questions/dll-call-with-function-as-input/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aptech.com</link>
	<description></description>
	<lastBuildDate>Fri, 08 Feb 2013 19:12:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>By: Aptech</title>
		<link>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2740</link>
		<comments>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2740#comments</comments>
		<pubDate>Fri, 07 Dec 2012 19:50:56 +0000</pubDate>
		<dc:creator>Aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2740</guid>
		<description><![CDATA[Many optimization codes have a reverse communication interface where the compiled code (FORTRAN/C/C++) will return a specific return value when it would like the objective function to be evaluated along with the values at which it would like them evaluated &#8230; <a href="http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2740">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Many optimization codes have a reverse communication interface where the compiled code (FORTRAN/C/C++) will return a specific return value when it would like the objective function to be evaluated along with the values at which it would like them evaluated at.</p>
<p>Below is a simple example of the concept. For this example, we will assume that we have a FORTRAN function that will assign <tt>ret</tt> to be equal to 1, assign the values at which it would like the function evaluated to <tt>parmout</tt> and then return whenever it would like a function evaluation. You could then set up your GAUSS code something like this:</p>
<pre>ret = 1;
parmin = zeros(4, 1);
parmout = zeros(4, 1);
ans = zeros(4,1);

<span style="color: #0000ff;">do while</span> (ret);
   <span style="color: #0000ff;">dllcall</span> fortranOptRoutine(parmin, parmout, ans, ret);

   <span style="color: #0000ff;">if</span> (ret == 1);
      parmin = myFunc(parmout);
   <span style="color: #0000ff;">endif;</span>
<span style="color: #0000ff;">endo</span>;

<span style="color: #0000ff;">proc</span> (1) = myFunc(x);
   <span style="color: #0000ff;">retp</span>(x*x);
<span style="color: #0000ff;">endp</span>;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2740/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: econwang</title>
		<link>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2739</link>
		<comments>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2739#comments</comments>
		<pubDate>Fri, 07 Dec 2012 19:13:13 +0000</pubDate>
		<dc:creator>econwang</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2739</guid>
		<description><![CDATA[I do have the FORTRAN source code which does optimization, in this optimization subroutine, there is a call to another FORTRAN subroutine, say FCN(N, X, F): subroutine FCN(N,X,F) double precision X, F F = x*x return end which defines the objective function.   I want &#8230; <a href="http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2739">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I do have the FORTRAN source code which does optimization, in this optimization subroutine, there is a call to another FORTRAN subroutine, say FCN(N, X, F):</p>
<pre>
subroutine FCN(N,X,F)
   double precision X, F
   F = x*x
   return
end
</pre>
<p>which defines the objective function.</p>
<p> </p>
<p>I want to compile the optimization subroutine and call it within GAUSS, while the definition of the objective function FCN  is written in GAUSS rather than Fortran.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2739/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: Aptech</title>
		<link>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2738</link>
		<comments>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2738#comments</comments>
		<pubDate>Fri, 07 Dec 2012 17:54:35 +0000</pubDate>
		<dc:creator>Aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2738</guid>
		<description><![CDATA[You cannot directly pass a GAUSS procedure into a Fortran function that takes a function pointer as an argument. There may be a work around. Could you provide some information about the Fortan code? Do you have the source code?]]></description>
			<content:encoded><![CDATA[<p>You cannot directly pass a GAUSS procedure into a Fortran function that takes a function pointer as an argument. There may be a work around. Could you provide some information about the Fortan code? Do you have the source code?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2738/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: econwang</title>
		<link>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2733</link>
		<comments>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2733#comments</comments>
		<pubDate>Fri, 07 Dec 2012 10:37:53 +0000</pubDate>
		<dc:creator>econwang</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2733</guid>
		<description><![CDATA[Thanks. I want to know how to pass a GAUSS function into a compiled Fortran function that takes a function pointer as an argument.]]></description>
			<content:encoded><![CDATA[<p>Thanks.</p>
<p>I want to know how to pass a GAUSS function into a compiled Fortran function that takes a function pointer as an argument.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2733/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: Aptech</title>
		<link>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2714</link>
		<comments>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2714#comments</comments>
		<pubDate>Thu, 06 Dec 2012 22:29:21 +0000</pubDate>
		<dc:creator>Aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2714</guid>
		<description><![CDATA[Functions that are called with dllcall can only accept GAUSS variables as inputs. Are you wanting to save the step of assigning the output of a GAUSS procedure to a variable before passing it to the function you are calling &#8230; <a href="http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2714">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Functions that are called with <tt>dllcall</tt> can only accept GAUSS variables as inputs.</p>
<p>Are you wanting to save the step of assigning the output of a GAUSS procedure to a variable before passing it to the function you are calling with <tt>dllcall</tt>? Or are you wanting to try to pass a GAUSS function in to a compiled (C/C++/Fortran) function that takes a function pointer as an argument?</p>
<p>If you provide a little more information, I may be able to help you accomplish your end goal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/dll-call-with-function-as-input/#answer-2714/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.aptech.com @ 2013-02-09 01:42:54 --