From: rif <rif@MIT.EDU>  20041208 04:06:01

Is there any way, in CMUCL, using some implementationspecific construct, to create an "aliased array"? Suppose I create a doublefloat array of size 10: (makearray 10 :elementtype 'doublefloat) I know I can take it's address, with #'system:vectorsap. What I want to do is manipulate that address and somehow "invert" vectorsap to create a new doublefloat array whose first element is (for example) the third element of the original array. I need this because I need to pass matlisp a subset of an array. More specifically, I want to allocate an n by n+1 array, so that I can store half of each of two n by n symmetric arrays in n(n+1) space rather than 2n^2 space. This is a common technique for using BLAS/LAPACK, but to get at it, I need to be able to give a Fortran matlisp routine a way to get at the square n by n matrix that "starts with the second column" of the n by n+1 matrix, and the way the interface is defined, it wants actual arrays, not pointers. If I can somehow create the appropriate array, I don't have to go mucking about in the internals of matlisp's deffortranroutine and so forth. (Note that I only need this "aliased array" temporarily, and I'd of course turn gc off while I needed it.) Any suggestions or advice are appreciated. If you respond, please cc to rif directly  I think I'm on both these lists, but I'm not 100% sure. rif 
From: Marcin Tustin <mm3@ze...>  20041208 08:39:00

http://www.lisp.org/HyperSpec/Body/glo_d.html#displaced_array 
From: Raymond Toy <raymond.toy@er...>  20041208 12:43:51

>>>>> "rif" == rif <rif@...> writes: rif> Is there any way, in CMUCL, using some implementationspecific rif> construct, to create an "aliased array"? Suppose I create a rif> doublefloat array of size 10: rif> (makearray 10 :elementtype 'doublefloat) rif> I know I can take it's address, with #'system:vectorsap. rif> What I want to do is manipulate that address and somehow "invert" rif> vectorsap to create a new doublefloat array whose first element is rif> (for example) the third element of the original array. rif> I need this because I need to pass matlisp a subset of an array. More rif> specifically, I want to allocate an n by n+1 array, so that I can rif> store half of each of two n by n symmetric arrays in n(n+1) space rif> rather than 2n^2 space. This is a common technique for using rif> BLAS/LAPACK, but to get at it, I need to be able to give a Fortran rif> matlisp routine a way to get at the square n by n matrix that "starts rif> with the second column" of the n by n+1 matrix, and the way the rif> interface is defined, it wants actual arrays, not pointers. If I can rif> somehow create the appropriate array, I don't have to go mucking about rif> in the internals of matlisp's deffortranroutine and so forth. Marc has already mentioned displaced arrays. This should work, but depends on what you are really trying to do. What matlisp function are you trying to call? Ray 
From: Marco Antoniotti <marcoxa@cs...>  20041208 14:41:20

On Dec 8, 2004, at 7:43 AM, Raymond Toy wrote: >>>>>> "rif" == rif <rif@...> writes: > > rif> Is there any way, in CMUCL, using some implementationspecific > rif> construct, to create an "aliased array"? Suppose I create a > rif> doublefloat array of size 10: > > rif> (makearray 10 :elementtype 'doublefloat) > > rif> I know I can take it's address, with #'system:vectorsap. > > rif> What I want to do is manipulate that address and somehow > "invert" > rif> vectorsap to create a new doublefloat array whose first > element is > rif> (for example) the third element of the original array. > > rif> I need this because I need to pass matlisp a subset of an > array. More > rif> specifically, I want to allocate an n by n+1 array, so that I > can > rif> store half of each of two n by n symmetric arrays in n(n+1) > space > rif> rather than 2n^2 space. This is a common technique for using > rif> BLAS/LAPACK, but to get at it, I need to be able to give a > Fortran > rif> matlisp routine a way to get at the square n by n matrix that > "starts > rif> with the second column" of the n by n+1 matrix, and the way > the > rif> interface is defined, it wants actual arrays, not pointers. > If I can > rif> somehow create the appropriate array, I don't have to go > mucking about > rif> in the internals of matlisp's deffortranroutine and so > forth. > > Marc has already mentioned displaced arrays. This should work, but > depends on what you are really trying to do. Not necessarily. Displaced arrays are good for rowmajor slices. So if the matrix where (N + 1 x N), then you could "displace away" the first row. Unfortunately, FORTRAN is columnmajor. The only way I see around this is to transpose the array first, and then displace. However, that may cause problems for the algorithm at hand. Isn't this fun? :) Cheers  Marco Antoniotti http://bioinformatics.nyu.edu NYU Courant Bioinformatics Group tel. +1  212  998 3488 715 Broadway 10th FL fax. +1  212  998 3484 New York, NY, 10003, U.S.A. 