Hi,
I see the r6r5 info on use of 'library' now.
https://www.gnu.org/software/guile/manual/html_node/R6RS-Libraries.html
For those tspl4/examples the display output is a bit odd and generally single
line.
My primitive try at matrix formatting is too brute force, but the output is
more of what I was looking for. If nothing exists already in snd I may have
missed, maybe I can come up with some combination of the tspl4/examples and
improvements on my nested do loops approach for matrix display.
(with-let (sublet *libgsl*)
(let* ( (n 4) ;num rows
(p 4) ;num cols
(m (gsl_matrix_alloc n p))
(myrow (gsl_vector_alloc n)) ;alloc gsl vectors
(mycol (gsl_vector_alloc p))
(my_i (gsl_vector_alloc n))
(my_j (gsl_vector_alloc 16)) ;4x4
(r 0.0) ;row indicator
(c 0.0) ;col indicator
)
(format #t "\n\nGSL MATRIX: \n" )
;nested do to load matrix
(do ((i 0 (+ i 1)))
((= i n))
(do ((j 0 (+ j 1)))
((= j 4))
(gsl_matrix_set m i j 1.12) ;sets i j values all to 1.12
))
;2nd nested do to put matrix i j values into separate gsl_vectors
(do ((i 0 (+ i 1)))
((= i n))
(do ((j 0 (+ j 1)))
((= j 4))
(gsl_vector_set my_i i (gsl_matrix_get m i j))
(gsl_vector_set my_j j (gsl_matrix_get m i j))
))
;3rd nested do to print gsl_vector values
(do ((i 0 (+ i 1)))
((= i n))
(let ((r (gsl_vector_get my_i i)) ;print i for row num or r for row
value
)
(format #t "r: ~A " i)
)
(do ((j 0 (+ j 1))) ;j is col
((= j 4))
(let ((c (gsl_vector_get my_j j))
)
(format #t " c~A: ~A"j c)
)
)
(format #t "\n")
)
(gsl_matrix_free m)
(gsl_vector_free myrow)
(gsl_vector_free mycol)
(gsl_vector_free my_i)
(gsl_vector_free my_j)
))
________________________________
From: [email protected] <[email protected]> on
behalf of [email protected] <[email protected]>
Sent: Wednesday, April 30, 2025 9:00 AM
To: [email protected] <[email protected]>
Subject: Cmdist Digest, Vol 203, Issue 3
Send Cmdist mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Cmdist digest..."
Today's Topics:
1. matrix display (James Hearon)
----------------------------------------------------------------------
Message: 1
Date: Wed, 30 Apr 2025 17:53:37 +0000
From: James Hearon <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [CM] matrix display
Message-ID:
<sa1pr14mb5981064825e0fdaa36f469d7e5...@sa1pr14mb5981.namprd14.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
I'm working thru libgsl.scm defs and trying to come up with good way to display
a
gsl_matrix. I found some code in s7test.scm (dofit...etc.), but couldn't
follow it exactly. Then I tried my own version using gsl_vectors and nested do
loops, but still not happy with it.
Then came across another approach
https://www.scheme.com/tspl4/examples.html<https://www.scheme.com/tspl4/examples.html>
under Section 12.1. Matrix and Vector Multiplication, which uses a keyword
'library' along with export and import to utilize a group of different defines
related to matrix activities.
(library (tspl matrix)
(export make-matrix matrix? matrix-rows matrix-columns
matrix-ref matrix-set! mul)
(import (rnrs)) ...
Seems the 'library' keyword is unbound in snd. Just curious if there was some
alternative in snd I missed to be able to cobble together a group of
definitions into some sort of useable structure? (His individual matrix
definitions work fine in snd if you forgo the 'library' part and substitute
parentheses for brackets in the definitions). Or maybe there's a better way to
format or display rows and cols in snd I also missed.
Regards,
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20250430/2ba43b26/attachment-0001.html>
------------------------------
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist
End of Cmdist Digest, Vol 203, Issue 3
**************************************
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist