-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRUNME.sh
executable file
·61 lines (33 loc) · 1.19 KB
/
RUNME.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! csi
;;;; RUNME.scm
;;@project: matrico (numerical-schemer.xyz)
;;@version: 0.7 (2024-07-18)
;;@authors: Christian Himpe (0000-0003-2194-6754)
;;@license: zlib-acknowledgement (spdx.org/licenses/zlib-acknowledgement.html)
;;@summary: demo codes
(import matrico)
;; `matrico` about
(matrico 'about)
;; `matrico` version
(matrico 'version)
;; `matrico` cite
(matrico 'citation)
;; Using the REPL help
(matrico 'mx)
;; Assigning matrices and vectors
(matrico 'mx-tridiag)
(define A (mx-tridiag 3 1.0 -2.0 0.5)) ; Assign a 3x3 tridiagonal matrix to A
(mx-print A) ; Print matrix A
(define b (mx 3 1 1.0)) ; Assign a 3x1 column vector of ones to b
(mx-print b) ; Print vector b
;; Entry-wise matrix arithmetic
(mx-print (mx+ b b)) ; Print entry-wise sum of b and b
(mx-print (mx+ A b)) ; Print entry-wise (broadcasted) sum of A b
(mx-print (mx* b A)) ; Print entry-wise (broadcasted) product of B A
;; Multiplying matrices
(matrico 'mx-dot)
(mx-print (mx-dot A b)) ; Print matrix-vector probuct of A and b
(mx-print (mx-dot A A)) ; Print matrix-matrix product of A and A
;; Solving a linear problem
(matrico 'mx-solve)
(mx-print (mx-solve A b)) ; Print the solution to the linear problem A x = b