Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12024
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Triggering on exception conditions |
| Date | 2012-10-10 05:25 +0000 |
| Message-ID | <k530sb$912$1@smc.vnet.net> (permalink) |
| References | <20121009043747.A0201687A@smc.vnet.net> |
| Organization | Time-Warner Telecom |
data1 = With[{h = 20},
Module[{y},
Table[y = PowerMod[k, -1, h];
{Mod[k, h],
If[FreeQ[y, PowerMod], y, 0]},
{k, 1, h - 1}]]] // Quiet
{{1, 1}, {2, 0}, {3, 7}, {4, 0}, {5, 0}, {6, 0}, {7, 3}, {8, 0}, {9,
9}, {10, 0}, {11, 11}, {12, 0}, {13, 17}, {14, 0}, {15, 0}, {16,
0}, {17, 13}, {18, 0}, {19, 19}}
data2 = With[{h = 20},
Module[{y},
Table[y = PowerMod[k, -1, h];
{Mod[k, h],
y*Boole[FreeQ[y, PowerMod]]},
{k, 1, h - 1}]]] // Quiet;
data3 = With[{h = 20},
Module[{y},
Table[y = PowerMod[k, -1, h];
{Mod[k, h],
If[NumericQ[y], y, 0]},
{k, 1, h - 1}]]] // Quiet;
data4 = With[{h = 20},
Module[{y},
Table[y = PowerMod[k, -1, h];
{Mod[k, h],
y*Boole[NumericQ[y]]},
{k, 1, h - 1}]]] // Quiet;
data1 == data2 == data3 == data4
True
Bob Hanlon
On Tue, Oct 9, 2012 at 12:37 AM, Lorenz <lorenz.mueller@bluewin.ch> wrote:
> Assume I have a statement like
> Table[ {Mod[k, h], PowerMod[k, -1, h]}, {k, 1, h - 1}]
> How can I select the elements in the table which fullfill the condition
> PowerMod::ninv: 2 is not invertible modulo xxx
>
> I would like a statement with a form like
> If[PowerMod[2, -1, h] == ninv, 1, 0]
> but this does not work.
>
> More general how to catch exceptions in calculation for each type of exception condition, eg in this case PowerMod::ninv
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Triggering on exception conditions Bob Hanlon <hanlonr357@gmail.com> - 2012-10-10 05:25 +0000
csiph-web