[overture] Re: A++ : Finding non-zeros in an array

  • From: "#DOMINIC DENVER JOHN CHANDAR#" <DOMI0002@xxxxxxxxxx>
  • To: <overture@xxxxxxxxxxxxx>
  • Date: Wed, 22 Apr 2009 10:43:33 +0800

Hi Slava,

 Thanks for the idea ! .. Ive implemented this and its perfect ..

Regards,
Dominic
 

-----Original Message-----
From: overture-bounce@xxxxxxxxxxxxx
[mailto:overture-bounce@xxxxxxxxxxxxx] On Behalf Of Viacheslav Merkin
Sent: Tuesday, April 21, 2009 8:16 PM
To: overture@xxxxxxxxxxxxx
Subject: [overture] Re: A++ : Finding non-zeros in an array

Hi Dominic,

You could probably do something like this:


where ( X != 0)
  {
    intArray mask = 1;
    RealArray Y=X
}

int N_nonzeros = sum(mask);
Y.reshape(N_nonzeros);



I don't remember the exact P++ usage for the sum() and the reshape()
functions, but something like this should work, I think.

Regards,
Slava





On Apr 21, 2009, at 7:25 AM, #DOMINIC DENVER JOHN CHANDAR# wrote:

> Hi,
>
>    I have an array of the form   X = { P , P, P , P, A, A, A, P, P ,  
> P, A , A, A}
>
> P : finite value exists
> A : value is zero
>
> I would like to create a new array called Y = { P,P,P....} which has 
> all the non-zero entries. I will not know the number of non-zeros 
> unless I look into the array..
> Using a simple loop, I believe this can be achieved.. but for large 
> amount of data, it takes time. What could be the simplest way of doing

> this using A++ ?
>
> I tried something like :
>
> where ( X != 0)
>  {
>    RealArray Y=X
> }
>
> The non zero entries are there.. but the dimension of array Y is 
> obviously that of X.. with the remaining padded with zeros. Is there a

> way to redimension this.. keeping in mind that we dont know the size 
> of Y ..
>
> Thanks,
> Dominic
>



Other related posts: