From: Akshay S. <aks...@gm...> - 2012-03-20 07:05:31
|
> It seems to me that if I do (make-instance 'real-matrix :nrows > rows :ncols cols) I shouldn't have to specify the strides unless I > really want to. There should be some default. Either column-major > or row-major. Apparently this is the way it was supposed to work (I take my words back :) I think the initarg for {row,col}-stride was changed from zero, which makes it throw up a unbound error. I've fixed this now. > > >> >>> ;;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 "!". >> > Yes, it is a bad naming convention. Can we pick some other > character to indicate that the store is shared ? The "!" was meant > to indicate that the store is essentially the same, but this > contradicts with the usual Lisp convention. > >> 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. > That sounds reasonable, shouldn't be too hard to do. > > > I think if you do this, then you don't need any special naming > convention. sub-matrix creates a submatrix of the given matrix, > and the type (submatrix) tells us instantly that something is > shared. And we can, if we want to, chase down what matrix we're a > submatrix of. I can imagine submatrices of submatrices of .... Hmm, but if one would want to copy the submatrix, we'd have to call it something else. Or we can make sure that we never copy anything by default, I'm more in favour of this. Akshay |