[Date Index]
[Thread Index]
[Author Index]
Re: slots with 2 indexed array?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg95623] Re: [mg95553] slots with 2 indexed array?
*From*: Bob Hanlon <hanlonr at cox.net>
*Date*: Fri, 23 Jan 2009 05:05:54 -0500 (EST)
*Reply-to*: hanlonr at cox.net
data = {{1, 2, 3}, {4, 5, 6}};
Map[g, data, {2}]
{{g[1], g[2], g[3]}, {g[4], g[5],
g[6]}}
data = sigs = Table[10 i + j,
{i, 4000}, {j, 1024}];
len = Length[sigs];
f = If[# >= 2048, # - 2048, # + 2048] &;
Timing[For[i = 1, i < len + 1, i++,
sigs[[i]] = f /@ sigs[[i]]]]
{1.3219,Null}
Timing[res = Map[f, data, {2}];]
{0.833989,Null}
Verifying that Map performs the same function
sigs == res
True
Bob Hanlon
---- "wb at wavebounce.com" <wb at wavebounce.com> wrote:
=============
First I produce some dummy data, 4000 of what I call signals, 1024 samples each.
sigs = Table[10 i + j, {i, 4000}, {j, 1024}];
len = Length[sigs];
I'd like to modify these signals. The For statement below works. I can use a slot function on each of the sigs specified by i.
For[i = 1, i < len + 1, i++,
sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ]
Surely there's a way to use slots on a double indexed array but I haven't found it yet.
If I try to let # represent every entry in sigs, the If statement isn't processed:
sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs;
I tried Which that Help says uses HoldAll but that doesn't work either; Which[] still isn't evaluated.
I tried using #2 and ## instead of # but that doesn't work. In reading about slot functions I haven't seen any examples using multi indexed arrays.
Could someone please give me a hint on how to pull this off? -- if this can be done with slots. Thanks.
Prev by Date:
**Re: export to ps, transparency issue**
Next by Date:
**Re: bug in LinearProgramming**
Previous by thread:
**Re: slots with 2 indexed array?**
Next by thread:
**Re: Fitting problem**
| |