Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,55 +0,0 @@
with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Kronecker_Product is
type Matrix is array (Positive range <>, Positive range <>) of Integer;
function "*"(Left, Right : in Matrix) return Matrix is
result : Matrix
(1 .. Left'Length(1) * Right'Length(1),
1 .. Left'Length(2) * Right'Length(2));
LI : Natural := 0;
LJ : Natural := 0;
begin
for I in 0 .. result'Length(1) - 1 loop
for J in 0 .. result'Length(2) - 1 loop
result (I + 1, J + 1) :=
Left(Left'First(1) + (LI), Left'First(2) + (LJ))
* Right
(Right'First(1) + (I mod Right'Length(1)),
Right'First(2) + (J mod Right'Length(2)));
if (J+1) mod Right'Length(2) = 0 then
LJ := LJ + 1;
end if;
end loop;
if (I+1) mod Right'Length(1) = 0 then
LI := LI + 1;
end if;
LJ := 0;
end loop;
return result;
end "*";
Left1 : constant Matrix := ((1, 2), (3, 4));
Right1 : constant Matrix := ((0, 5), (6, 7));
result1 : constant Matrix := Left1 * Right1;
Left2 : constant Matrix := ((0, 1, 0), (1, 1, 1), (0, 1, 0));
Right2 : constant Matrix := ((1, 1, 1, 1), (1, 0, 0, 1), (1, 1, 1, 1));
result2 : constant Matrix := Left2 * Right2;
begin
for I in result1'Range(1) loop
for J in result1'Range(2) loop
Ada.Integer_Text_IO.Put(Ada.Text_IO.Standard_Output, result1(I, J));
end loop;
Ada.Text_IO.New_Line;
end loop;
Ada.Text_IO.New_Line;
for I in result2'Range(1) loop
for J in result2'Range(2) loop
Ada.Integer_Text_IO.Put(Ada.Text_IO.Standard_Output, result2(I, J));
end loop;
Ada.Text_IO.New_Line;
end loop;
end Kronecker_Product;

View file

@ -1,5 +1,9 @@
define :matrix [X][
print: [
define :matrix [
init: method [X][
this\X: X
]
string: method [][
result: ""
loop this\X 'arr [
result: result ++ "[" ++
@ -13,7 +17,7 @@ define :matrix [X][
kroneckerProduct: function [a,b][
M: size a\X, N: size first a\X
P: size b\X, Q: size first b\X
result: to :matrix @[new array.of:M*P array.of:N*Q 0]
result: to :matrix @[array.of:M*P array.of:N*Q 0]
loop 0..dec M 'i [
loop 0..dec N 'j [

View file

@ -1,85 +0,0 @@
' Kronecker product - 05/04/2017 ' array boundary iteration corrections 06/13/2023
dim a(),b(),r()
sub kroneckerproduct '(a,b)
m=ubound(a,1): n=ubound(a,2)
p=ubound(b,1): q=ubound(b,2)
rtn=m*p
ctn=n*q
redim r(rtn,ctn)
for i=1 to m
for j=1 to n
for k=1 to p
for l=1 to q
r(p*(i-1)+k,q*(j-1)+l)=a(i,j)*b(k,l)
next: next: next: next
end sub 'kroneckerproduct
Private Sub printmatrix(text, m, w)
wscript.stdout.writeline text
Dim myArr()
Select Case m
Case "a": myArr = a()
Case "b": myArr = b()
Case "r": myArr = r()
End Select
For i = LBound(myArr, 1) To UBound(myArr, 1)
text = vbNullString
For j = LBound(myArr, 2) To UBound(myArr, 2)
Select Case m
Case "a": k = a(i, j)
Case "b": k = b(i, j)
Case "r": k = r(i, j)
End Select
text = text & " " & k
Next
wscript.stdout.writeline text
Next
End Sub 'printmatrix
sub printall(w)
printmatrix "matrix a:", "a", w
printmatrix "matrix b:", "b", w
printmatrix "kronecker product:", "r", w
end sub 'printall
sub main()
xa = Array(1, 2, _
3, 4)
ReDim a(LBound(xa, 1) To LBound(xa, 1) + 1, LBound(xa, 1) To LBound(xa, 1) + 1)
k = LBound(a, 1)
For i = LBound(a, 1) To UBound(a, 1): For j = LBound(a, 1) To UBound(a, 1)
a(i, j) = xa(k): k = k + 1
Next: Next
xb = Array(0, 5, _
6, 7)
ReDim b(LBound(xb, 1) To LBound(xb, 1) + 1, LBound(xb, 1) To LBound(xb, 1) + 1)
k = LBound(b, 1)
For i = LBound(b, 1) To UBound(b, 1): For j = LBound(b, 2) To UBound(b, 2)
b(i, j) = xb(k): k = k + 1
Next: Next
kroneckerproduct
printall 3
xa = Array(0, 1, 0, _
1, 1, 1, _
0, 1, 0)
ReDim a(LBound(xa, 1) To LBound(xa, 1) + 2, LBound(xa, 1) To LBound(xa, 1) + 2)
k = LBound(a, 1)
For i = LBound(a, 1) To UBound(a, 1): For j = LBound(a, 1) To UBound(a, 1)
a(i, j) = xa(k): k = k + 1
Next: Next
xb = Array(1, 1, 1, 1, _
1, 0, 0, 1, _
1, 1, 1, 1)
ReDim b(LBound(xb, 1) To LBound(xb, 1) + 2, LBound(xb, 1) To LBound(xb, 1) + 3)
k = LBound(b, 1)
For i = LBound(b, 1) To UBound(b, 1): For j = LBound(b, 2) To UBound(b, 2)
b(i, j) = xb(k): k = k + 1
Next: Next
kroneckerproduct
printall 2
end sub 'main
main