C_R

3577 Reputation

21 Badges

6 years, 96 days

MaplePrimes Activity


These are replies submitted by C_R

@acer 

A perfect oneliner leaving even space for a "why comment"

codegen[makeproc](TheList, parameters = map(`::`, [proc_params], double));# double required because CodeGeneration[C] sometimes puts int instead of double.

Since codegen[C] did not show this effect: Do you think its worth bringing this difference to the attention of Maplesoft?

Thank you!

 

Visual Studio Community 2017 and 2019 replace the Express Edition.

A bit hidden when following the download link in help(Setup, Compiler):

On the MS download pages: There is no download link to Visual Studio Community 2017. Installing another 2017 download, will list the Community package under the Available tab in the Visual Studio Installer.  

Desktop development with C++ must be installed additionally (available under the Workloads tab of the package).

These are the new paths:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat

@tomleslie 

Before asking I consulted indets and type\structure (where indets points to). In the later I could not find an appropriate match. That’s where I stopped.

I should have gone to the type help page (referenced by type\structure) and browsed through the more than 250 (!!!) types. I'm not sure I would have recognized suffix on the first go, since this word had no meaning in my life (so far).

That’s why I consider nm`s answer the closest in my reach.

The help page of type\structure is quite intimidating for someone who only knows "normal" types of programming languages. This rich choice of types reminds me of the concept of function, which is used much more narrowly in engineering than in mathematics. Acer has made some efforts to introduce me to this level of abstraction.

The type command and its uses is another good example that Maple is not a programming language.

Thank you for taking your time!

@acer

I was not aware of that (implication by the choice of a command). Now it makes sense.

The alternative for the (undocumented?) `if` call is indeed intersting.

Thank you for these insights!

@Carl Love @nm @tomleslie

These are all excellent answers!

It's difficult to pick a winner.

nm answer uses commands that can be found in the help system.

That suffixed can be used as a command without "type" suprises. From the help system I can deduce at most a use like this

            select(X -> `if`(type(X, 'suffixed(t, integer)'), true, false), lst)

(I assume that Carls &under is required for other structures than sets.)

Thanks allot!!!

@Joe Riel @Thomas Richard 

Here is an update what I could figure out:

  • ExternalCCodeGen I was refering to is actually not an old Maple command as I assumed, but a procedure written by the author of the video. A call to CodeGeneration (to create a C code string) and to FileTools[Text][WriteFile] (to write the string to a file) could be used for a replacement of ExternalCCodeGen.
  • Much simpler to save is Thomas solution.
  • Saving is also possible with the External C/Library Block App and the option “Text Area”. In the text area: copy&paste Maple Output of C code -> optionally modify -> save file.

Using C code in MapleSim with the External C/Library Block App requires customizing the generated code to definitions (#define) and parameters accepted by the App. Knowledge of C is needed for that.

@chriskiwi 

I meant: You could upload screen shots that we can see how a small palette looks like.

I use a PC with monitors of different resolutions, which requires adjusting the scaling options. Maple in native 4K resolution works, but menus are just too small on a notebook (but a real joy on a large screen)

attached samples (green arrow for upload) are also helpfull.

@Joe Riel 

I did that (with the Custom Component App) before I generated the C code with the same list of equations.

That worked well and matched the kinematics of a MapleSim model.

Now I want to test (verify) C code with MapleSim before using it outside MapleSim. A test simliar to what is demonstrated here https://www.youtube.com/watch?v=uaQh_bXcIGA.

Let's see how far I get with the solution of Thomas. I will send an update.

@Thomas Richard 

In other words: string can be the value of output but if the value of output is a string its a filename.

I missed the two meanings of the string string in the paragraph of the help page. At least it is not obvious.

Thank you!

@tomleslie 

Now it makes sense.

The equation label (2) in my example labels an output (the return value xa,xc of cat). Referring in a subsequent statement to the same equation label evaluates the output to its value (which are equations). This explains why no eval is needed when two statements are used.

This also explains why no additional eval is needed in nested statements when an output or a return value is already evaluated, which is the case for most commands.

Thanks for the help in identifying this subtle difference.

@Carl Love 

Your answer provides an operator that returns an evaluated expression for the types of operands I have used. Comparing the help page of || to the answer of Tom makes the different levels of evaluation clear.

Thanks for this "discouraged" and unbeatable compact alternative!

@tomleslie 

This explains why rhs returns a name (unevaluated).

What I still do not understand in my example is why two separate statements (lines of input) do not need an eval. A which point is the eval happening? Maybe it’s because the “termination of a statement” (an input line) forces an evaluation.

Thank you!

@wmcnally 

The RLC circuit is a linear time-invariant system (LTI system). Linearization is independed of the linearization point which is not the case for the double pendulum

Newer MapleSim versions may provide a “foolproof” way.

In the attachment, the use of contact components instead of an elasto gap component shows no dependence on the sign of the axis of the prismatic joint for the case discussed.

Prismatic_Joint_with_Contact_Components.msim

First 60 61 62 63 64 65 66 Last Page 62 of 70