Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
get "libhdr"
|
||||
manifest $( size = 5 $)
|
||||
|
||||
// Matrix index
|
||||
let ix(mat, n, x, y) = mat+y*n+x
|
||||
|
||||
let lower(m, n) be
|
||||
for y=0 to n-1
|
||||
for x=0 to n-1 do
|
||||
!ix(m,n,x,y) :=
|
||||
x>y -> 0,
|
||||
x=y | x=0 -> 1,
|
||||
!ix(m,n,x-1,y-1) + !ix(m,n,x,y-1)
|
||||
|
||||
|
||||
let upper(m, n) be
|
||||
for y=0 to n-1
|
||||
for x=0 to n-1 do
|
||||
!ix(m,n,x,y) :=
|
||||
x<y -> 0,
|
||||
x=y | y=0 -> 1,
|
||||
!ix(m,n,x-1,y-1) + !ix(m,n,x-1,y)
|
||||
|
||||
let symmetric(m, n) be
|
||||
for y=0 to n-1
|
||||
for x=0 to n-1 do
|
||||
!ix(m,n,x,y) :=
|
||||
x=0 | y=0 -> 1,
|
||||
!ix(m,n,x-1,y) + !ix(m,n,x,y-1)
|
||||
|
||||
// Print matrix
|
||||
let writemat(m, n, d) be
|
||||
for y=0 to n-1
|
||||
$( for x=0 to n-1
|
||||
$( writed(!ix(m,n,x,y), d)
|
||||
wrch(' ')
|
||||
$)
|
||||
wrch('*N')
|
||||
$)
|
||||
|
||||
// Generate and print 5-by-5 matrices
|
||||
let start() be
|
||||
$( let mat = vec size * size
|
||||
|
||||
writes("Upper-triangular matrix:*N")
|
||||
upper(mat, size) ; writemat(mat, size, 2)
|
||||
|
||||
writes("*NLower-triangular matrix:*N")
|
||||
lower(mat, size) ; writemat(mat, size, 2)
|
||||
|
||||
writes("*NSymmetric matrix:*N")
|
||||
symmetric(mat, size) ; writemat(mat, size, 2)
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue