File: amatrix.dem

package info (click to toggle)
maxima 5.44.0-2
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 108,368 kB
  • sloc: lisp: 383,860; fortran: 14,665; perl: 14,369; tcl: 11,147; sh: 4,517; makefile: 2,580; ansic: 447; python: 262; xml: 59; awk: 37; sed: 17
file content (136 lines) | stat: -rw-r--r-- 1,882 bytes parent folder | download | duplicates (10)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
if ?get ('amatrix, 'present) = false then load (amatrix) else 'already_loaded;

"... Hilbert matrix ..."$

foo : make_matrix (7, 5)$
for i thru foo@nr do for j thru foo@nc do foo [i, j] : 1/(i + j - 1);
foo;

"... Integer subscripts ..."$

foo [1, 1];

foo [1, 1] : 42;

foo;

"... 'all subscripts ..."$

foo [all, 1];
foo [1, all];

foo [all, all];

bar : foo [all, 1];

mumble : foo [1, all];

"... Collective assignment ..."$

foo [all, 2] : %pi;

foo;

foo [all, 5] : foo [all, 1];

foo;

"... Implicit subscript=1 when #rows=1 or #columns=1 ..."$

bar;

bar [1];

bar [all];

"... Copy-on-write policy ..."$

bar [1];

bar [1] : 1729;

bar;

mumble;

"... List of integers subscripts ..."$

foo [[1, 5, 3], 1];

foo [all, [5, 4, 3]];

foo [[5, 6, 7], [2, 5]];

"... amatrix of Boolean values subscripts ..."$

baz : amatrixmap (lambda ([x], is (x > 3/10)), bar);

quux : amatrixmap (lambda ([x], is (x < 1/4)), bar);

blurf : amatrixmap (lambda ([x], is (x < 1/2)), mumble);

snort : amatrixmap (lambda ([x], is (x >= 1/3)), mumble);

foo [baz, 4];

foo [6, blurf];

foo [baz, all];

foo [all, blurf];

foo [baz, [1, 5]];

foo [[2, 3, 6], blurf];

foo [baz, blurf];

"... Relational expressions subscripts ..."$

bar;

bar [bar > 2/3];

foo [bar >= 1/4, 4];

foo [6, 3/4 >= mumble];

foo [bar > 1/2, all];

foo [all, mumble < 1/2];

foo [bar # 1/2, [5, 2]];

foo [[4, 3, 2], mumble < 3/7];

foo [bar <= 7/8, blurf];

foo [baz, mumble > 1/8];

foo [bar > 2/7, 8/9 >= mumble];

"... Boolean expressions subscripts ..."$

foo [not baz, 3];

foo [7, blurf and snort];

foo [baz and not quux, all];

foo [all, not blurf or snort];

foo [baz or quux, [1, 2, 4]];

foo [[3, 2, 5], not blurf and snort];

foo [quux and baz, snort];

foo [quux, not blurf];

foo [not quux and not baz, mumble < 0.95];

foo [bar > 0.15, not blurf or not snort];

foo [quux or baz, blurf or not snort];