Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAGICL:EXPM doesn't work on SINGLE-FLOAT or (COMPLEX SINGLE-FLOAT) matrices #135

Open
danikino opened this issue May 3, 2021 · 2 comments

Comments

@danikino
Copy link

danikino commented May 3, 2021

After installing magicl from git :
in emacs with sbcl and sly :
(ql:quickload :magicl)
(magicl.backends:active-backends)
--> (:EXPOKIT :LAPACK :BLAS :LISP)
(defparameter a (magicl:from-list '(1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0) '(3 3)))
a -->
#<MAGICL:MATRIX/DOUBLE-FLOAT (3x3):
1.000 0.000 0.000
0.000 2.000 0.000
0.000 0.000 3.000>

(magicl:logm a) -->
#<MAGICL:MATRIX/DOUBLE-FLOAT (3x3):
0.000 0.000 0.000
0.000 0.693 0.000
0.000 0.000 1.099>
now ,if i do :
(magicl:expm a) -->
MAGICL:EXPM is not implemented in any of the current active backends: EXPOKIT, LAPACK, BLAS, LISP.
[Condition of type MAGICL.BACKENDS:NO-APPLICABLE-IMPLEMENTATION]
the question is how to calculate the exponential of a matrix ?
What am I doing wrong ? I am trying to use magicl to learn robotics :) :)

@stylewarning
Copy link
Member

HI @danikino, sorry for the late response.

The issue is that expm only works on complex double-float matrices.

CL-USER> (defparameter *a (magicl:from-list '(1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0) '(3 3) :type '(complex double-float)))
*A
CL-USER> (magicl:expm *a)
#<MAGICL:MATRIX/COMPLEX-DOUBLE-FLOAT (3x3):
   2.718 + 0.000j     0.000 + 0.000j     0.000 + 0.000j
   0.000 + 0.000j     7.389 + 0.000j     0.000 + 0.000j
   0.000 + 0.000j     0.000 + 0.000j    20.086 + 0.000j>

We haven't extended it to get it to work on just double or single float matrices, but shouldn't be too hard!

@stylewarning stylewarning changed the title use of magicl:expm MAGICL:EXPM doesn't work on single- or double-float matrices Sep 14, 2021
@stylewarning
Copy link
Member

I merged support for double-float, now you can do:

CL-USER> (setf *read-default-float-format* 'double-float)
DOUBLE-FLOAT
CL-USER> (defparameter *a (magicl:from-list '(1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0) '(3 3)))
*A
CL-USER> *a
#<MAGICL:MATRIX/DOUBLE-FLOAT (3x3):
   1.000     0.000     0.000
   0.000     2.000     0.000
   0.000     0.000     3.000>
CL-USER> (magicl:expm *a)
#<MAGICL:MATRIX/DOUBLE-FLOAT (3x3):
   2.718     0.000     0.000
   0.000     7.389     0.000
   0.000     0.000    20.086>

Still no implementation for single-floats though.

@stylewarning stylewarning changed the title MAGICL:EXPM doesn't work on single- or double-float matrices MAGICL:EXPM doesn't work on SINGLE-FLOAT or (COMPLEX SINGLE-FLOAT) matrices Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants