Continuous arrays system


#1

Dear friends, good day!

I tried to build in an additional system of continuous type arrays. I needed it for using fast codes on c/c++, fft, sound and image processing, bmp-graphics putimage getimage.

In this new source old arrays “aref”, “arrayp”, “make-array” are work same. New array commands are named “aref*”, “arrayp*”, “make-array*”, and “del-array*”. Example of calls:

(defvar b (make-array* '(4 4) :element-type 'single-float))

(do ((i 0 (1+ i)))  ((= i 4))
  (do ((j 0 (1+ j)))  ((= j 4))
  (setf (aref* b i j) (+ (* i 4) j))
 )
)

5480> (print b)
#2A((0 1.0 2.0 3.0) (4.0 5.0 6.0 7.0) (8.0 9.0 10.0 11.0) (12.0 13.0 14.0 15.0))
#2A((0 1.0 2.0 3.0) (4.0 5.0 6.0 7.0) (8.0 9.0 10.0 11.0) (12.0 13.0 14.0 15.0))

5480> (save-image)
Write cell:94,  array size 64
3570
5480>

After reseting device:

5483> (print b)
Error: undefined: b

After reset “b” - is unknown

5483> (load-image)
Read cell:94,  array size 64
3570

The b-array data are restored now:

5480> (print b)
#2A((0 1.0 2.0 3.0) (4.0 5.0 6.0 7.0) (8.0 9.0 10.0 11.0) (12.0 13.0 14.0 15.0))
#2A((0 1.0 2.0 3.0) (4.0 5.0 6.0 7.0) (8.0 9.0 10.0 11.0) (12.0 13.0 14.0 15.0))
5480>
5480>(array-dimensions b) 
(4 4)
5480>

The new arrays system changes can be on or off by

#define DEF_ARRAY2

You can found new array implementation parts by search

#if defined(DEF_ARRAY2)

in this sources. These changes was made in following procedures:

sweep
saveimage
loadimage
delassoc
**place
sp_push
sp_pop
sp_incf
sp_decf
setf
fn_length
fn_arraydimensions
fn_makunbound
printobject
setup
symbol_t Aref2_name ; //variable is added

Github of the sources: https://github.com/molnija2/ulisp-arraysys2

At present moment bit-type calls processing is not supported, but it can be added.

Saving data has been tested on an SD card.
The new array system is still raw. But it was tested on some tasks for the x86 platform.
Any of you can use these developments if its are useful.
Dear friends, if you don’t believe me, you can ask our neighbors in the Galaxy about it. (Incidentally, we are already here).


#2

I had to enter a descriptor in the array header that stores the dimensions and type.

typedef struct {
  int32_t dim[8];
  int32_t dimstep[8];
  int ndim;
  int element_size;
  size_t size;
  uintptr_t  type ;
  object bufferobj ;
  object *obj_pointer ;
} array_desc_t;

Elements type control in (make-array*…) parameters:

:element-type 'single-float
:element-type 'integer
:element-type 'character

I haven’t yet managed to formalize this as a separate extension without interfering with the uLisp source code.