Re: [eigen] find command or equivalent |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] find command or equivalent
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 3 Sep 2010 07:19:14 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ylKvx26f8FkQP1VNGLLjgsOiMgcU5yBjeHdcllm79V4=; b=QYmnnmqHJ9vZrTrRONDImziDCBAvHyjoq+fM4lElnkwLTl0HY8/rmTNBAP7L2W1K/f LwLZNxDjmWkpn8Rw9427qg6LQ3sgDEWnN9YDxUn2lfeF2Ib7XS6QXqNsFggkVCEcRhsS 18DS+25QMthw7D1Pc4G8eSgf7l0924Ki5iJsM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=hIJ8paYMYg7T9syDlgv2dpTYbQz3A7y8Ngr/73XL0tAi3tyGz63pTw9ZX6jiF15KJ+ CfRX380ShwcX1chs6HHli9Q6PvpHvAeL84yaQErYVRhwne8adr2UDZCeLuz0OGyGszz3 BcR5mVLmREMDPUeJK/CGEReu+muIaLzXXGRyA=
2010/9/3 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
> interesting, here is how this is compiled by gcc 4.5:
>
> .L418:
> leaq (%rsi,%rdx), %rcx
> addq $1, %rax
> addq $4, %rdx
> cmpq %rbx, %rax
> movss (%rcx), %xmm0
> movaps %xmm0, %xmm1
> movaps %xmm0, %xmm3
> cmpnltss %xmm2, %xmm1
> movaps %xmm1, %xmm0
> andps %xmm1, %xmm3
> andnps %xmm4, %xmm0
> orps %xmm3, %xmm0
> movss %xmm0, (%rcx)
> jne .L418
>
> where %xmm2 contains 0.0001, and %xmm4 is initialized to zero
> (xorps %xmm4, %xmm4).
>
> - Since GCC knows that %xmm4 == 0, it should be able to optimize away
> these two instructions which have no effect:
> andnps %xmm4, %xmm0
> orps %xmm3, %xmm0
>
> - It is also weird that it generates packet instructions while the
> loop is not vectorized (andss, andnss, orss would be enough).
>
> - there are too many movaps instructions.
>
> here is what gcc should be able to easily generate:
>
> .L418:
> leaq (%rsi,%rdx), %rcx
> addq $1, %rax
> addq $4, %rdx
> cmpq %rbx, %rax
> movss (%rcx), %xmm0
> movaps %xmm0, %xmm1
> cmpnltss %xmm2, %xmm1
> andss %xmm1, %xmm0
> movss %xmm0, (%rcx)
> jne .L418
>
> maybe it is worth a bug report ?
I'd say yes! You can always attach the preprocessed source so they can
see for themselves.
Benoit
>
> gael
>
> On Fri, Sep 3, 2010 at 9:19 AM, Gael Guennebaud
> <gael.guennebaud@xxxxxxxxx> wrote:
>> you can do:
>>
>> A = (A.array()<0.0001).select(0,A);
>>
>> where the "select" method mimics the c++ ?: operator.
>>
>> gael
>>
>>
>> On Fri, Sep 3, 2010 at 6:40 AM, Suresh Kumar
>> <suresh.amritapuri@xxxxxxxxx> wrote:
>>> Hi
>>> I want to replace all elements of a matrix, which are less than a threshold
>>> by zero. How to do it without writing a nested for loop?
>>> I am looking for something like this in matlab. A(A < 0.001) = 0 where A is
>>> a matrix.
>>> Thanks
>>> suresh
>>>
>>> --
>>> R Suresh Kumar,
>>> http://www.ee.ucr.edu/~sramachandranna
>>> --
>>> Dhyaana–moolam Guror murtih
>>> Puja-moolam Guroh padam
>>> Mantra – moolam Guror vakyam
>>> Moksha – moolam Guroh krpa.
>>>
>>
>
>
>