Re: [pure-lang-users] case
Status: Beta
Brought to you by:
agraef
From: Eddie R. <er...@bm...> - 2008-08-29 14:14:45
|
On Fri, 2008-08-29 at 02:26 +0200, Albert Graef wrote: > Yes, I see. So it's just a blob with dimensions and stride attached to > it. Well, I could easily generate data compatible with that in Pure, > along with the usual access operations and support in the runtime. > Memory management would be provided by Pure. > > I could then add the necessary marshalling so that these thingies could > be passed either as is to GSL, or the underlying gsl_block to the BLAS > routines, or just the pointer to the blob to int*, double* etc., so that > they could be used with graphics and audio software just as easily. > > Of course we need to fix a syntax for those arrays. I'd suggest the > following: {x1,x2,...} is a vector (compatible with gsl_vector struct > layout), {x11,x12,...; x21,x22,...; ...} is a matrix (compatible with > gsl_matrix struct layout). > > Elements would be either integers or doubles, promoting all ints to > double in the mixed case. We can think about complex numbers later. > Using some macro hackery, it should also be possible to provide some > kind of array comprehensions. I still have to think about this. > > Does that proposal sound reasonable? Using the method GSL uses internally for vectors and matrices seems reasonable and would probably allow for fast routines and make it easy for interfacing to other libraries and/or hardware. I think that maybe some of the primitive operations like addition, subtraction, multiplication, and a reciprocal function might be handled best internally in Pure though. Before you say no too quickly, let me point out that GSL_BLAS has a bunch of steps involved just to multiply two matrices. There is a routine to directly add two matrices but not for multiplication. For example to multiply to matrices with double entries, I have to use the following procedure (there is a more sophisticated version that deals with order (row major vs column major order like in FORTRAN) and some other things. int gsl_blas_dgemm (CBLAS_TRANSPOSE_t TransA, CBLAS_TRANSPOSE_t TransB, double alpha, const gsl_matrix * A, const gsl_matrix * B, double beta, gsl_matrix * C) Thus, the matrix operation follows C = alpha*A*B + beta*C; TransA and TransB have to be set to CblasNoTrans for regular multiplication, other choices are CblasTrans and CblasConjTrans. e.r. |