Bluebit Software
Bluebit Software Support Forum
 Home          Members     Calendar     Who's On

Welcome Guest ( Login | Register )
        



Inconsistent results from ReOrderRows -... Expand / Collapse
Message
Posted Wednesday, November 29, 2006 6:31 AM Post #145
 

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member
I have been having problems with re-ordering the columns of a matrix. To try help things, i have made a simple example using the reOrderRows method (based on the example in the help file distributed with the ActiveX DLL). The code i have used is shown below:

Private Sub Command1_Click()
Dim A As New Matrix, B As Matrix
Dim perm(5) As Integer
Dim PI As Variant
'Set A = New Matrix
'A.Size 6, 6
'A.FillRandom

Set B = New Matrix
B.Size 6, 1
'B.FillRandom
B(0, 0) = 5
B(1, 0) = 3
B(2, 0) = 9
B(3, 0) = 7
B(4, 0) = 10
B(5, 0) = 9

'Debug.Print "A = "
'Debug.Print A.GetString

Debug.Print "B = "
Debug.Print B.GetString


perm(0) = 4
perm(1) = 5
perm(2) = 3
perm(3) = 1
perm(4) = 6
perm(5) = 2

PI = perm()
B.ReorderRows PI

Debug.Print "B reordered"
Debug.Print B.GetString
End Sub

I thought i would make the help file example easier by not using the sort rows method and also by having a constant matrix for B each time. The permutation index stored in perm() is also constant each time. After copying this to the variant PI and then calling the ReorderRows method, i would expect the same output for the reordered B matrix as in the example in the help file.

However, i do not get the same output each time. The rows are not reordered. Also the value of the first row of the reordered matrix changes with different executions of the above code. This is nearly identical to the problem that i have when i try to reorder columns in my program.

The output from different executions of the above code is shown below:

B = 
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |

B reordered
| 9.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |
------------------------
B =
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |

B reordered
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |
------------------------
B =
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |

B reordered
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |
------------------------
B =
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |

B reordered
| 7.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |


The results that i expect (which are the same results from the help example) are shown below:


B =
| 5.000 |
| 3.000 |
| 9.000 |
| 7.000 |
| 10.000 |
| 9.000 |

B reordered
| 7.000 |
| 10.000 |
| 9.000 |
| 5.000 |
| 9.000 |
| 3.000 |


Can you please help me with what is going wrong as i am completely stuck?
Posted Wednesday, November 29, 2006 10:17 AM Post #379
 

Bluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit Support
Replace this statement
Dim perm(5) As Integer
with this
Dim perm(5) As Long

in order to get the same results as the example set perm() as follows

perm(0) = 3
perm(1) = 5
perm(2) = 2
perm(3) = 0
perm(4) = 1
perm(5) = 4


Trifon Triantafillidis

Lead Developer

Bluebit Software

« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Trifon

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 3:34am

Powered by InstantForum.NET v4.1.4 © 2012
Execution: 0.219. 9 queries. Compression Disabled.
.NET Matrix Library