Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16860
| From | pgeipi10@gmail.com |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Better way to test the number of arguments? |
| Date | 2014-04-27 06:42 +0000 |
| Message-ID | <lji8td$ocn$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
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]}
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Better way to test the number of arguments? pgeipi10@gmail.com - 2014-04-27 06:42 +0000
csiph-web