unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Uniform vectors, user survey
@ 2004-10-22 14:19 Marius Vollmer
  2004-10-23 14:02 ` Neil Jerram
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Marius Vollmer @ 2004-10-22 14:19 UTC (permalink / raw)


Hi,

I want to unify our two implementations of uniform vectors, and make
them more useful.

We do have (srfi srfi-4), which implements uniform vectors according
to SRFI-4, and we have the 'old' uniform vectors that are created with
'make-uniform-vector'.

I guess uniform vectors would be mainly useful for interfacing to
external code that deals with large arrays.  Like the GNU Scientific
Library, say, or maybe things like data compression, image
manipulation, binary file formats in general, etc.

Instead of using uniform vectors, one can always define a new smob
type that can wrap the large external array.  But maybe uniform
vectors would be preferable in some cases, if only you could convince
Guile to handle the external memory right (like you can with smobs).

I have close to zero experience with using uniform vectors myself, so
I appreciate your input.  Do you use uniform vectors?  What for?  Did
you try but couldn't make them work for you?  What do you wish would
be different about them?  Etc.

Thanks!


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
@ 2004-10-23 14:02 ` Neil Jerram
  2004-10-24 16:04 ` Mikael Djurfeldt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Neil Jerram @ 2004-10-23 14:02 UTC (permalink / raw)
  Cc: guile-user

Marius Vollmer wrote:

>Hi,
>  
>
Hi Marius

>I want to unify our two implementations of uniform vectors, and make
>them more useful.
>  
>
Sounds like a good objective.

>I have close to zero experience with using uniform vectors myself, so
>I appreciate your input.  Do you use uniform vectors?  What for?  Did
>you try but couldn't make them work for you?  What do you wish would
>be different about them?  Etc.
>  
>
I use uniform byte vectors in my Guile extension to an application whose 
interfaces are all expressed in terms of C structs, so that I can build 
the struct (represented as a uniform byte vector) in Scheme and then 
call a C function that does the generic "dispatch this struct" operation.

I could now rewrite this using a SMOB instead (and arguably should, as 
that would give me better control over how the struct memory is shared 
between C and Scheme), but that would have slowed down my prototyping, 
and at the time it was very nice to get something up and running quickly.

Hope this is useful.

Regards,
Neil




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
  2004-10-23 14:02 ` Neil Jerram
@ 2004-10-24 16:04 ` Mikael Djurfeldt
  2004-10-25 18:08 ` Stephen Compall
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Mikael Djurfeldt @ 2004-10-24 16:04 UTC (permalink / raw)
  Cc: guile-user, djurfeldt

Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:

> I want to unify our two implementations of uniform vectors, and make
> them more useful.

Sounds like an important improvement.

> I guess uniform vectors would be mainly useful for interfacing to
> external code that deals with large arrays.  Like the GNU Scientific
> Library, say, or maybe things like data compression, image
> manipulation, binary file formats in general, etc.
>
> Instead of using uniform vectors, one can always define a new smob
> type that can wrap the large external array.  But maybe uniform
> vectors would be preferable in some cases, if only you could convince
> Guile to handle the external memory right (like you can with smobs).
>
> I have close to zero experience with using uniform vectors myself, so
> I appreciate your input.  Do you use uniform vectors?  What for?  Did
> you try but couldn't make them work for you?  What do you wish would
> be different about them?  Etc.

I use arrays as the basic representation of matrices in my matrix
library (guile-matrix).  uniform-vector-read/write! is an important
tool for dealing with binary file formats.

While smobs are useful in one of the scenarios which Guile targets
(application extension language), smobs are not useful as a basis for
data structures when developing code in Scheme (like in the scripting
language scenario).

Vectors are useful as a building block for data structures on the
Scheme side.  Generic vectors are not always a good alternative, for
example when working with large bodies of numerical or binary data.

Also, uniform vectors can sometimes be an important "generic" data
structure suitable for representation of arguments and results to
application extensions.  If we have a Guile library M which can do
some computation on every element of a collection of numbers, and
another library S which can compute statistics on collections of
numbers, we don't reach quite the same level of "cross-fertilization"
of these libraries if M collections are represented as M-smobs and S
collections as S-smobs.  What I'm saying is that the need to
efficiently represent a list of numbers is sufficiently common to
warrant a generic number list data structure such as the uniform
vector.

M


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
  2004-10-23 14:02 ` Neil Jerram
  2004-10-24 16:04 ` Mikael Djurfeldt
@ 2004-10-25 18:08 ` Stephen Compall
  2004-10-25 18:34   ` Peter Christopher
  2004-10-25 22:00 ` Mike Gran
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Stephen Compall @ 2004-10-25 18:08 UTC (permalink / raw)
  Cc: guile-user

Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:

> I have close to zero experience with using uniform vectors myself,
> so I appreciate your input.  Do you use uniform vectors?  What for?
> Did you try but couldn't make them work for you?  What do you wish
> would be different about them?  Etc.

I have used bit-vectors in my class.

--
Stephen Compall or s11 or sirian

Within a computer, natural language is unnatural.

Perl-RSA subversive Merlin SCUD missile MP5K-SD militia ANC national
information infrastructure Firefly passwd MILSATCOM lynch HAMASMOIS
covert video Ermes


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-25 18:08 ` Stephen Compall
@ 2004-10-25 18:34   ` Peter Christopher
  2004-10-25 19:51     ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Christopher @ 2004-10-25 18:34 UTC (permalink / raw)
  Cc: guile-user, Marius Vollmer

Hi there,

	Just thought I'd weigh in. I used the uniform vectors to 
construct what amounts to a guile version of NumericPython. I.e. I used 
uniform vectors of double precision numbers. I found the interface to be 
fairly usable. I do have one HUGE pet peeve though. I grant you that this 
is just a peeve and not a major difficulty but ... I HATE the way you 
select what type of elements will be stored in the vector. For instance 
as it says at  
http://www.gnu.org/software/guile/docs/guile-ref/Uniform-Arrays.html#Uniform%20Arrays
you create a vector with (make-uniform-array <prototype> 3) where 
<prototype> is one of 
#t             boolean (bit-vector)                    b
#\a            char (string)                           a
#\nul          byte (integer)                          y
's             short (integer)                         h
1              unsigned long (integer)                 u
-1             signed long (integer)                   e
'l             signed long long (integer)              l
1.0            float (single precision)                s
1/3            double (double precision float)         i
0+i            complex (double precision)              c
()             conventional vector
I don't like the left most column. I think that it's ugly because it's 
not necessarily obvious to the reader of the code what type you are 
storing in the vector. IMHO it would be better to use symbols as the 
prototype arguments, for example
'bool             boolean (bit-vector)                    b
'char             char (string)                           a
'byte             byte (integer)                          y
'short            short (integer)                         h
'ulong            unsigned long (integer)                 u
'long             signed long (integer)                   e
'longlong         signed long long (integer)              l
'float            float (single precision)                s
'double           double (double precision float)         i
'complex          complex (double precision)              c
This way it is obvious what kind of uniform vector you're constructing. 
Ok ... yea I know this isn't a killer problem, but it has always annoyed 
me.

Also, I want to stress that *I* think that uniform vectors are a very 
important guile feature. They may not be used a lot, BUT they allow 
developers to (conveniently) make some applications that would 
otherwise be very performance hindering.

And there are my 2 cents. 

Best, 
Pete


On 25 Oct 2004, Stephen Compall wrote:

> Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:
> 
> > I have close to zero experience with using uniform vectors myself,
> > so I appreciate your input.  Do you use uniform vectors?  What for?
> > Did you try but couldn't make them work for you?  What do you wish
> > would be different about them?  Etc.
> 
> I have used bit-vectors in my class.
> 
> --
> Stephen Compall or s11 or sirian
> 
> Within a computer, natural language is unnatural.
> 
> Perl-RSA subversive Merlin SCUD missile MP5K-SD militia ANC national
> information infrastructure Firefly passwd MILSATCOM lynch HAMASMOIS
> covert video Ermes
> 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
> 



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-25 18:34   ` Peter Christopher
@ 2004-10-25 19:51     ` Ludovic Courtès
  0 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2004-10-25 19:51 UTC (permalink / raw)
  Cc: guile-user, Marius Vollmer

Hi,

Today, one hour, 14 minutes, 32 seconds ago, Peter Christopher wrote:
> I don't like the left most column. I think that it's ugly because it's 
> not necessarily obvious to the reader of the code what type you are 
> storing in the vector. IMHO it would be better to use symbols as the 
> prototype arguments, for example

Did you look at SRFI-4 (http://srfi.schemers.org/srfi-4/srfi-4.html)
which is available in Guile as (srfi srfi-4)?  It seems closer to what
you suggested, syntactically.

Ludovic.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
                   ` (2 preceding siblings ...)
  2004-10-25 18:08 ` Stephen Compall
@ 2004-10-25 22:00 ` Mike Gran
  2004-10-26  2:50 ` Steve Tell
  2004-11-04 17:48 ` Marius Vollmer
  5 siblings, 0 replies; 11+ messages in thread
