[CM] cons value for float vector

2023-09-08 Thread James Hearon
Hi,
Thank you for that info.  I didn't realize you can have multidimensional 
float-vectors, nor knew how to go about that.  This helps.
Jim

From: cmdist-boun...@ccrma.stanford.edu  on 
behalf of cmdist-requ...@ccrma.stanford.edu 
Sent: Thursday, September 7, 2023 9:00 AM
To: cmdist@ccrma.Stanford.EDU 
Subject: Cmdist Digest, Vol 184, Issue 1

Send Cmdist mailing list submissions to
cmdist@ccrma.stanford.edu

To subscribe or unsubscribe via the World Wide Web, visit
https://cm-mail.stanford.edu/mailman/listinfo/cmdist
or, via email, send a message with subject or body 'help' to
cmdist-requ...@ccrma.stanford.edu

You can reach the person managing the list at
cmdist-ow...@ccrma.stanford.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Cmdist digest..."


Today's Topics:

   1. cons value for float vector (James Hearon)


--

Message: 1
Date: Thu, 7 Sep 2023 17:47:11 +
From: James Hearon 
To: "cmdist@ccrma.Stanford.EDU" 
Subject: [CM] cons value for float vector
Message-ID:



Content-Type: text/plain; charset="iso-8859-1"


Hi,
I'm having a difficult time trying to create two columns of data (or three or 
four etc.) in a float vector.
A list works fine, but the vector gives an error that the data is a pair but 
should
be a real.  I could use make-env for this probably, but seems like I should
be able to get the vector to cooperate.  I'm wondering what I'm 
misunderstanding or if there's
a better way to think of this such as individual vectors then zip them together?
Thanks,
Jim

;float vector XXX
(let* ((fsize 10)
   (im (make-float-vector fsize))
   (x 1)
   (y 1.0)
   )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (im k) (cons x y)) ;XXX is a pair but should be a real?
;(float-vector-set! im k (cons x y))
(format #t "~% ~A ~A" k (im k) )
(set! x (1+ x))
(set! y (1+ y))
))

;list OK
(let* ((fsize 10)
   (mylist (make-list fsize))
   (x 1)
   (y 1.0)
   )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (list-ref mylist k) (cons x y))
(format #t "~% ~A ~A" k (list-ref mylist k))
(set! x (1+ x))
(set! y (1+ y))
))
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20230907/2168650d/attachment-0001.html>

--

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


End of Cmdist Digest, Vol 184, Issue 1
**
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] cons value for float vector

2023-09-07 Thread bil

I think you want to use a multidimensional float-vector:

(let* ((fsize 10)
   (im (make-float-vector (list fsize 2)))
   (x 1)
   (y 1.0)
   )
  (do ((k 0 (+ k 1)))
  ((>= k fsize))
(set! (im k 0) x) ; this will be turned into a float
(set! (im k 1) y)
(format #t "~% ~A ~A ~A" k (im k 0) (im k 1))
(set! x (1+ x))
(set! y (1+ y))
))

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


[CM] cons value for float vector

2023-09-07 Thread James Hearon

Hi,
I'm having a difficult time trying to create two columns of data (or three or 
four etc.) in a float vector.
A list works fine, but the vector gives an error that the data is a pair but 
should
be a real.  I could use make-env for this probably, but seems like I should
be able to get the vector to cooperate.  I'm wondering what I'm 
misunderstanding or if there's
a better way to think of this such as individual vectors then zip them together?
Thanks,
Jim

;float vector XXX
(let* ((fsize 10)
   (im (make-float-vector fsize))
   (x 1)
   (y 1.0)
   )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (im k) (cons x y)) ;XXX is a pair but should be a real?
;(float-vector-set! im k (cons x y))
(format #t "~% ~A ~A" k (im k) )
(set! x (1+ x))
(set! y (1+ y))
))

;list OK
(let* ((fsize 10)
   (mylist (make-list fsize))
   (x 1)
   (y 1.0)
   )
(do ((k 0 (+ k 1)))
((>= k fsize))
(set! (list-ref mylist k) (cons x y))
(format #t "~% ~A ~A" k (list-ref mylist k))
(set! x (1+ x))
(set! y (1+ y))
))
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist