Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Better way to test the number of arguments?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132649] Re: Better way to test the number of arguments?
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sun, 27 Apr 2014 21:45:44 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140427064225.DB5346A1C@smc.vnet.net>

Without a specific example of an input and a desired output, I am not sure
what you want. Presumably, you just want to transpose the output.


f[a_, b_, c_, d_, e_, f_, g_, h_] =
  Table[
   ToExpression[
     "f" <> ToString[i] <> ToString[j]][a, b, c, d, e, f, g, h],
   {i, 4}, {j, 5}];


ddSaPartial[f_][args__] := D[f[args], {Rest@{args}}]


Dimensions[ddSaPartial[f][a, b, c, d, e, f, g, h]]


{4, 5, 7}


Dimensions[
 ddSaPartial[f][a, b, c, d, e, f, g, h] //
  Transpose[#, {2, 3, 1}] &]


{7, 4, 5}



Bob Hanlon




On Sun, Apr 27, 2014 at 11:18 AM, Pavel Grinfeld <pgeipi10 at gmail.com> wrote:

> Thank you, Bob.
> There's one difference in the output. If "f" is a vector(or tensor)-valued
> function, I would like the new dimension to be first. For example if f is a
> 4x5 matrix and a function 1+7 variables, I would like the output to be
> 7x4x5.
>
> How does one accomplish that?
>
> Thanks again,
>
> Pavel
>
>
> On Sun, Apr 27, 2014 at 9:04 AM, Bob Hanlon <hanlonr357 at gmail.com> wrote:
>
>> CORRECTION
>>
>> I left off there blank on the function:
>>
>> ddSaPartial[f_][args__]  := D[f[args],  {Rest@{args}}]
>>
>>
>> 2014-04-27 8:56 GMT-04:00 Bob Hanlon <hanlonr357 at gmail.com>:
>>
>> ddSaPartial[f][args__]  := D[f[args],  {Rest@{args}}]
>>>
>>>
>>>
>>> Bob Hanlon
>>>
>>>
>>> 2014-04-27 2:42 GMT-04:00 <pgeipi10 at gmail.com>:
>>>
>>> Hi,
>>>>
>>>> I have the following code that produces the gradient of a function
>>>> (with respect to all but the first variable). There is probably a better
>>>> way that avoids the Switch.
>>>>
>>>> Thank you,
>>>>
>>>> Pavel
>>>>
>>>> ddSaPartial[func_][t_, s__] := Switch[Length[{s}],
>>>>   1, {Derivative[0, 1][func][t, s]},
>>>>   2, {Derivative[0, 1, 0][func][t, s],
>>>>    Derivative[0, 0, 1][func][t, s]},
>>>>   3, {Derivative[0, 1, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 1, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 1][func][t, s]},
>>>>   4, {Derivative[0, 1, 0, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 1, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 1, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 0, 1][func][t, s]},
>>>>   5, {Derivative[0, 1, 0, 0, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 1, 0, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 1, 0, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 0, 1, 0][func][t, s],
>>>>    Derivative[0, 0, 0, 0, 0, 1][func][t, s]}
>>>>
>>>>
>>>>
>>>>
>>>
>>
>



  • Prev by Date: Re: Function parameterization guess
  • Next by Date: Suzhou, China
  • Previous by thread: Re: Better way to test the number of arguments?
  • Next by thread: Inverse function solution