From: Mike Gran @ 2004-10-25 22:00 UTC (permalink / raw)


To be honest, I rarely used them.  Standard vectors and lists are good
enough for me.  I don't seem to have any memory or speed problems in
what I'm doing.

I've always thought the way the "old" vectors used prototypes, such as
'a' or 1/3, in scm_dimensions_to_uniform_array and related functions
was a bit ad hoc.  I'd have preferred something more orderly. 

It is true the SMOBs could be wrangled to do the work, but, SMOBs still
remain an unintuitive subject for anyone just coming to Guile.  The
barrier for entry is too high in 1.6: the documentation talks a lot
about memory, allocation, garbage collection, etc, which ideally is
what one is trying to avoid learning by using Scheme.

Vociferous in my ignorance,

-- 
Mike



	
		
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
                   ` (3 preceding siblings ...)
  2004-10-25 22:00 ` Mike Gran
@ 2004-10-26  2:50 ` Steve Tell
  2004-11-04 17:48 ` Marius Vollmer
  5 siblings, 0 replies; 11+ messages in thread
From: Steve Tell @ 2004-10-26  2:50 UTC (permalink / raw)
  Cc: Guile Mailing List

On Fri, 22 Oct 2004, Marius Vollmer wrote:

> Hi,
> 
> I want to unify our two implementations of uniform vectors, and make
> them more useful.

In general, sounds like a good idea.
 
> I have close to zero experience with using uniform vectors myself, so
> I appreciate your input.  Do you use uniform vectors?  What for?  Did
> you try but couldn't make them work for you?  What do you wish would
> be different about them?  Etc.

In a quick survey of my code, I've always used uniform vectors to
store scheme objects (booleans or lists) an never for the 10 numeric types 
allowed by srfi-4 vectors.
I remember chosing uniform vectors over the related vector and array 
types when I knew that the length wouldn't change and the types were all,
well, uniform.  The vector and uniform-vector procedures seemed a bit
simpler than the array ones, but (non-uniform) vectors or arrays would 
probably have worked.

I've never used uniform vectors as part of an interface to C code. I don't
think the documentation covered the srfi4 back when I first wrote many of
the things I surveyed.

Steve



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
@ 2004-10-26  3:03 Roland Orre
  0 siblings, 0 replies; 11+ messages in thread
From: Roland Orre @ 2004-10-26  3:03 UTC (permalink / raw)


I'm mainly using guile for data analysis (basically everything
what I'm doing) and I'm always used uniform vectors a lot.

I'm using uniform vectors as basic data structures and as interfaces.
The types I'm using are mainly:
#s()        Float
#i()        Double
#h()        Short
#u()        Integer
#t          bits

As my habit is to implement things in scheme first and then go to
C-code I can gain incredible effects on performance compared to
e.g. using standard vectors, which I'm basically use for high
level data structures, to keep other vectors and things in.
With uniform vector gc goes to zero and the C-code becomes
very efficient.

I like the uniform vectors and consider them to be an essential
feature of guile. I've used them since guile started to be guile
ten years or so ago. I also use the shared vectors (as well as
shared substrings, nowadays priv impl.) for efficieny reasons.

I have to agree somewhat with Peter Christopher though, that
I'm not entirely enthusiastic about the prototypes, even though
they are quite intuitive (it's basically the difference between
float vectors and double vectors I'm not very fond of, as well
as the reading/printing syntax of uniform vectors maybe should
be more consistent. It may preferrably be something like:

type	print/read	proto
gen	#()		'()	or 'v
float	#f()		'f
double	#d()		'd
complex #c()		'c
signint	#i()		'i
uns.int #u()		'u
short   #s()		's
llong   #l()            'l
bit     #*1010		'*
string	#a()		'a

and so on, something like this would be more intuitive I think,
but this is just a wild suggestion.

	Best regards
	Roland Orre




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
                   ` (4 preceding siblings ...)
  2004-10-26  2:50 ` Steve Tell
@ 2004-11-04 17:48 ` Marius Vollmer
  2004-11-05 17:01   ` Marius Vollmer
  5 siblings, 1 reply; 11+ messages in thread
From: Marius Vollmer @ 2004-11-04 17:48 UTC (permalink / raw)


Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:

> I have close to zero experience with using uniform vectors myself, so
> I appreciate your input.

Thanks everybody for answering!

Here is where I am heading at the moment:

- The old uniform vector implementation are gone and the SRFI-4
  homogenous vectors have taken over.  This means that a bunch of
  precious tc7 types are freed.

  This brings some non-compatible changes to the C side, which I think
  are reasonable.  You can no longer use SCM_UVECTOR_BASE etc and of
  course the tc7 tag messing is no longer needed.

- The C API of the SRFI-4 homogenous vectors has the two functions
  scm_TAGvector_elements and scm_uniform_vector_release that allow
  access to the raw memory of the vector.  There is scm_take_TAGvector
  to have Guile take over a memory block.

- Read and print syntax for arrays has been extended to also accept
  the new "u8" etc tags and Guile can now print and read arrays with
  non-zero lower bounds:

    (make-array 0 '(1 2) '(2 3))
    => #2@1@2((0 0) (0 0))

  The "@1@2" means that the lower bounds are 1 and 2, respectively.

- The prototypes will be deprecated.  Instead, make-uniform-array will
  take a creator procedure; i.e, to get a u8 array you would do

    (make-uniform-array make-u8vector 2 2)
    => #2u8((220 88) (48 64))

  The array will not be initialized.  You can use uniform-array-fill!
  for that.

  In place of array-prototype, which is deprecated, there is the new
  array-creator.

- In addition to the types specified in SRFI-4, Guile also has c32 and
  c64, which are floating point complex numbers of single and double
  precision.

- vector? will be true for all zero-origin, one-dimensional arrays,
  including uniform arrays except strings, bit vectors and suitable
  shared arrays.  Strings can be used with make-uniform-array but are
  not accepted by vector? because R5RS says so.  Also, vector-ref etc
  will be suitably extended.

  (Not implemented yet.  This breaks with the tradition of RnRS to
  have disjoint types.  Maybe uniform vectors and general vectors
  should remain disjoint?  Opinions?)

- There will be some form of nice C API for uniform arrays.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Uniform vectors, user survey
  2004-11-04 17:48 ` Marius Vollmer
@ 2004-11-05 17:01   ` Marius Vollmer
  0 siblings, 0 replies; 11+ messages in thread
From: Marius Vollmer @ 2004-11-05 17:01 UTC (permalink / raw)


Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:

> - vector? will be true for all zero-origin, one-dimensional arrays,

I will not do this right away, since I can't really convince myself
that this is the Right Thing.

There will first be vectors, strings, bit vectors, and uniform numeric
vectors; and all will be disjoint.  Together, they might be called
'generalized vector types'.

Then there will be arrays, which will include all the generalized
vector types, and more (such as non-zero origin 'vectors', and
multi-dimensional arrays.)  Arrays can use any one of the generalized
vector types for their storage, and the array procedures will work
with strict arrays and with any of the generalized vector types.

[ Incidentally, vector-length, vector-ref, and vector-set are
  primitive generics right now, and one can thus add methods to them
  for new types.  But vector? remains unaffected by that, and of
  course the existing C API will not work with these extended vector
  types...
]

Later we might want to arrange the genralized vector types
differently.

OK?


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-11-05 17:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-22 14:19 Uniform vectors, user survey Marius Vollmer
2004-10-23 14:02 ` Neil Jerram
2004-10-24 16:04 ` Mikael Djurfeldt
2004-10-25 18:08 ` Stephen Compall
2004-10-25 18:34   ` Peter Christopher
2004-10-25 19:51     ` Ludovic Courtès
2004-10-25 22:00 ` Mike Gran
2004-10-26  2:50 ` Steve Tell
2004-11-04 17:48 ` Marius Vollmer
2004-11-05 17:01   ` Marius Vollmer
  -- strict thread matches above, loose matches on Subject: below --
2004-10-26  3:03 Roland Orre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).