cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

c dll - variable parameter lists

PhilipOakley
5-Regular Member

c dll - variable parameter lists

Sort of silly question - can one create multiple
variants of the same function [compiled c code] where the function name is kept constant, but the
number of arguments is changed

This would simulate the optional parameters
available in regular functions.

The developer reference doesn't say either way.

By creating many FUNCTIONINFO structures, one per
option, it should be possible, but it does depend on
the core routines being able to discriminate between
MyFunction(a) and MyFunction(a,b) as having
different entry points [the code then adding the
optional b value before calling the common core code

Just a thought.

Philip Oakley
8 REPLIES 8

Don,t know exactly, but doesn't Mathcad itself have overloaded functions, or functions with optional parameters?

TTFN,
Eden
PhilipOakley
5-Regular Member
(To:IRstuff)

On 8/18/2009 5:10:32 PM, eden_mei wrote:
>Don,t know exactly, but
>doesn't Mathcad itself have
>overloaded functions, or
>functions with optional
>parameters?
>
>TTFN,
>Eden

MathCAD itself certainly does. But it hadn't been
clear how, or if, a user could do it them self.
Hence this question.

I wrote a c dll years ago, and now have a need
again, so I'm thinking about it.

The routine is a variant (i.e. with options) of
upfirdn so that I can code some wavelet functions.

Philip Oakley

The last time this subject came up was 2004, with no clean resolution: http://collab.mathsoft.com/read?52156,19e#52156

TTFN,
Eden

The question that comes to mind is: why code a function ? The Mathcad "program construct" copes more generally, and the answer around the Mathcad modularity is yes, as many variants, and as many parameters as long as each function in the collecting vector is valid. The result will be "that indexed" function in the vector. The other point is that the independent argument must be in vector form. The inconvenience is that all the parameters must be validated, whether it makes sense or not. For the exact question c-code, don't know. Something to try. But at least you can see my points and proofs in the attached.

Hope it helps.

Jean

... I should have passed the complete work sheet.

jmG
PhilipOakley
5-Regular Member
(To:ptc-1368288)

On 8/18/2009 10:40:57 PM, jmG wrote:
>The question that comes to
>mind is: why code a function ?
>The Mathcad "program
>construct" copes more
>generally, and the answer
>around the Mathcad modularity
>is yes, as many variants, and
>as many parameters as long as
>each function in the
>collecting vector is valid.
>The result will be "that
>indexed" function in the
>vector. The other point is
>that the independent argument
>must be in vector form. The
>inconvenience is that all the
>parameters must be validated,
>whether it makes sense or not.
>For the exact question c-code,
>don't know. Something to try.
>But at least you can see my
>points and proofs in the
>attached.
>
>Hope it helps.
>
>Jean

Hi Jean,

In this case I do have the code in MathCAD but it is soo sloow. It is essentially equivalent to an FFT (it is the core element of a 2d image transform), so getting enough of it hard coded would greatly reduce the frustration of waiting for execution.

The real hard bit is deciding on the balance between hard code of just the inner loop or ending up hard coding the whole transform. The latter removes a load of flexibility.

The really hard bit is finding the time 😉

Philip Oakley

>It is essentially equivalent to an FFT (it is the core element of a 2d image transform), <<br> _______________________

The core algorithm of the 2d image is the DCT.
They are built-in dct2d(M), idct2d(M). We have the construct of dct2d(M), but not the idct2d(M), which in fact idct2d(M) is the DCT-III.
I prefer saying "no capish" [understand nothing].

jmG
PhilipOakley
5-Regular Member
(To:ptc-1368288)

An extra tag along question.

Does anyone know how to get the current value of
ORIGIN into a c dll.

This is so I can make the function independent of
the ORIGIN setting (one optional parameter is the
position of the 'centre' of a vector, so that depend
on the users view about the ORIGIN.


Philip Oakley
Top Tags