You could make a verb that converts a number to complex:

interval=: 1j1 - 1j1 - ]

   interval 0

0

datatype interval 0

complex


-- 

Raul



On Thu, Aug 18, 2016 at 6:37 PM, Skip Cave <[email protected]> wrote:

> Interesting.  The vanishing imaginary zero is more than just a display
> issue though. More like a storage issue:
>
>    1j1 + 1j_1
>
> 2
>
>    datatype 1j1 + 1j_1
>
> complex
>
>
>    2j0
>
> 2
>
>    datatype 2j0
>
> integer
>
>
> Though both 1j1 + 1j_1 and 2j0 are complex numbers, only the addition
> process produces a complex result that can be stored. It looks like that
> when you input a complex number with a zero imaginary part, J ignores the
> complex part, and stores the number as a real number (could be boolean,
> integer, or floating). Thus J looses the fact that the number was entered
> as a complex number.
>
>
> So  if you want to maintain a complex datatype, you can't simply assign a
> noun with a value that has a zero imaginary part. You must find a way to
> compute the value with the zero imaginary part (thus avoiding direct
> entry), then assign it.
>
>
> In complex arithmetic, 2 & 2j0 are essentially the same, so J dropping the
> imaginary part probably saves storage by making this an integer. This won't
> matter, as long as you are staying in the complex domain.
>
>
> However, when you start using J's complex representation for other uses
> such as interval bounds (and other uses), this will be an issue. For
> example, say you want to input an interval such as _0.5j0 to a computation
> in Roger's unum lab. The lab can output intervals this way, you just can't
> input them. You can input the interval 0j0.5 and everything's ok.
> Unfortunately, not the mirror interval on the negative side.
>
>
> Skip
>
>
>
> Skip Cave
> Cave Consulting LLC
>
> On Thu, Aug 18, 2016 at 3:49 PM, Raul Miller <[email protected]>
> wrote:
>
> > Actually, J usually stores the number in whatever format it happens to
> > be storing it as.
> >
> > However, when J displays the number, it routinely removes irrelevant
> > information.
> >
> > Something similar happens when you enter numbers.
> >
> > Thus:
> >
> >    2j0
> > 2
> >    datatype 2j0
> > integer
> >    1j1 + 1j_1
> > 2
> >    datatype 1j1 + 1j_1
> > complex
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Thu, Aug 18, 2016 at 1:58 PM, Skip Cave <[email protected]>
> > wrote:
> > > Roger,
> > >
> > > Ah! the light dawns!  J doesn't keep the type of the data as entered by
> > the
> > > user. If the imaginary part is zero, J stores the number as real. If
> the
> > > number is one or zero (with or without an imaginary zero part), it
> stores
> > > the number as boolean. If the number is not floating and not
> fractional,
> > it
> > > stores the number as integer (again ignoring any zero imaginary part).
> > >
> > >     R1 =. _0.5
> > >
> > >     I1 =. _0.5j0
> > >
> > >     R1 = I1
> > >
> > > 1
> > >
> > >
> > >      R2 =. 1
> > >
> > >      I2 =. 1j0
> > >
> > >      R2 = I2
> > >
> > > 1
> > >
> > >
> > >     datatype 0j0
> > >
> > > boolean
> > >
> > >     datatype _0.5j0
> > >
> > > floating
> > >
> > >     datatype 1j0
> > >
> > > boolean
> > >
> > >     datatype 1j1
> > >
> > > complex
> > >
> > >     datatype 2j0
> > >
> > > integer
> > >
> > > Skip Cave
> > > Cave Consulting LLC
> > >
> > > On Thu, Aug 18, 2016 at 3:41 AM, roger stokes <
> [email protected]>
> > > wrote:
> > >
> > >> Skip,
> > >>
> > >> Thanks for your message and thanks for all the trouble you have gone
> to.
> > >> Let me try to explain the results you are seeing.
> > >>
> > >> First, the  important thing to note is that J itself displays a
> complex
> > >> number with imaginary part zero as looking like a real number. To
> > >> check this, try entering 0.5j0 _0.5j0 directly into any J session:
> > >>
> > >>
> > >>    0.5j0 _0.5j0
> > >> 0.5 _0.5
> > >>
> > >> Second, the result you are seeing is indeed complex:
> > >>
> > >>    Z =: JNFS SFJN _0.25
> > >>
> > >>    datatype Z
> > >> complex
> > >>
> > >> but it looks like a real number (and hence your objection)
> > >>
> > >>    Z
> > >> _0.5
> > >>
> > >> but it does have the value that you say it should have
> > >>
> > >>    Z = _0.5j0
> > >> 1
> > >>
> > >> Hope this is useful
> > >>
> > >> Regards
> > >>
> > >>
> > >> On Wed, Aug 17, 2016 at 8:35 PM, Skip Cave <[email protected]>
> > >> wrote:
> > >>
> > >> > All,
> > >> >
> > >> > I agree that the unum for _0.25 should be  "_0.5j0"
> > >> > My previous statement was wrong in its declaration of what *should
> > be*,
> > >> but
> > >> > it wasn't wrong about what *is wrong in the lab*.
> > >> >
> > >> > I said: "Shouldn't converting _0.25 to a SORN, then back to a
> > >> > J number produce _0j0.5, NOT _0.5? "
> > >> >
> > >> > I should have said:
> > >> > "Shouldn't converting _0.25 to a SORN, then back to a
> > >> > J number produce
> > >> >
> > >> >
> > >> >
> > >> > _0.5j0, NOT _0.5? "
> > >> >
> > >> > The key here is the words "NOT _0.5".
> > >> >
> > >> >
> > >> > Here are the lab results copied directly from the session:
> > >> >
> > >> >
> > >> >
> > >> >  JNFS SFJN 0.25
> > >> >
> > >> > 0j0.5
> > >> >
> > >> >
> > >> >
> > >> > JNFS SFJN _0.25
> > >> > _0.5
> > >> >
> > >> >
> > >> > So as I tried to state in my previous post: The lab is producing
> wrong
> > >> > results for conversions of _0.25 to SORNS and back to J numbers. The
> > lab
> > >> > should produce "
> > >> >
> > >> > _0.5j0
> > >> > " for the result of
> > >> >
> > >> > JNFS SFJN _0.25
> > >> >
> > >> > For that matter, the lab produces wrong results for the whole
> interval
> > >> from
> > >> > 0 < x < 0.5
> > >> >
> > >> >
> > >> >
> > >> > JNFS SFJN _0.25
> > >> >
> > >> > _0.5
> > >> >
> > >> >
> > >> > JNFS SFJN _0.35
> > >> > _0.5
> > >> >
> > >> >
> > >> > JNFS SFJN _0.1
> > >> >
> > >> > _0.5
> > >> >         JNFS SFJN _0.499
> > >> >
> > >> > _0.5
> > >> >
> > >> >
> > >> > JNFS SFJN _0.5
> > >> >
> > >> > _1r2
> > >> >
> > >> >
> > >> > I believe that all these results should be "
> > >> >
> > >> > _0.5j0
> > >> > " in the lab.
> > >> >
> > >> > Then the lab gets it right again once we cross the _1r2 border
> > (heading
> > >> > negatively):
> > >> >
> > >> >
> > >> >
> > >> > JNFS SFJN _0.6
> > >> >
> > >> > _1j_0.5
> > >> >
> > >> > Skip
> > >> >
> > >> >
> > >> >
> > >> > Skip Cave
> > >> > Cave Consulting LLC
> > >> >
> > >> > On Wed, Aug 17, 2016 at 10:47 AM, roger stokes <
> > [email protected]
> > >> >
> > >> > wrote:
> > >> >
> > >> > > Typo in my last: "gives 0.5j0" should be "Gives "_0.5j0"
> > >> > >
> > >> > > Sorry.
> > >> > >
> > >> > > On Wed, Aug 17, 2016 at 4:43 PM, roger stokes <
> > >> [email protected]>
> > >> > > wrote:
> > >> > >
> > >> > > > Skip,
> > >> > > >
> > >> > > >     you wrote "Shouldn't converting _0.25 to a SORN, then back
> to
> > a
> > >> > > > J number produce _0j0.5, NOT _0.5? "
> > >> > > > I believe the result given is correct, because _0.25 is in the
> > >> > > > interval (_0.5 0) in 4-bit precision.
> > >> > > >
> > >> > > >    A =: SFJN _0.25
> > >> > > >
> > >> > > >
> > >> > > >    (> A) # UNUMS
> > >> > > > +------+
> > >> > > > ¦_1r2 0¦
> > >> > > > +------+
> > >> > > >
> > >> > > > Rendering this as a complex number, with real for lower bound
> _1r2
> > >> > > > and imaginary for upper bound 0 gives 0.5j0 which is presented
> by
> > J
> > >> > > > as a real number because imag = 0
> > >> > > >
> > >> > > >   ] B =: JNFS A
> > >> > > > _0.5
> > >> > > >    datatype B
> > >> > > > complex
> > >> > > >    B = _0.5j0
> > >> > > > 1
> > >> > > >
> > >> > > >
> > >> > > > I rest my case.
> > >> > > >
> > >> > > > These conversions are not yet finished nor documented, in fact
> the
> > >> > whole
> > >> > > > thing is pretty rough.  On that subject, let me mention that
> > until I
> > >> > get
> > >> > > it
> > >> > > > cleaned up, users should avoid one-character lower case
> variables,
> > >> > > because
> > >> > > > of my sloppy style of doing global assigns to what should be
> > local.
> > >> > > >
> > >> > > > I thought it would be best to use rationals for the values,
> rather
> > >> than
> > >> > > > reals,
> > >> > > > so that the computations for the lookup tables would be exact.
> > >> > > >
> > >> > > > Regards
> > >> > > >
> > >> > > > On Wed, Aug 17, 2016 at 3:02 PM, Skip Cave <
> > [email protected]>
> > >> > > > wrote:
> > >> > > >
> > >> > > >> Playing with 4-bit unums (compact SORNS), I thought I would see
> > how
> > >> > the
> > >> > > >> J-to-SORN & SORN-to-J conversions worked:
> > >> > > >>
> > >> > > >>     JNFS SFJN _3
> > >> > > >>
> > >> > > >> __j_2
> > >> > > >>
> > >> > > >>    JNFS SFJN _2.5
> > >> > > >>
> > >> > > >> __j_2
> > >> > > >>
> > >> > > >>    JNFS SFJN _2
> > >> > > >>
> > >> > > >> _2
> > >> > > >>
> > >> > > >>    JNFS SFJN _1.5
> > >> > > >>
> > >> > > >> _2j_1
> > >> > > >>
> > >> > > >>    JNFS SFJN _1
> > >> > > >>
> > >> > > >> _1
> > >> > > >>
> > >> > > >>    JNFS SFJN _0.5
> > >> > > >>
> > >> > > >> _1r2
> > >> > > >>
> > >> > > >>    JNFS SFJN _0.25
> > >> > > >>
> > >> > > >> _0.5                                 NB. ??
> > >> > > >>
> > >> > > >>    JNFS SFJN _0
> > >> > > >>
> > >> > > >> 0
> > >> > > >>
> > >> > > >>    JNFS SFJN 0
> > >> > > >>
> > >> > > >> 0
> > >> > > >>
> > >> > > >>    JNFS SFJN 0.25
> > >> > > >>
> > >> > > >> 0j0.5
> > >> > > >>
> > >> > > >>    JNFS SFJN 0.5
> > >> > > >>
> > >> > > >> 1r2
> > >> > > >>
> > >> > > >>    JNFS SFJN 0.75
> > >> > > >>
> > >> > > >> 0.5j1
> > >> > > >>
> > >> > > >>    JNFS SFJN 1
> > >> > > >>
> > >> > > >> 1
> > >> > > >>
> > >> > > >>    JNFS SFJN 1.5
> > >> > > >>
> > >> > > >> 1j2
> > >> > > >>
> > >> > > >>    JNFS SFJN 1.75
> > >> > > >>
> > >> > > >> 1j2
> > >> > > >>
> > >> > > >>    JNFS SFJN 2
> > >> > > >>
> > >> > > >> 2
> > >> > > >>
> > >> > > >>    JNFS SFJN 2.5
> > >> > > >>
> > >> > > >> 2j_
> > >> > > >>
> > >> > > >>    JNFS SFJN 3
> > >> > > >>
> > >> > > >> 2j_
> > >> > > >>
> > >> > > >>    JNFS SFJN _
> > >> > > >>
> > >> > > >> 2j_
> > >> > > >>
> > >> > > >>    JNFS SFJN __
> > >> > > >>
> > >> > > >> __
> > >> > > >>
> > >> > > >>
> > >> > > >> This would have been easier if JNFS and SFJN could handle
> > vectors.
> > >> In
> > >> > > any
> > >> > > >> case, everything looked good, once I understood how Roger was
> > >> > > representing
> > >> > > >> intervals in J as complex numbers, EXCEPT converting _0.25.
> > >> Shouldn't
> > >> > > >> converting _0.25 to a SORN, then back to a J number produce
> > _0j0.5,
> > >> > NOT
> > >> > > >> _0.5?
> > >> > > >>
> > >> > > >>
> > >> > > >> Skip
> > >> > > >>
> > >> > > >>
> > >> > > >> Skip Cave
> > >> > > >> Cave Consulting LLC
> > >> > > >>
> > >> > > >> On Wed, Aug 17, 2016 at 7:21 AM, Skip Cave <
> > [email protected]
> > >> >
> > >> > > >> wrote:
> > >> > > >>
> > >> > > >> > Is there a way for the unum lab to discover where it was
> > started
> > >> > from,
> > >> > > >> and
> > >> > > >> > then set the working directory to that location, rather than
> > >> having
> > >> > > the
> > >> > > >> > user have to set the directory?
> > >> > > >> >
> > >> > > >> > Skip
> > >> > > >> >
> > >> > > >> > Skip Cave
> > >> > > >> > Cave Consulting LLC
> > >> > > >> >
> > >> > > >> > On Wed, Aug 17, 2016 at 6:47 AM, roger stokes <
> > >> > > [email protected]
> > >> > > >> >
> > >> > > >> > wrote:
> > >> > > >> >
> > >> > > >> >> Dear All,
> > >> > > >> >>
> > >> > > >> >> Please accept my apologies for wasting your time, and my
> > thanks
> > >> > > >> >> for your patience, persistence  and help.
> > >> > > >> >>
> > >> > > >> >> Skip, Raul, Vijay, you are quite right about 1 !: 44 .
> > >> > > >> >> Instead of cd .... I should have said
> > >> > > >> >>
> > >> > > >> >>      1 !: 44 'yourdirectory'      NB.  full pathname is
> > >> recommended
> > >> > > >> >>
> > >> > > >> >>
> > >> > > >> >> Vijay, I made a correction following your mention of
> > >> > > >> general/misc/fndef .
> > >> > > >> >> This file should not be needed.
> > >> > > >> >>
> > >> > > >> >>
> > >> > > >> >> Bob, thanks for the suggestion  -  it's a good way to get
> the
> > lab
> > >> > > >> started
> > >> > > >> >> but there is still the need to find the other scripts. I
> will
> > >> > ponder
> > >> > > >> this
> > >> > > >> >> and see if there is a better way than as it is.
> > >> > > >> >>
> > >> > > >> >> Bill, thanks for the information about jconsole - I didn't
> > know
> > >> > this
> > >> > > >> >> and am very glad you mentioned it.
> > >> > > >> >>
> > >> > > >> >> I have now uploaded a corrected version to
> > >> > > >> www.learningj.com/unumslab.zip
> > >> > > >> >> .
> > >> > > >> >> However, I hope, I believe, that the VERSION YOU ALREADY
> HAVE
> > >> > should
> > >> > > >> run
> > >> > > >> >> OK by doing this:
> > >> > > >> >>
> > >> > > >> >>   1 !: 44 'yourdirectory'
> > >> > > >> >>
> > >> > > >> >>   first =: {.             NB. workaround for Vijay's issues
> > >> > > >> >>   snd   =: 1 & {
> > >> > > >> >>
> > >> > > >> >>   load 'labs/labs'
> > >> > > >> >>
> > >> > > >> >>   lab_jlab_ 'unums.ijt'
> > >> > > >> >>
> > >> > > >> >>
> > >> > > >> >> Thanks again,  everyone
> > >> > > >> >>
> > >> > > >> >> On Wed, Aug 17, 2016 at 4:12 AM, bill lam <
> > [email protected]>
> > >> > > wrote:
> > >> > > >> >>
> > >> > > >> >> > In the readme, it said
> > >> > > >> >> >  ... jconsole doesn't support labs
> > >> > > >> >> >
> > >> > > >> >> > This is incorrect. One can run labs on jconsole
> > >> > > >> >> > and type labrun_jlab_ '' (and up arrow to recall)
> > >> > > >> >> > to advance.
> > >> > > >> >> >
> > >> > > >> >> > Вт, 16 авг 2016, roger stokes написал(а):
> > >> > > >> >> > > Dear All,
> > >> > > >> >> > >
> > >> > > >> >> > > I've heard it said that you don't understand a subject
> > >> > > >> >> > > unless you can explain it to a computer. With that in
> mind
> > >> > > >> >> > > I've attempted a software implementation of Gustafson's
> > Unums
> > >> > 2.0
> > >> > > >> >> > >
> > >> > > >> >> > >  ( http://www.johngustafson.net/
> > presentations/Unums2.0.pdf
> > >> ).
> > >> > > >> >> > >
> > >> > > >> >> > > If anyone is interested, there is a demo available in
> the
> > >> > > >> >> > > form of a J lab. To run the lab
> > >> > > >> >> > >
> > >> > > >> >> > >        Download www.learningj.com/unumslab.zip
> > >> > > >> >> > >
> > >> > > >> >> > >        Unzip into any convenient directory
> > >> > > >> >> > >
> > >> > > >> >> > >        Follow directions in the readme file
> > >> > > >> >> > >
> > >> > > >> >> > > Comments and criticisms appreciated.
> > >> > > >> >> > >
> > >> > > >> >> > > Regards
> > >> > > >> >> > > ------------------------------
> > ------------------------------
> > >> > > >> >> ----------
> > >> > > >> >> > > For information about J forums see
> > >> > > http://www.jsoftware.com/forum
> > >> > > >> >> s.htm
> > >> > > >> >> >
> > >> > > >> >> > --
> > >> > > >> >> > regards,
> > >> > > >> >> > ====================================================
> > >> > > >> >> > GPG key 1024D/4434BAB3 2008-08-24
> > >> > > >> >> > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> > >> > > >> >> > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> > >> > > >> >> > ------------------------------
> > ------------------------------
> > >> > > >> ----------
> > >> > > >> >> > For information about J forums see
> > >> > http://www.jsoftware.com/forum
> > >> > > >> s.htm
> > >> > > >> >> >
> > >> > > >> >> ------------------------------
> ------------------------------
> > >> > > ----------
> > >> > > >> >> For information about J forums see
> http://www.jsoftware.com/
> > >> > > forums.htm
> > >> > > >> >>
> > >> > > >> >
> > >> > > >> >
> > >> > > >> ------------------------------------------------------------
> > >> > ----------
> > >> > > >> For information about J forums see http://www.jsoftware.com/
> > >> > forums.htm
> > >> > > >>
> > >> > > >
> > >> > > >
> > >> > > ------------------------------------------------------------
> > ----------
> > >> > > For information about J forums see http://www.jsoftware.com/
> > forums.htm
> > >> > >
> > >> > ------------------------------------------------------------
> > ----------
> > >> > For information about J forums see http://www.jsoftware.com/
> > forums.htm
> > >> >
> > >> ------------------------------------------------------------
> ----------
> > >> For information about J forums see http://www.jsoftware.com/
> forums.htm
> > >>
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to