Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Following on from the thread Prime 3.1: Method for converting range variable to vector no longer works!, I thought an updated, ORIGIN-independent version of my vec function might be of some interest.
The vec function converts its arguments into a vector, including nested arrays of arbitrary depth. See Vectorization (mathematics) - Wikipedia, the free encyclopedia for further information on the vec function in linear algebrae
Apart from Prime's (<= v3.1) inability to accept a range definition as an argument, vec works in Mathcad 15 and Prime 3.1.
Stuart
StuartBruff wrote:
The vec function converts its arguments into a vector, including nested arrays of arbitrary depth. See Vectorization (mathematics) - Wikipedia, the free encyclopedia for further information on the vec function in linear algebrae
One problem with the above form of the vec function is that it doesn't work with symbolics; the particular form of for loop (e is element-of array) isn't supported. Here's a version that will work with the symbolic processor. As usual there is a trade-off and in this case it's that vec no longer. converts range arguments into vectors (which I find of greater general utility)
Stuart
Thanks!. I use a lot your library, and your functions are in my default template. Also, I'm an ORIGIN one guy. I guess that some of your functions can be extended to take functions as arguments, with the instruction IsFunction
AlvaroDíaz wrote:
Thanks!. I use a lot your library, and your functions are in my default template. Also, I'm an ORIGIN one guy. I guess that some of your functions can be extended to take functions as arguments, with the instruction IsFunction
Thanks, Alvaro. It's nice to know they're of some use to somebody, especially one of the Power Users!
Yes, I was pleased to see that Prime does include the IsFunction predicate - that's something that I've for before as being a major hole in the testing of arguments. If I need it (which isn't very often under M13+ static type checking) then I usually try to evaluate a variable as if it were a function and trap the error - doesn't always work).
Now that Prime allows arrays with a mix of functions, arrays and atoms (scalars or strings), I'll have to dig out a few of my old M11 worksheets and see if I can get them to work using IsFunction rather than my workarounds.
The still-outstanding major predicate omission is IsNested .... I'm sure that a built-in function must be more efficient than my library function.
... That's interesting. I was thinking about using IsFunction in my function equals (used in IsZero above) to see if I could test functional arguments for equality. Out of idle curiosity, I tried using equals on functions in Prime (I know it doesn't work in M15) and it seems to work, even symbollically.
Prime 3.1
Mathcad 15
Looking at the difference in the physical (if you can call it that) size of the M15 and Prime versions of equals, it is clear that "compact" is not in PTC's vocabulary!
Stuart
Hi Stuart. Great work. I refer for those utilities with more args, like this. In MC11 works with some problems, and needs to call maple functions. So, works when they want. But with a documented function to check the type function, they can be well implemented, I hope.
Best regards.