Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6768
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Matrices as operators |
| Date | 2011-11-26 11:48 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jaqjn9$oj7$1@smc.vnet.net> (permalink) |
----- Christopher Young <cy56@comcast.net> wrote:
> On Nov 25, 2011, at 6:17 PM, Ray Koopman wrote:
>
>> This is simpler. Does it do what you want?
>> Note that 'mat' can be a ragged array.
>> Mapping at {-1} preserves its shape, whatever it may be.
>>
>> In[1]:= op[mat_,t_] := Map[#@t&, mat, {-1}]
>>
>> In[2]:= op[ { {Sin, Cos}, Tan, whatever }, t ]
>>
>> Out[2]= { {Sin[t], Cos[t]}, Tan[t], whatever[t] }
>
> Thanks very much, this is very close to what I need.
> I just need to keep the "[t]" from being added to numbers.
>
> In[1]:= op[mat_, t_] := Map[#1[t] &, mat, {-1}]
>
> In[2]:= op[{{Sin, Cos}, Tan, {Cos, 0, 1}}, t]
>
> Out[2]= {{Sin[t], Cos[t]}, Tan[t], {Cos[t], 0[t], 1[t]}}
This won't try to interpret a number as a function:
In[1]:= op[mat_, t_] := Map[If[NumericQ@#, #, #@t] &, mat, {-1}]
In[2]:= op[{{Sin, Cos}, Tan, {Cos, 0, 1}}, t]
Out[2]= {{Sin[t], Cos[t]}, Tan[t], {Cos[t], 0, 1}}
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Matrices as operators Ray Koopman <koopman@sfu.ca> - 2011-11-26 11:48 +0000 Re: Matrices as operators Chris Young <cy56@comcast.net> - 2011-11-27 09:13 +0000
csiph-web