quil-lang / magicl

Matrix Algebra proGrams In Common Lisp.
BSD 3-Clause "New" or "Revised" License
238 stars 44 forks source link

Add Optimizations for rank 2 tensors #200

Closed anranyicheng closed 1 year ago

anranyicheng commented 1 year ago

now function from-list can do this:


(from-list '((1 2 3 4) (5 6 7 8)) '(2 4) :type 'double-float)
(from-list '(#(1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)
(from-list #(#(1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)
(from-list #((1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)
(from-list #(#(1 2 3 4)(5 6 7 8)) '(2 4))
(from-list '((1.0d0 2 3 4)(5 6 7 8)) '(2 4))
(from-list '((1.0d0 2 3 4)(5 6 7 8)) '(2 4) :type '(complex single-float))

and result is: MAGICL> (from-list '((1 2 3 4) (5 6 7 8)) '(2 4) :type 'double-float)

<MATRIX/DOUBLE-FLOAT (2x4):

1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000> MAGICL> (from-list '(#(1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)

<MATRIX/DOUBLE-FLOAT (2x4):

1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000> MAGICL> (from-list #(#(1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)

<MATRIX/DOUBLE-FLOAT (2x4):

1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000> MAGICL> (from-list #((1 2 3 4) #(5 6 7 8)) '(2 4) :type 'double-float)

<MATRIX/DOUBLE-FLOAT (2x4):

1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000> MAGICL> (from-list #(#(1 2 3 4)(5 6 7 8)) '(2 4))

<MATRIX/INT32 (2x4):

1      2      3      4
5      6      7      8>

MAGICL> (from-list '((1.0d0 2 3 4)(5 6 7 8)) '(2 4))

<MATRIX/DOUBLE-FLOAT (2x4):

1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000> MAGICL> (from-list '((1.0d0 2 3 4)(5 6 7 8)) '(2 4) :type '(complex single-float))

<MATRIX/COMPLEX-SINGLE-FLOAT (2x4):

1.000 + 0.000j 2.000 + 0.000j 3.000 + 0.000j 4.000 + 0.000j 5.000 + 0.000j 6.000 + 0.000j 7.000 + 0.000j 8.000 + 0.000j> MAGICL>

stylewarning commented 1 year ago

Thanks!