Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Identity-matrix/ALGOL-68/identity-matrix-1.alg
Normal file
33
Task/Identity-matrix/ALGOL-68/identity-matrix-1.alg
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/a68g --script #
|
||||
# -*- coding: utf-8 -*- #
|
||||
|
||||
# Define some generic vector initialisation and printing operations #
|
||||
|
||||
COMMENT REQUIRES:
|
||||
MODE SCAL = ~ # a scalar, eg REAL #;
|
||||
FORMAT scal fmt := ~;
|
||||
END COMMENT
|
||||
|
||||
INT vec lwb := 1, vec upb := 0;
|
||||
MODE VECNEW = [vec lwb:vec upb]SCAL; MODE VEC = REF VECNEW;
|
||||
FORMAT vec fmt := $"("n(vec upb-vec lwb)(f(scal fmt)", ")f(scal fmt)")"$;
|
||||
|
||||
PRIO INIT = 1;
|
||||
|
||||
OP INIT = (VEC self, SCAL scal)VEC: (
|
||||
FOR col FROM LWB self TO UPB self DO self[col]:= scal OD;
|
||||
self
|
||||
);
|
||||
|
||||
# ZEROINIT: defines the additive identity #
|
||||
OP ZEROINIT = (VEC self)VEC:
|
||||
self INIT SCAL(0);
|
||||
|
||||
OP REPR = (VEC self)STRING: (
|
||||
FILE f; STRING s; associate(f,s);
|
||||
vec lwb := LWB self; vec upb := UPB self;
|
||||
putf(f, (vec fmt, self)); close(f);
|
||||
s
|
||||
);
|
||||
|
||||
SKIP
|
||||
52
Task/Identity-matrix/ALGOL-68/identity-matrix-2.alg
Normal file
52
Task/Identity-matrix/ALGOL-68/identity-matrix-2.alg
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: utf-8 -*- #
|
||||
|
||||
# Define some generic matrix initialisation and printing operations #
|
||||
|
||||
COMMENT REQUIRES:
|
||||
MODE SCAL = ~ # a scalar, eg REAL #;
|
||||
MODE VEC = []SCAL;
|
||||
FORMAT scal fmt := ~;
|
||||
et al.
|
||||
END COMMENT
|
||||
|
||||
INT mat lwb := 1, mat upb := 0;
|
||||
MODE MATNEW = [mat lwb:mat upb, vec lwb: vec upb]SCAL; MODE MAT = REF MATNEW;
|
||||
FORMAT mat fmt = $"("n(vec upb-vec lwb)(f(vec fmt)","lx)f(vec fmt)")"l$;
|
||||
|
||||
PRIO DIAGINIT = 1;
|
||||
|
||||
OP INIT = (MAT self, SCAL scal)MAT: (
|
||||
FOR row FROM LWB self TO UPB self DO self[row,] INIT scal OD;
|
||||
self
|
||||
);
|
||||
|
||||
# ZEROINIT: defines the additive identity #
|
||||
OP ZEROINIT = (MAT self)MAT:
|
||||
self INIT SCAL(0);
|
||||
|
||||
OP REPR = (MATNEW self)STRING: (
|
||||
FILE f; STRING s; associate(f,s);
|
||||
vec lwb := 2 LWB self; vec upb := 2 UPB self;
|
||||
mat lwb := LWB self; mat upb := UPB self;
|
||||
putf(f, (mat fmt, self)); close(f);
|
||||
s
|
||||
);
|
||||
|
||||
OP DIAGINIT = (MAT self, VEC diag)MAT: (
|
||||
ZEROINIT self;
|
||||
FOR d FROM LWB diag TO UPB diag DO self[d,d]:= diag[d] OD;
|
||||
# or alternatively using TORRIX ...
|
||||
DIAG self := diag;
|
||||
#
|
||||
self
|
||||
);
|
||||
|
||||
# ONEINIT: defines the multiplicative identity #
|
||||
OP ONEINIT = (MAT self)MAT: (
|
||||
ZEROINIT self DIAGINIT (LOC[LWB self:UPB self]SCAL INIT SCAL(1))
|
||||
# or alternatively using TORRIX ...
|
||||
(DIAG out) VECINIT SCAL(1)
|
||||
#
|
||||
);
|
||||
|
||||
SKIP
|
||||
11
Task/Identity-matrix/ALGOL-68/identity-matrix-3.alg
Normal file
11
Task/Identity-matrix/ALGOL-68/identity-matrix-3.alg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8 -*- #
|
||||
|
||||
PRIO IDENT = 9; # The same as I for COMPLex #
|
||||
|
||||
OP IDENT = (INT lwb, upb)MATNEW:
|
||||
ONEINIT LOC [lwb:upb,lwb:upb]SCAL;
|
||||
|
||||
OP IDENT = (INT upb)MATNEW: # default lwb is 1 #
|
||||
1 IDENT upb;
|
||||
|
||||
SKIP
|
||||
8
Task/Identity-matrix/ALGOL-68/identity-matrix-4.alg
Normal file
8
Task/Identity-matrix/ALGOL-68/identity-matrix-4.alg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/a68g --script #
|
||||
# -*- coding: utf-8 -*- #
|
||||
|
||||
PR READ "prelude/vector_base.a68" PR;
|
||||
PR READ "prelude/matrix_base.a68" PR;
|
||||
PR READ "prelude/matrix_ident.a68" PR;
|
||||
|
||||
SKIP
|
||||
9
Task/Identity-matrix/ALGOL-68/identity-matrix-5.alg
Normal file
9
Task/Identity-matrix/ALGOL-68/identity-matrix-5.alg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/a68g --script #
|
||||
# -*- coding: utf-8 -*- #
|
||||
|
||||
MODE SCAL = REAL;
|
||||
FORMAT scal fmt := $g(-3,1)$;
|
||||
|
||||
PR READ "prelude/matrix.a68" PR;
|
||||
|
||||
print(REPR IDENT 4)
|
||||
Loading…
Add table
Add a link
Reference in a new issue