Groups | Search | Server Info | Login | Register
Groups > comp.soft-sys.math.mathematica > #16853
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | Bill Rowe <readnews@sbcglobal.net> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: boolean indexing for subset reassignment |
| Date | Sat, 26 Apr 2014 06:07:39 +0000 (UTC) |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <ljfifb$guh$1@smc.vnet.net> (permalink) |
| Lines | 35 |
| Organization | Time-Warner Telecom |
| NNTP-Posting-Date | 26 Apr 2014 06:13:49 GMT |
| NNTP-Posting-Host | c94db354.news.twtelecom.net |
| X-Trace | DXC=WS>E>GPUZAL:^L5n5Q6mGEC_A=>8kQj6M;[h;PUXBgbD3`G[5H2>>MBEFiONJ7[GoFOZXoIa1;QnJ |
| X-Complaints-To | abuse@twtelecom.net |
| Xref | csiph.com comp.soft-sys.math.mathematica:16853 |
Show key headers only | View raw
On 4/25/14 at 12:44 AM, alan.isaac@gmail.com (Alan) wrote:
>Thanks for taking a stab at this, but you have not described
>comparable functionality. Most importantly, you are not changing
>the list `b` in place.
I don't understand why you do not see what I had posted as
comparable since it outputs the same result as described. If
your objection is simply I did not modify the original array,
that is trivial to change. Where I had posted
m = b Unitize@Clip[a, {1, 15}, {0, 0}]
this could be done as:
b = b Unitize@Clip[a, {1, 15}, {0, 0}]
which would change the original array.
In either case, what is returned is an array containing the
elements of b except those that exceed 15 which are replaced
with 0. That is:
In[18]:= a = RandomInteger[{1, 20}, {4, 3}]
Out[18]= {{8, 9, 11}, {16, 7, 20}, {4, 6, 3}, {12, 13, 16}}
In[19]:= b = RandomReal[1, {4, 3}];
b = b Unitize@Clip[a, {1, 15}, {0, 0}];
In[21]:= a Unitize[b]
Out[21]= {{8, 9, 11}, {0, 7, 0}, {4, 6, 3}, {12, 13, 0}}
showing b now has a 0 where a has a value greater than 15
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: boolean indexing for subset reassignment Bill Rowe <readnews@sbcglobal.net> - 2014-04-26 06:07 +0000
csiph-web