|
From: Raymond T. <toy...@gm...> - 2012-03-18 17:46:07
|
On 3/17/12 4:09 AM, Akshay Srinivasan wrote: -matlisp-commit +matlisp-devel > ;;Create a 4x4 matrix with random entries > (defvar d (make-complex-matrix 4 4)) > > (dotimes (i 4) > (dotimes (j 4) > (setf (matrix-ref-2d d i j) > (complex-coerce (complex (cl:random 10) (cl:random 10)))))) There's a rand() function, but it currently doesn't work because :row-stride is unbound. Is there a reason why these are unbound? Isn't there some suitable default for this, assuming we're creating a regular full matrix? Can we also fix the issue in mtimes and the autoswap thing? I'm not exactly sure what you're trying to do, but if you explain it to me, I can probably help with that. > ;;Submatrix of d starting at (1, 1) or size (2, 2) > (defvar e (sub! d 1 1 2 2)) We should pick a better name than sub!, like maybe sub-matrix!. And what does the ! mean here? The intention for "!" is to mean a destructive operation so does sub! destructively modify d to make a submatrix? And what would that actually mean? If it's not destructive, then don't use "!". It seems that e and d now both refer to the same storage. So if I modify e, d will magically change? That's expected, but once e is created, it becomes very easy to lose track of the fact that it is a submatrix of d, especially at the repl. I think we need to make the relationship more explicit. Maybe create a new class that is a subclass of matrix (or whatever) that adds a slot that holds a reference to the matrix. Kind of like how in lisp you can have displaced arrays, and you can tell it's displaced and can chase down all the way to the final, non-displaced array if you want to. But don't get me wrong. Real submatrices are really, really cool! BTW, can you merge the master branch to the matlisp-cffi branch? There are a few changes that I need to build correctly. I tried myself, but there's a conflict which I'm not confident in resolving on my own. Thanks for your work, Ray |