System/Interpreter/Bugs/Errors

From J Wiki
Jump to: navigation, search
Requests: Interpreter   Bugs: Interpreter

Please restrict the headings to just two levels, with the actual bug reports placed at the top level; sign your submission using ~~~~; register the entry in the comment field below.


The interpreter handles these scenarios incorrectly.


Errors in special code

,&.>/ y does scalar replication wrong

   ,&.>/ (i. 5);4;i. 2 3
+---------+
|0 1 2 3 4|
|4 4 4 4 4|
|0 1 2 0 0|
|3 4 5 0 0|
+---------+
   ,",&.>/ (i. 5);4;i. 2 3
+---------+
|0 1 2 3 4|
|4 4 4 0 0|
|0 1 2 0 0|
|3 4 5 0 0|
+---------+

The special code behaves more like ; , figuring out the shape of the result and replicating to the full result size

-- Henry Rich <<DateTime(2014-04-30T01:15:37Z)>>

Status: open.

1: takes too long

   timespacex 'c0 17'
0.078233 2.01328e8
   timespacex 'c01 17'
0.761976 1.61061e9
   c0
,@((1 0 1 */ ])^:(]`(1"_)))
   c01
,@((1 0 1 */ ])^:(]`1:))

(I am just guessing at how this issue should be classified)

--Raul Miller (talk) 16:19, 1 December 2017 (UTC)

Bugs in 13 : and f.

13&:'s result different from 4&:

  s=:' (r # x) ,. (r=. x -.@= y) # y'
  fi=:13 : s
  fe=: 4 : s
  1 3 2 3 fi 4 3 5 3   NB. Bug
1 1
2 2
  1 3 2 3 fe 4 3 5 3   NB. Correct
1 4
2 5

Status: open

-- June Kim <<DateTime(2007-02-09T01:27:15Z)>>


bugs in fixing hybrid tacit/explicit self-referential verbs (in anonymous definitions)

There is a slight bug in J6's new method of isolating the context of $: when fixing verbs.

Verbs derived from f. are erroneous when:

  • The argument contains an anonymous expression using:
  • a named verb which itself:
  • mixes self reference (with $:) and a multi-line explicit verb (commonly, to default one of the arguments to that explicit verb).

I have not investigated whether it is possible to generalize or further restrict these criteria.

Example:

   dyadic      =: 4 : 0
this is my verb
with multiple lines
)
   ambivalent  =: ($:~ 0:) : dyadic

   (ambivalent ]) f.
4 : 0 ]
x ($:~ 0:) :(4 : 0)
this is my verb
with multiple lines
) y
)

Note that f. attempts to nest one multi-line explicit definition within another, resulting in syntax errors like ) y and pending explicit definitions like : 0 (which J will attempt to read from the keyboard when the verb is invoked). For example:

   dyadic      =: 4 : ('z=.x+y';'2*z')
   ambivalent  =: ($:~ 0:) : dyadic
   fixed       =: (ambivalent +:) f.

   fixed 10
J is asking me to give
the defintion of the (incorrectly) nested explicit definition
but the invocation will choke on regardless of what I type.
)

The error results from a bug in how f. attempts to isolate the context of $:; it does not handle multi-line definitions properly.

