From: SourceForge.net <no...@so...> - 2011-04-23 21:03:36
|
Bugs item #3291590, was opened at 2011-04-22 21:05 Message generated for change (Settings changed) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3291590&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Dieter Kaiser (crategus) Assigned to: Nobody/Anonymous (nobody) Summary: Problems with fast arrays Initial Comment: 1. make_array(hashed) does not work We dot not get a hashed array. But we write values in a structure returned by make_array. (%i1) a:make_array(hashed,1); (%o1) {Array: #(NIL NIL $HASHED NIL NIL G968)} (%i2) a[0]:0$ a[1]:1$ a[2]:2$ a[3]:3$ a[4]:4$ a[5]:5$ (%i8) a; (%o8) {Array: #(0 1 2 3 4 5)} (%i9) a[6]:6; Maxima encountered a Lisp error: Index 6 out of bounds for (SIMPLE-VECTOR 6), should be nonnegative and <6. Automatically continuing. To enable the Lisp debugger set *debugger-hook* to nil. This is the correct behavior. The hash-table works as expected. (%i1) a:make_array(hashed); (%o1) #<HASH-TABLE :TEST EQUAL :COUNT 1 {C6FA0F9}> (%i2) a[100]:100; (%o2) 100 (%i3) a[x]:sin(x); (%o3) sin(x) (%i4) a[x*y]:x^2+y; (%o4) y+x^2 (%i5) arrayinfo(a); (%o5) [hash_table,1,100,x,x*y] (%i6) listarray(a); (%o6) [100,sin(x),y+x^2] 2. make_array(functional, .... ) does not work First the check of the dimensions is not correct for the case of arrays of type functional, but there are more problems. Arrays of type functional allow memoizing functions, e.g. make_array(functional, 'factorial, hashed) will store the factorials in an array. This is an example with already corrected code. The second call f[100000] gets the stored value: (%i1) f:make_array(functional, 'factorial, hashed); (%o1) #S(MGENARRAY :AREF NIL :ASET NIL :TYPE $FUNCTIONAL :NULL NIL :GENERATOR MFACTORIAL :CONTENT #<HASH-TABLE :TEST EQUAL :COUNT 1 {CBBDB51}>) (%i2) showtime:true$ (%i3) bfloat(f[100000]); Evaluation took 7.5960 seconds (8.3920 elapsed) using 4.743 MB. (%o3) 2.824229407960348b456573 (%i4) bfloat(f[100000]); Evaluation took 0.0040 seconds (0.0030 elapsed) using 925.750 KB. (%o4) 2.824229407960348b456573 3. listarray does not work for multidimensional arrays (%i1) a: make_array(fixnum, 2, 2); (%o1) {Array: #2A((0 0) (0 0))} (%i2) arrayinfo(a); (%o2) [declared, 2, [1, 1]] (%i3) listarray(a); Maxima encountered a Lisp error: #2A((0 0) (0 0)) can't be converted to type LIST. Automatically continuing. To enable the Lisp debugger set *debugger-hook* to nil. 4. array(a, ...) does not work with use_fast_arrays Only untyped arrays are possible if the option variable user_fast_arrays has the value true: (%i1) array(a, 2, 2); (%o1) #2A((NIL NIL NIL) (NIL NIL NIL) (NIL NIL NIL)) (%i2) array(a, any, 2, 2); make_array: dimensions must be integers; found [any + 1, 3, 3] -- an error. To debug this try: debugmode(true); (%i3) array(a, fixnum, 2, 2); make_array: dimensions must be integers; found [fixnum + 1, 3, 3] -- an error. To debug this try: debugmode(true); (%i4) array(a, hashed); make_array: dimensions must be integers; found [hashed + 1] -- an error. To debug this try: debugmode(true); With the corrected code we get the expected behavior: (%i1) array(a, 2, 2); (%o1) #2A((NIL NIL NIL) (NIL NIL NIL) (NIL NIL NIL)) (%i2) array(a, any, 2, 2); (%o2) #2A((NIL NIL NIL) (NIL NIL NIL) (NIL NIL NIL)) (%i3) array(a, fixnum, 2, 2); (%o3) #2A((0 0 0) (0 0 0) (0 0 0)) (%i4) array(a, flonum, 2, 2); (%o4) #2A((0.0 0.0 0.0) (0.0 0.0 0.0) (0.0 0.0 0.0)) (%i5) array(a, hashed); (%o5) #<HASH-TABLE :TEST EQUAL :COUNT 1 {C6DA0F9}> Dieter Kaiser ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2011-04-23 23:03 Message: The problems of this bug report have been fixed in the following commits: http://maxima.git.sourceforge.net/git/gitweb.cgi?p=maxima/maxima;a=commit;h=ec5e5b9c63a0e93569470b4ac1af887465d809c6 http://maxima.git.sourceforge.net/git/gitweb.cgi?p=maxima/maxima;a=commit;h=d470f077514f7a367d0171a6ce8fb5b2049474c2 http://maxima.git.sourceforge.net/git/gitweb.cgi?p=maxima/maxima;a=commit;h=2febc9528ae55cf458e4061376a1a29e57d5fb25 http://maxima.git.sourceforge.net/git/gitweb.cgi?p=maxima/maxima;a=commit;h=1b6b8268af6d6d2514a4eb6c16a8fbcb43b8916e Closing this bug report as fixed. Dieter Kaiser ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3291590&group_id=4933 |