Skip to main content
1-Visitor
February 1, 2012
Solved

MathcadAllocate

  • February 1, 2012
  • 3 replies
  • 5072 views

Hi Community,

I need a little help with the MathcadAllocate Command, what I understood so far is that I am able to allocate with this command a certain amount of memory, still I do not know for what I am allocating this memory, means how to explain the code that I want to allocate the Memory for my output COMPLEXSCALAR, I really dont get it and the help is not quite usefull on that topic, my search in the forum so far didn't help either.

Would be nice if you have some sample function where I can see how to allocate the memory correct.

Thanks in advance,

David

Best answer by LucMeekes

Hi David,

you do not need to allocate memory for a scalar, net even if it's complex. The only (allowed output) structures that you need to allocate memory for are strings (using MathcadAllocate) and arrays (vectors and matrices of complex scalars, using MathcadArrayAllocate).

For more information consult the provided examples (in the UserEFI directory) of 'cmplxsum' (which contains a function producing a complex scalar and does not use a memory allocator) and 'simple' (which contains a function that multiplies an array with a scalar, producing an array and therefore uses MathcadArrayAllocate).

Success!

Luc

3 replies

24-Ruby III
February 2, 2012

Hello!

Look in the Mathcad Help: "Developer's Reference":

Pic.png

Pic_1.png

Also, maybe this will helps you: "Mathcad User Guide - Creating a User DLL".

1-Visitor
February 2, 2012

Hi Vladimir,

Thanks allot for the help, but sadly thats what I already have found myself, but it is still a bit unclear to me, as the help leaves out the syntax and is completely missing an example.

The MathcadArrayAllocate command owns his own syntax, so I tell the programm allocate memory for a certain array (taken out of the developers reference):

BOOL MathcadArrayAllocate(array, rows, cols, allocateReal,

allocateImaginary)

COMPLEXARRAY* const array;

unsigned int rows;

unsigned int cols;

BOOL allocateReal;

BOOL allocateImaginary;

So if I want to do the same for a ComplexScalar, means I will have to use the Mathcadallocate command, but how do I define to allocate the memory for my output variable, for example OUTPUT1? When I try to do this in a classical c scheme, somehting like that:

double *line;

line = malloc(sizeof(double));

Is there a similar procedure for MathcadAllocate, or did I understand that completely wrong? Means I do not allocate the memory for a certain variable, I do it for the whole output?

Thanks in Advance for any replies, every help is welcome.

Regards

David

24-Ruby III
February 2, 2012

David,

Do you have an active maintenance for Mathcad? If yes, then create a new "Сase" with your question to PTC's technical support, here: "Log a New Case"

LucMeekes23-Emerald IVAnswer
23-Emerald IV
February 2, 2012

Hi David,

you do not need to allocate memory for a scalar, net even if it's complex. The only (allowed output) structures that you need to allocate memory for are strings (using MathcadAllocate) and arrays (vectors and matrices of complex scalars, using MathcadArrayAllocate).

For more information consult the provided examples (in the UserEFI directory) of 'cmplxsum' (which contains a function producing a complex scalar and does not use a memory allocator) and 'simple' (which contains a function that multiplies an array with a scalar, producing an array and therefore uses MathcadArrayAllocate).

Success!

Luc

1-Visitor
February 3, 2012

He Guys,

Thanks for your quick replies, the information Luc gave me was exactlty what I was looking for, the little piece of information I have been missing.

Thanks allot to all of you!

Have a nice weekend!

David

24-Ruby III
February 3, 2012

I'm glad that you solve your problem.