Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Matrix Utils - Array questions

Author
Message
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 16th Feb 2012 05:38
Hello,

I was extremely pleased recently to find Matrix utils but I think my lack of experience makes reading the documentation difficult so I had a few questions.

This is using the commands from this page:
http://www.matrix1.demon.co.uk/Matrix1Utils_Help/Matrix1Util_29_index.html

1: When using the "SORT ARRAY RANGE" this works clearly enough. But when reading the documentation for "SET ARRAY SORT" I have no idea what this is doing? Is this a performance item?

2: Also regarding "SET ARRAY SORT" what is a UDT and Non-UDT array?

3: "CLEAR ARRAY ITEM Array(), Index" seems to work in the fashion of clearing the item to a 0. But what I'm confused about here is what does it mean by "Index" I noticed I cant say MyArray(3,5) it only seems to accept a single numerical input like "1" or "12" ? What's that all about so I understand how to use it better?

4: I need to sort my array after clearing an item but in a particular fashion I will attempt to describe it here so that if someone is aware of a Matrix util array command that would help that end I would appreciate it; but after reading all the array commands I think I have to write my own loop to get it done.

Example Array Start:

1,4,3
2,1,5
6,5,2

Array after clearing an item:

1,4,3
2,1,5
6,0,2 <- notice the zero on this line


So the intend is to sort the middle line in such a way as to drop the 1 into the 0's position, and then the 4 into the 1's position. And then finally fill the gap with a new random number.

I can certainly write my own loop/bubble sort code to do this but Matrix Util's is doing some amazing things I am hoping that it has a utility/command I'm missing in this area

Any help or answers, even tips in the right direction are greatly appreciated in advance!

Thank you.
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 16th Feb 2012 05:49
UPDATE:

I've been reading the documentation further this evening and I *THINK* the "ROTATE ARRAY" command may answering my question #4

Funny how when you read something the 4th time , the post a forum question, and go back and read it the 5th time it clicks a little bit sometimes!
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 16th Feb 2012 06:02
And a 5th follow up question.

If I clear an array item can I re-populate it with a random number?
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Feb 2012 06:57
Quote: "When using the "SORT ARRAY RANGE" this works clearly enough. But when reading the documentation for "SET ARRAY SORT" I have no idea what this is doing? Is this a performance item?"

Yes, this is a performance item. It allows you to choose one of the available sorts for sorting the specified array. Some sorts are faster than others in certain circumstances. Here is a nice visual demonstration of a few sorts and you will see some are faster than others at sorting certain situations.

Quote: "Also regarding "SET ARRAY SORT" what is a UDT and Non-UDT array?"

A UDT array is an array of User-Defined Types. E.g


Quote: ""CLEAR ARRAY ITEM Array(), Index" seems to work in the fashion of clearing the item to a 0. But what I'm confused about here is what does it mean by "Index""

An index is the location of a cell in an array. For multi-dimensional arrays it appears they are stored column by column. If anyone can confirm this please do so. Have a look at this snippet:

It also appears that the command seems to skip the final row, e.g Array(10, n).


Quote: "I've been reading the documentation further this evening and I *THINK* the "ROTATE ARRAY" command may answering my question #4"

Looks like it.

Quote: "
If I clear an array item can I re-populate it with a random number? "

You should be able to, try it.

erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 17th Feb 2012 02:55
Thank you hodgey much appreciated!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Feb 2012 18:24
SET ARRAY SORT is not just a performance command - one of those sort methods is a stable sort too, meaning it'll have an affect on the final order.

Also, the sorting is quite clumsy when used with multi-dimensional arrays, because you can only sort along the columns, and you have to work out the start and end points in the array yourself. You should look to see if you can switch to a 1D UDT array instead, then sort on the field numbers instead.



Login to post a reply

Server time is: 2024-11-22 06:02:12
Your offset time is: 2024-11-22 06:02:12