Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: RealOnly (Correction)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39220] Re: RealOnly (Correction)
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 4 Feb 2003 02:21:45 -0500 (EST)
  • References: <b1idka$bk3$1@smc.vnet.net> <b1l1su$iae$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Ray,

The suggestion that I previously posted should have used Get (as Bob Hanlon
did) instead of
Needs.
With Needs, On[RealOnly] does not load the package Miscellaneous`RealOnly`
when use a second time, and in particular after using Off[RealOnly] ---this
is because "Miscellaneous`RealOnly`" will be in the list $Packages.

Here is the corrected version,

RealOnly /: On[RealOnly] :=
    Get[ "Miscellaneous`RealOnly`"];
RealOnly /: Off[RealOnly] :=
   (Unprotect[Power, Solve, Roots];
    Clear[Power, Solve, Roots];
    Protect[Power, Solve, Roots];
    Remove["Miscellaneous`RealOnly`Nonreal"];
    $Post =.
   )


"Allan Hayes" <hay at haystack.demon.co.uk> wrote in message
news:b1l1su$iae$1 at smc.vnet.net...
>
> "Ray" <rayfg at optonline.net> wrote in message
> news:b1idka$bk3$1 at smc.vnet.net...
> > If I activate <<Miscellaneous`RealOnly` to do a calculation where I only
> > want real values, how can I get rid of it so I can do a different
> > calculation involving complex values. In other words, how do I close the
> > RealOnly function. Is there another way of doing a calculation that will
> > work only in the reals without opening RealOnly. Thanks.
> >
>
> Ray,
> Here is a modification of a posting by Bob Hanlon in Sept 2000.
>
>
>     RealOnly /: On[RealOnly] :=
>         Needs[ "Miscellaneous`RealOnly`"];
>
>     RealOnly /: Off[RealOnly] :=
>        (Unprotect[Power, Solve, Roots]; Clear[Power, Solve,
>          Roots]; Protect[Power, Solve, Roots];
>         Remove["Miscellaneous`RealOnly`Nonreal"]; $Post =. )
>
> Check
>
>     (-1.)^(1/3)
>
>         0.5 + 0.8660254037844387*I
>
>     On[RealOnly]
>     (-1.)^(1/3)
>
>         -1.
>
>     Off[RealOnly]
>     (-1.)^(1/3)
>
>         0.5 + 0.8660254037844387*I
>
>
> --
> Allan
>
> ---------------------
> Allan Hayes
> Mathematica Training and Consulting
> Leicester UK
> hay at haystack.demon.co.uk
> Voice: +44 (0)116 271 4198
> Fax: +44 (0)870 164 0565
>
>
>
>






  • Prev by Date: Re: Random Trouble
  • Next by Date: Messages loading Combinatorica and mathStatica
  • Previous by thread: RE: Simple Problem ??
  • Next by thread: Messages loading Combinatorica and mathStatica