Prev: Persistent arrays
Next: AUTHENTIC DESIGNER HANDBAGS ACCESSORIES GREAT DISCOUNTS! WWW.VOGUELANDE.COM
From: allchemist on 27 Mar 2010 13:29 Hello! I'm searching the way of adjusting marrays. I defined a func (defun make-matrix (dimensions) (gsl:make-marray 'single-float :dimensions dimensions :allow-other-keys t :adjustable t)) (defparameter *m* (make-matrix '(3 3))) Common adjusting like (adjust-array (gsl:cl-array *m*) '(4 3)) returnes a native array with adjusted dimensions and structure: (defparameter *a* (adjust-array (gsl:cl-array *m*) '(4 3))) (array-dimensions *a*) ;=> '(4 3) The marray *m* itself will have an adjusted structure, and (gsl:maref *m* 3 0) returnes 0.0. But the dimensions of *m* are not adjusted: (gsl:dimensions *m*) ;=> '(3 3). It's bad, since I can't get a whole row which I added using gsl:row. Since the native array, which is returned from adjust-array, has a proper structure, I tried to create marray of it using the key :data: (gsl:make-marray 'single-float :dimensions '(4 3) :data *a*), but it complains at the type of *a*: make-marray wants to recieve simple-array, but *a* has type (and (array single-float (4 3)) (not simple-array)) because it has been adjusted. So, please let me know if i have a mistake somethere or you know another possible method of adjusting gsll marrays.
From: Tamas K Papp on 27 Mar 2010 13:39 On Sat, 27 Mar 2010 10:29:45 -0700, allchemist wrote: > Hello! > I'm searching the way of adjusting marrays. > > I defined a func > (defun make-matrix (dimensions) > (gsl:make-marray 'single-float :dimensions dimensions > :allow-other-keys t :adjustable t)) > (defparameter *m* (make-matrix '(3 3))) Common adjusting like > (adjust-array (gsl:cl-array *m*) '(4 3)) returnes a native array with > adjusted dimensions and structure: (defparameter *a* (adjust-array > (gsl:cl-array *m*) '(4 3))) (array-dimensions *a*) ;=> '(4 3) > The marray *m* itself will have an adjusted structure, and (gsl:maref > *m* 3 0) returnes 0.0. But the dimensions of *m* are not adjusted: > (gsl:dimensions *m*) ;=> '(3 3). It's bad, since I can't get a whole row > which I added using gsl:row. > > Since the native array, which is returned from adjust-array, has a > proper structure, I tried to create marray of it using the key :data: > (gsl:make-marray 'single-float :dimensions '(4 3) :data *a*), but it > complains at the type of *a*: > make-marray wants to recieve simple-array, but *a* has type (and (array > single-float (4 3)) (not simple-array)) because it has been adjusted. > > So, please let me know if i have a mistake somethere or you know another > possible method of adjusting gsll marrays. There is a gsll-devel mailing list, you are much more likely to get quick help there. Tamas
From: allchemist on 27 Mar 2010 13:54 Thanks for answer. By the way, I didn'need a quick help, now I have some variant of concatenating marrays, though it generates a lot of garbage
From: Thomas A. Russ on 29 Mar 2010 13:19 allchemist <hohlovivan(a)gmail.com> writes: > Hello! > I'm searching the way of adjusting marrays. > > I defined a func > (defun make-matrix (dimensions) > (gsl:make-marray 'single-float :dimensions dimensions > :allow-other-keys t :adjustable t)) > (defparameter *m* (make-matrix '(3 3))) > Common adjusting like (adjust-array (gsl:cl-array *m*) '(4 3)) > returnes a native array with adjusted dimensions and structure: > (defparameter *a* (adjust-array (gsl:cl-array *m*) '(4 3))) > (array-dimensions *a*) ;=> '(4 3) > The marray *m* itself will have an adjusted structure, and (gsl:maref > *m* 3 0) returnes 0.0. But the dimensions of *m* are not adjusted: > (gsl:dimensions *m*) ;=> '(3 3). It's bad, since I can't get a whole > row which I added using gsl:row. Well, I would think that you would need to use whatever support gsl provides for having an adjustable array. I am a little bit concerned by your use of ":allow-other-keys t" in your call to GSL:MAKE-ARRAY. If GSL:MAKE-ARRAY supports the :ADJUSTABLE keyword, then you shouldn't need that. If GSL:MAKE-ARRAY doesn't support the :ADJUSTABLE keyword, then the only thing that supplying :ALLOW-OTHER-KEYS does is prevent an error from being signaled for an unsupported keyword. It doesn't somehow magically make the unsupported keyword supported. So, this should only really work if GSL supports adjustable arrays. However, since it appears that you can adjust the underlying Common Lisp array, the parameter must really be supported. I guess the issue perhaps lies with the code not returning the proper dimensions? That would sound like a bug in the GSL code, then. Perhaps it has never really been tested much for this particular configuration. In that case, you should report this problem to the maintainers of the gsl software. In the meantime, perhaps it would be sufficient for you to write your own work-around function: (defun gsl-dimensions (gsl-matrix) (array-dimensions (gsl:cl-array gsl-matrix))) > SINCE the native array, which is returned from adjust-array, has a > proper structure, I tried to create marray of it using the key :data: > (gsl:make-marray 'single-float :dimensions '(4 3) :data *a*), but it > complains at the type of *a*: > make-marray wants to recieve simple-array, but *a* has type (and > (array single-float (4 3)) (not simple-array)) because it has been > adjusted. -- Thomas A. Russ, USC/Information Sciences Institute
|
Pages: 1 Prev: Persistent arrays Next: AUTHENTIC DESIGNER HANDBAGS ACCESSORIES GREAT DISCOUNTS! WWW.VOGUELANDE.COM |