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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

various userefi tools

radair
2-Guest

various userefi tools

Philip,

I've attached a collection of things I've posted over the years that help with creating userefi functions in general and c++ arrays in particular. The attached file is named _zip to avoid firewill issues with .zip files automatically running. Within the zip is an exe file called CreateUserEfiXMLFile.exe that reads the userdll comment section and creates the Mathcad xml file which allows using the insert function menu to display comments on how to use the userefi functions. Some firewalls may remove that from the archive.

In addition, there are several vc6 projects (as well as a userefi wizard for vc6) that show the various ways to make c/c++ userdlls.

The vc6 project directly of interest here is called "Cpp Arrays - mc11 wrksheet wo images" which has a function called "fCppMatrixTest" in the "Cpp Arrays.cpp" file that demonstrates how to attach cpp arrays to the matrices passed into a userdll by Mathcad. There are several options for doing "c-like" matrix operations such as multiplication and transpose. Try the various options to see what sorts of errors pop up in Mathcad worksheets.

Note that as advertised, I didn't create the class to attach to immutable objects, so all the stuff done with LPCCOMPLEXARRAY in this thread might cause issues with attaching to those objects. I haven't gone through and added code that allows fixing that for the simple reason that the tutorial is hard enough for people who actually want to go through all the c++ class code. The point of the tutorial is mainly designed to give c programmers some c++ capability without having them learn c++, so other than knowing where to put a breakpoint in the BoundsCheck function in the "Cpp Array Allocation.h" file, there isn't a real need to read through the code. Just remember to use M[i] = ... rather than *M=...;++M; to get the benefits of bounds checking.

I decided to leave in block matrix multiplication for those who are wondering about optimization. I'm sure that many will find it surprising that code requiring more operations can actually run 5x faster due to how the cache gets utilized.

Also note that the vc6 project is set up to copy the dll output into the mathcad directory which allows one to run the debugger and launch Mathcad in a seamless manner. Translating to newer versions of visual studio will require modifying the project settings in the translated project to keep that behavior. Also note, depending on the type of Mathcad license on the computer, you may or may not be able to just punch the run button in visual studio and have things run in debug mode. I don't think that's an issue with mc14, but it is in prior versions.

Robert
2 REPLIES 2
PhilipOakley
5-Regular Member
(To:radair)

Robert,

A useful set of tools. I'll probably stick with basic C at the moment, as I'm trying not to do any big (1000's loc) coding.

I'm coding a multiband filter with 2d capability to support wavelets, but trying to be minimalist in the functions coded.

I'll post some results when I have it tidied up.

Philip Oakley

On 9/14/2009 4:40:29 AM, philipoakley wrote:
>Robert,
>
>A useful set of tools. I'll
>probably stick with basic C at
>the moment, as I'm trying not
>to do any big (1000's loc)
>coding.
>
>I'm coding a multiband filter
>with 2d capability to support
>wavelets, but trying to be
>minimalist in the functions
>coded.
>
>I'll post some results when I
>have it tidied up.
>
>Philip Oakley

Philip,

Keep in mind that the matrix class is designed to give the c user bounds checking ability while preserving normal c array notation, not multiplication of big arrays. The big arrays are used as a specific example to show that the common assumption that c is much faster than c++ isn't justified.

Robert
Top Tags