Remove Duplicate Rows [message #82914] |
Thu, 24 January 2013 19:42  |
Gompie
Messages: 76 Registered: August 2012
|
Member |
|
|
Hi,
I have a 500x500 array of floats. Some of the rows are duplicate.
How do I remove these duplicate rows.
Thanks in advance.
Gompie
|
|
|
|
|
Re: Remove Duplicate Rows [message #82988 is a reply to message #82914] |
Sat, 26 January 2013 07:32  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
On Saturday, January 26, 2013 2:25:56 PM UTC+1, Gompie wrote:
> Thanks Mat
>
> I want to first remove duplicate rows( which your code already does).
>
> I then want to sum up each duplicate column to get a sum columns.
>
> I then want to replace every pair of duplicate columns with the sum columns.
>
> Gompie
Oh, columns! I missed that part. Well, you can use uniqrows to find duplicate columns, too. Just use the OP keyword to change what index it considers the row index. And then I imagine the summing could proceed much like I've already outlined.
|
|
|
Re: Remove Duplicate Rows [message #82989 is a reply to message #82914] |
Sat, 26 January 2013 05:25  |
Gompie
Messages: 76 Registered: August 2012
|
Member |
|
|
Thanks Mat
I want to first remove duplicate rows( which your code already does).
I then want to sum up each duplicate column to get a sum columns.
I then want to replace every pair of duplicate columns with the sum columns.
Gompie
|
|
|
Re: Remove Duplicate Rows [message #82990 is a reply to message #82914] |
Sat, 26 January 2013 02:09  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
On Saturday, January 26, 2013 11:02:33 AM UTC+1, Mats Löfdahl wrote:
> On Saturday, January 26, 2013 1:03:37 AM UTC+1, Gompie wrote:
>
>> Pretty easy for you to do because you wrote the uniq-rows code..but hard for me to follow.
>
>
>
> Well, it wasn't meant as detailed instructions. I just tried to get an idea across so you could figure the details out for yourself.
I'll make another attempt, and this time not just before bedtime...
As I understood your problem, you wanted to remove duplicate rows and then instead co-add them. That would be equivalent to multiply the first copy of the duplicated row with the number of copies. So my idea was to define an array of factors to multiply each row with. It would start out as unity for each row but everytime you found a duplicate you would add one to the position corresponding to the first copy, the one you are going to keep. And when you have found all the duplicate rows, you'd apply those multiplicative factors to the rows before removing the duplicates.
|
|
|
Re: Remove Duplicate Rows [message #82991 is a reply to message #82914] |
Sat, 26 January 2013 02:02  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
On Saturday, January 26, 2013 1:03:37 AM UTC+1, Gompie wrote:
> Pretty easy for you to do because you wrote the uniq-rows code..but hard for me to follow.
Well, it wasn't meant as detailed instructions. I just tried to get an idea across so you could figure the details out for yourself.
|
|
|
|
Re: Remove Duplicate Rows [message #82996 is a reply to message #82914] |
Fri, 25 January 2013 15:20  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
On Saturday, January 26, 2013 12:05:37 AM UTC+1, Gompie wrote:
> Thanks Mats !!!
>
> The Marks uniq and your uniq pro worked well.
>
> But now I want to sum the repeated columns and replace the repeated by the sum.
>
> Any help !!!
One way of doing it would be to make a modified version of the uniqrows function under a new name.
At the point where a duplicate rowis found (row i equals row j), the index j is stored in the duplicateindx array for later removal. At that point you could add 1 to the i:th element of another array (that is as long as the number of rows and initialized to unity in all elements before the loop starts), lets call it multfac. And then, before removing the duplicate rows, loop for i=0,Nrows-1 and multiply row i by multfac[i].
Something like that should work.
|
|
|