Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12024 > unrolled thread

Re: Triggering on exception conditions

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-10-10 05:25 +0000
Last post2012-10-10 05:25 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Triggering on exception conditions Bob Hanlon <hanlonr357@gmail.com> - 2012-10-10 05:25 +0000

#12024 — Re: Triggering on exception conditions

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-10-10 05:25 +0000
SubjectRe: Triggering on exception conditions
Message-ID<k530sb$912$1@smc.vnet.net>
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
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web