The bug would be fixed if the erroneous nesting were replaced by the linear representation of the text of the definition, enclosed in parentheses. For example, a correct formulation of the above would be:

   ] text =. (a:,1;1;1) {:: 5!:1{.;:'dyadic'
z=.x+y
2*z

   5!:5{.;:'text'
2 6$'z=.x+y2*z   '

   fixed =: 4 : 0 +:
x ($:~ 0:) : (4 : (2 6$'z=.x+y2*z   ')) y
)

   fixed 10
60

Other single-line definition formats amenable to : might result in more readable code (if that is relevant for the normally-unscrutinized result of f.). E.G., one might prefer 'z=.x+y';'2*z' to the lrep in the preceding.

Status: open

-- Dan Bron <<DateTime(2007-04-02T18:48:20Z)>>


ambivalent verbs improperly fixed

The domain errors at the end of this example are spurious, and caused by a bug in f.:

   defaultLHA =: 99&$: : [

   defaultLHA 9
99
   12 defaultLHA 9
12
   iLike42 =: 42&defaultLHA

   iLike42 78
42

   12 iLike42 78
42

   iLike42 f. 78
|domain error
|       iLike42 f.78

   12 iLike42 f. 78
|domain error
|   12     iLike42 f.78

The problem is how f. fixes iLike42:

   iLike42 f.
42&(3 : '99&$: :[ y')

Note that the original verb was ambivalent, but f. has constrained it to a monad. The proper fix would be 42 & (3 : '(99&$: :[) y') : (4 : 'x (99&$: : [) y'), or something similar.

I'm not sure what relationship this bug has to the bug in fixing hybrid verbs or the fixed verbs broken report.

Applies to ('j602/2008-03-03/16:45';6;'jwin32' ) -: (9!:14'') ; (9!:12'') ; wd 'qwd' (This does not mean that the bug is restricted to this environment, only that it is the one I tested.)

Status: open

-- Dan Bron <<DateTime(2008-07-30T14:35:34Z)>>


Bugs in Calculus and Sparse Arrays

spurious "non unique" error with dyad / and sparse arrays

As reported in the Forums, phrases of the form sparseA f/ sparseB cause spurious (?) non-unique sparse elements errors:

   =/~ $. , 1
|non-unique sparse elements
|       =/~$.,1

I'm not positive this is a bug, because I'm not clear on when such errors are raised, but the documentation says (3940 178 qdoj 'errors'):

non-unique sparse elements ($.i.4){i.4 2 the sparse element of a sparse array must be an atom

and since the arguments to f/ are properly-formed sparse arrays, and the user has no further control of the sparse element specified within the logic of f/, the error is not his fault, and he cannot avoid it.

Status: open

-- Dan Bron <<DateTime(2006-12-30T18:53:50Z)>>


Higher derivatives inaccurate unless symbolic

   0j13 ": sin d.3 (1)  NB. The correct result, calculated symbolically
_0.5403023058681
   0j13 ": sin D.3 (1)  NB. Approximation - way off!
111022.3024625156500
   0j13 ": sin D. 1 D. 1 D. 1 (1)  NB. Not as far off if done by hand
_0.5352054832652

   0j13 ": 1E_6 sin D:3 (1)  NB. Error seems to be too small a step
111.0223024625157
   0j13 ": 1E_4 sin D:3 (1)
_0.5400124791777

-- Henry Rich <<DateTime(2014-04-19T21:17:40Z)>>

Status: open.

Second partial derivatives wrong

   func =: verb define   NB. (x-2)^2 + (y-3)^2
'x y' =. y
(*: x-2) + (*: y-3)
)
   ]hessian =: func D. 2 (2 3)  NB. Hessian at (2,3) - should be symmetric!
       2 _0.5
0.333333    2
   ]hessian =: func D. 1 D. 1 (2 3)  NB. better
           2 _2.64698e_16
_8.82326e_17            2

-- Henry Rich <<DateTime(2014-04-19T21:17:40Z)>>

Status: open.


Other errors

Nub gives wrong result, and is inconsistent with #/. and u/.

   0j16": tb=. 1+2e_14*i:3
0.9999999999999400 0.9999999999999600 0.9999999999999800 1.0000000000000000 1.0000000000000200 1.0000000000000400 1.0000000000000600
   =/~ tb
1 1 1 0 0 0 0
1 1 1 1 0 0 0
1 1 1 1 1 0 0
0 1 1 1 1 1 0
0 0 1 1 1 1 1
0 0 0 1 1 1 1
0 0 0 0 1 1 1
   0j16": ~.tb
0.9999999999999400
   ~:tb
1 0 0 0 0 0 0
   =tb
1 1 1 0 0 0 0

0{tb is not tolerantly equal to 3{tb so 3{tb should be a member of ~.tb according to the dictionary definition of ~. which says: “More precisely, the nub is found by selecting the leading item, suppressing from the argument all items tolerantly equal to it, selecting the next remaining item, and so on.” So the nub monad gives the wrong result, and the nub sieve and self-classify verbs give a wrong result consistent with it.

Moreover, ~. should always produce the same partitioning as u/., but it doesn't:

   ~. tb
1
   </.~ tb
+-----+-+-+-+-+
|1 1 1|1|1|1|1|
+-----+-+-+-+-+

Also, the special case #/. loses some of the items in this case:

   #/.~ tb
3

The special case (#,{.)/. suffers the same problem:

    (#,{.)/.~ tb
|length error
| (#,{.)/.~tb

-- User:B Jonas <<DateTime(2015-06-09T21:44:32+0200)>>

Status: open. Roger suggests applying i.~ to imprecise arguments before forming the equivalence classes.

Error in rxmatches (regex)

Verified for J 8.05 and J 8.06:

   load 'regex'
   '(?m)^.{2}' rxall 'abcde' , LF , '12345' , LF
+--+--+--+--+
|ab|cd|12|34|
+--+--+--+--+
   NB. it's wrong, the result should be:
+--+--+
|ab|12|
+--+--+

-- User:Igor Zhuravlov

Error in float representation between 1e15 and 1e19

should return float values for all cases Verified for J 8.05 and J 8.06:

   JVERSION
Engine: j806/j64avx/darwin
Beta-4: commercial/2017-06-27T12:55:06
Library: 8.06.03
Qt IDE: 1.5.3/5.6.2
Platform: Darwin 64
Installer: J806 install
InstallPath: /users/bobtherriault/j64-806
Contact: www.jsoftware.com
   (; datatype) 999999999999999.3
┌────┬────────┐
│1e15│floating│
└────┴────────┘
   (; datatype) 9999999999999999.3
┌─────────────────┬───────┐
│10000000000000000│integer│
└─────────────────┴───────┘
   (; datatype) 99999999999999999.3
┌──────────────────┬───────┐
│100000000000000000│integer│
└──────────────────┴───────┘
   (; datatype) 999999999999999999.3
┌───────────────────┬───────┐
│1000000000000000000│integer│
└───────────────────┴───────┘
   (; datatype) 9999999999999999999.3
┌────┬────────┐
│1e19│floating│
└────┴────────┘

-- User: bob therriault

Faulty linear representations of some bonded conjunctions

Linear representations of atomic representations, or similar, of conjunctions and adverbs (even verbs) bonded to tie and evoke are faulty:

   (<,'&')`
&`
   `(<'&')
`&   
   (<'/')`:
/`:

-- User: Pepe Quintana

Uninitialized sequential machine

Sequential machine fails for function 1 with integer data. As I recall there are some cases where c variables are used before initialization.

NB. FSM to discard alternate items instead demonstrates bug.

STATE=: 1 1 ,:&:(,:~) 0 3
Y=:i.8
map=: <@:{.
FSM=: (1 ; STATE ; <@:map) Y
FSM ;: Y



   Note'JVERSION'
   
   FSM;:'abcde'
ace
   
   FSM;:Y
0 2 4 6 4613937818241073152 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 139966340226320 786440 64 0 176 2 _9223372036854775807 1 1 1

   ((<0),}.FSM);:Y
+-+-+-+-+
|0|2|4|6|
+-+-+-+-+


   FSM
┌─┬───┬───┐
│1│1 1│┌─┐│
│ │1 1││0││
│ │   │└─┘│
│ │0 3│   │
│ │0 3│   │
└─┴───┴───┘


Engine: j806/j64avx/linux
Beta-3: commercial/2017-04-10T17:51:14
Library: 8.06.09
Platform: Linux 64
Installer: J806 install
InstallPath: /home/lambertdw/downloads/installs/j64-806
Contact: www.jsoftware.com
)

-- User: David Lambert