From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.lisp.guile.user Subject: Re: matrix library? Date: Wed, 4 Oct 2023 20:28:58 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="m8hde5KtQ37jOjZt" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37865"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Nala Ginrut , guile-user To: Damien Mattei Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Oct 04 20:29:51 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qo6d4-0009VJ-DX for guile-user@m.gmane-mx.org; Wed, 04 Oct 2023 20:29:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qo6cS-0004x0-Mq; Wed, 04 Oct 2023 14:29:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qo6cK-0004uv-Ab for guile-user@gnu.org; Wed, 04 Oct 2023 14:29:04 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qo6cH-0006IA-Gh for guile-user@gnu.org; Wed, 04 Oct 2023 14:29:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nT65fcGZ9JPW1kOWgRFL0Jhj1fxBKDuQ9+wyLODtygg=; b=Bo+XDldodMG39ggguUG+S1eso2 pyK9oypPu00qYCQr7yaI3w4UaVjlRa9gbPsufHrpqL/mTBM7RhHQLbBugCWxlf1GDmmi15/D5ETud bT6Cez9i/EtLdbVxAr8MNCXVltrn7TPwAIowem3Yv42nA/bysJyjIKvezR2/UyqWCW0mxEvqvV8ux K6r7GwF880yRz7Ilk2czreMcfqUW1QdfstBlGsBsgK0E39u0SZYKHK5Qim1tNqcUzEDlPg6h6xKXK DFaPqlZqlN0udmXFpIP1XgDNPO+ROwsABm2la/t2KToWhyUzr8PstW1Cx+KHZ1u2fHnJCS7gFK8Fw rwGqLNdQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qo6cE-0001R0-VX; Wed, 04 Oct 2023 20:28:59 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19229 Archived-At: --m8hde5KtQ37jOjZt Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 04, 2023 at 05:42:10PM +0200, Damien Mattei wrote: > thank you. i will try to find a simple example in. >=20 > On Wed, Oct 4, 2023 at 1:36=E2=80=AFPM Nala Ginrut = wrote: > > > > And I'd mention AIScm which bound tensorflow APIs. It needs more love. > > > > https://wedesoft.github.io/aiscm/ > > > > > > On Wed, Oct 4, 2023, 17:12 wrote: > >> > >> On Wed, Oct 04, 2023 at 08:46:02AM +0200, Damien Mattei wrote: > >> > hello, > >> > does anyone know if it exists a basic matrix library for Guile? > >> > just need to multiply a matrix and a vector. > >> > >> Perhaps this thread from guile-user [1] has something for you > >> > >> Cheers > >> > >> [1] https://lists.gnu.org/archive/html/guile-user/2018-12/threads.html= #00117 That all said, if your case doesn't get much hairier, it is fairly easy to navigate with Guile's arrays: (define (dot v1 v2) "The dot product of v1 and v2" (let ((sum 0)) (array-for-each (lambda (x1 x2) (set! sum (+ sum (* x1 x2)))) v1 v2) sum)) (define (row m i) "The i-th row of m, as a vector" (make-shared-array m (lambda (j) (list i j)) (car (array-dimensions m)))) (define (mat* m v) "Left multiply matrix m and vector v" (let* ((height (cadr (array-dimensions m))) (res (make-typed-array 'f64 0 height))) (do ((i 0 (1+ i))) ((>=3D i height)) (array-set! res (dot (row m i) v) i)) res)) (define vec #1f64(1 2 1)) (define mat #2f64((0.5 0.5 0) (0 0.5 0.5) (-0.5 0 0.5))) (mat* mat vec) =3D> (1.5 1.5 0) CAVEAT: only tested with this one example. Input value checking left as an... Cheers --=20 t --m8hde5KtQ37jOjZt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZR2u4gAKCRAFyCz1etHa RniGAJ9pCiEZEkEIZf+MaiqsUE+EVcaRMQCdH5M0t9hUBYvEKEPrbxFd6/Bn2+E= =Uka1 -----END PGP SIGNATURE----- --m8hde5KtQ37jOjZt--