Skip to main content
23-Emerald V
October 20, 2024
Solved

matrix indexing using parentheses

  • October 20, 2024
  • 2 replies
  • 3792 views

Let me tell you a story.  Once upon a time, perhaps even 10 minutes ago, when writing a new function (Bidiagonal) and testing it with strings, I replaced a direct function call argument with a predefined vector but forgot to remove the original function's argument.  After a few seconds of gazing at the (correct) output from Bidiagonal, I realised that the notation V(3) for vector V should have raised an error, but it didn't. 

 

After a bit of playing with a new, blank worksheet, I confirmed that to get an array's elements, one can use the standard subscripted index notation Mi,j or the standard programming language parenthesis notation M(i,j). And Little Red Riding Hood and Peter campaigned for a better public understanding of wolves, their role in ecology, and their treatment.

 

2024 10 20 A.png

 

I have a vague, dusty, indistinct memory of coming across this notation before, perhaps even on this forum, but I'm not sure - it might be a case of déjà vu.

 

Stuart

Best answer by LucMeekes

It is one of the two supported means to index an Array in Prime.

And it is confusing.

And it takes up more space.

And you cannot use this notation to access elements of nested arrays.

LucMeekes_0-1729417377031.png

So I never use it

 

Luc

2 replies

LucMeekes23-Emerald IVAnswer
23-Emerald IV
October 20, 2024

It is one of the two supported means to index an Array in Prime.

And it is confusing.

And it takes up more space.

And you cannot use this notation to access elements of nested arrays.

LucMeekes_0-1729417377031.png

So I never use it

 

Luc

23-Emerald V
October 20, 2024

Yes, I agree, Luc. 

 

I had a quick play with nested arrays but couldn't find a way of indexing them by extension of this notation.  I was rather hoping I'd be able to do something useful, such as P(1,1,1,1) to get at an element - that would make using nested arrays more straightforward and be the basis for a proper multidimensional array (MDA) system ... I may have mentioned/requested MDAs on the odd occasion.

 

2024 10 20 B.png

 

Do you know if this notation is documented as well as supported?

 

Stuart

23-Emerald IV
October 20, 2024

AFAIK it's supported, and I hope it's documented. It's been in since Prime 1.

 

Luc

25-Diamond I
October 20, 2024

Here is another difference - guess you did not try to change the value of ORIGIN.

The functional notation is ignoring the setting of ORIGIN - similar to the third argument (generating function) in the "matrix" function.

Werner_E_0-1729430075419.png

 

I can confirm that this 'feature' has existed since Prime's inception and I've railed against it a time or two here for a couple of reasons.
However, I haven't come across any official documentation on it, so I couldn't say that it's officially supported by PTC. It's also possible that it just happened unintentionally.
In my opinion, it would have made more sense to eliminate this 'feature'. Just as the undocumented ability to quickly and easily convert ranges to vectors was eliminated in Prime 10, but unfortunately without providing a (more logical and intuitive) alternative.

23-Emerald V
October 20, 2024

Your Werner railings.jpegs are possibly what I might have seen, but forgotten about.  Apologies if so; my memory is as bad now as it was then.   Although I have a very vague recollection of seeing this when I was modifying my multidimensional array worksheets to work with Prime Express.

 

Whilst PTC are fixing this indexing feature, it would be nice if they'd give some consideration to fixing two particular bug bears I have with the normal indexing notation.

 

  • Cannot use deep nested array indexing on left hand side of a definition, although it works in an assignment.
  • Programmatically and visually, nested indexing, whilst unambiguous, isn't flexible enough to cater for irregularly shaped nested arrays.  The ability to use a single level indexing would make it easier to see the indices and to handle deep arrays. 

2024 10 20 C.png

 

ISTR that you couldn't use nested indexing in an assignment, either.  Did M15 or early versions of Prime allow it?

 

Stuart

25-Diamond I
October 20, 2024

Here is what you did converted to Mathcad 15.

Werner_E_1-1729445518139.png