Skip to content

Commit

Permalink
ipwr py and for skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
statespacedev committed Sep 21, 2024
1 parent 722d22e commit 1ee850f
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ lang-sentences*
/venv310/
/cmake-build-debug-docker/
/build-docs/
.vscode
/a.out.dSYM/
a.out
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "for",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "ipwr",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb"
},
]
}
10 changes: 10 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "ipwr",
"command": "gfortran pdp10/algebra/ipwr.for -g -O0 -fbacktrace -fcheck=all -ffpe-trap=zero,overflow,underflow -Wall -Wextra -Warray-temporaries -Wconversion -ffree-line-length-0",
}
]
}
File renamed without changes.
11 changes: 11 additions & 0 deletions pdp10/algebra/ipwr.for
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


integer i
real pi
pi = 3.1415927
i = 0
i = i + 1
10 format (f10.7)
write (*, 10) pi
end

21 changes: 21 additions & 0 deletions pdp10/algebra/ipwr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
""" imaginary powers of base 10. starting with 10**(i/1024), and squaring successively ten times. this matches with feynman's table 22-3"""
from math import sqrt

# non rounded version
y = .00225 # should be .0022486
x = sqrt(1. - y**2)
for _ in range(11):
print('%10.7f %10.7f' % (x, y))
x2 = x**2 - y**2
y2 = 2 * x * y
x, y = x2, y2

# rounded version that more closely matches feynman's table 22-3
y = .00225 # should be .0022486
x = round(sqrt(1. - y**2), 7)
for _ in range(11):
print('%10.5f %10.5f' % (x, y))
x2 = round(x**2 - y**2, 7)
y2 = round(2 * x * y, 7)
x, y = x2, y2

53 changes: 25 additions & 28 deletions algebra/simplex.py → pdp10/algebra/simplex.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
"""simplest possible simplex implementation"""
import numpy as np


def main():
A = np.array([[-2, 1, 1, 0, 0], [-1, 2, 0, 1, 0], [1, 0, 0, 0, 1]])
b = np.array([2, 7, 3])
c = np.array([-1, -2, 0, 0, 0])
x = simplex(A, b, c)
return x


def simplex(A, b, c):
"""revised simplex method. """
m, n, o = A.shape[0], A.shape[1], A.shape[1] - A.shape[0]
ns, v1, v2 = [i for i in range(n)], np.array(c[o:]), np.array(c[:o])
Binv = np.linalg.inv(A[:, ns[o:]])
while not np.min(v2 - v1 @ Binv @ A[:, ns[:o]]) > 0:
n1 = np.argmin(v2 - v1 @ Binv @ A[:, ns[:o]])
t1, t2 = Binv @ b, Binv @ A[:, ns[n1]]
n2 = np.argmin([t1[i] / t2[i] if t2[i] > 0 else np.inf for i in range(m)])
ns[n1], ns[n2 + o], v1[n2], v2[n1] = ns[n2 + o], ns[n1], v2[n1], v1[n2]
Binv = np.linalg.inv(A[:, ns[o:]])
return Binv @ b


if __name__ == "__main__":
main()
"""simplest possible simplex implementation"""
import numpy as np

def main():
A = np.array([[-2, 1, 1, 0, 0], [-1, 2, 0, 1, 0], [1, 0, 0, 0, 1]])
b = np.array([2, 7, 3])
c = np.array([-1, -2, 0, 0, 0])
x = simplex(A, b, c)
return x

def simplex(A, b, c):
"""revised simplex method. """
m, n, o = A.shape[0], A.shape[1], A.shape[1] - A.shape[0]
ns, v1, v2 = [i for i in range(n)], np.array(c[o:]), np.array(c[:o])
Binv = np.linalg.inv(A[:, ns[o:]])
while not np.min(v2 - v1 @ Binv @ A[:, ns[:o]]) > 0:
n1 = np.argmin(v2 - v1 @ Binv @ A[:, ns[:o]])
t1, t2 = Binv @ b, Binv @ A[:, ns[n1]]
n2 = np.argmin([t1[i] / t2[i] if t2[i] > 0 else np.inf for i in range(m)])
ns[n1], ns[n2 + o], v1[n2], v2[n1] = ns[n2 + o], ns[n1], v2[n1], v1[n2]
Binv = np.linalg.inv(A[:, ns[o:]])
return Binv @ b

if __name__ == "__main__":
main()
94 changes: 47 additions & 47 deletions pdp10/docs/sec5-minimalist-walkthrough.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
assume you've started simh pdp10 and it's listening on 2010 for connections.

# on raspi side, start kermit

./kermit/wermit
C-Kermit>set host localhost 2010 /raw-socket
C-Kermit>c

# on tops10 side, start kermit

assume you've created a subfolder [,,decwar] in your home folder [,].

.r setsrc
*cp [,,decwar]
*^C
.r kermit
Kermit-10>set file byte-size 36-bit
Kermit-10>server

ctrl-\c back over to raspi kermit

# in raspi kermit

C-Kermit>set transfer mode manual
C-Kermit>set file type binary
C-Kermit>send utexas/*.*
C-Kermit>send compuserve/*.*
C-Kermit>send scripts/COM1.CMD
C-Kermit>send scripts/COM2.CMD
C-Kermit>send scripts/CAN1.CMD

can leave this connection in this state for further usage and get on tops10 via another connection, but if you like to use just this connection

C-Kermit>c
Kermit-10>^c^c^c
.

# on tops10 side

.compile @com1
.compile @com2
.r link
*@can1
.get decwar
.ssave

if it's not already there, create p,pn [1,27] using react, then copy DECWAR.EXE, DECWAR.GRP, DECWAR.HLP, DECWAR.NWS to its home folder to 'deploy/install' it. [1,27] is where decwar was deployed for compuserve. for utexas it was logical device name 'gam:', assigned to [5,30].
assume you've started simh pdp10 and it's listening on 2010 for connections.

# on raspi side, start kermit

./kermit/wermit
C-Kermit>set host localhost 2010 /raw-socket
C-Kermit>c

# on tops10 side, start kermit

assume you've created a subfolder [,,decwar] in your home folder [,].

.r setsrc
*cp [,,decwar]
*^C
.r kermit
Kermit-10>set file byte-size 36-bit
Kermit-10>server

ctrl-\c back over to raspi kermit

# in raspi kermit

C-Kermit>set transfer mode manual
C-Kermit>set file type binary
C-Kermit>send utexas/*.*
C-Kermit>send compuserve/*.*
C-Kermit>send scripts/COM1.CMD
C-Kermit>send scripts/COM2.CMD
C-Kermit>send scripts/CAN1.CMD

can leave this connection in this state for further usage and get on tops10 via another connection, but if you like to use just this connection

C-Kermit>c
Kermit-10>^c^c^c
.

# on tops10 side

.compile @com1
.compile @com2
.r link
*@can1
.get decwar
.ssave

if it's not already there, create p,pn [1,27] using react, then copy DECWAR.EXE, DECWAR.GRP, DECWAR.HLP, DECWAR.NWS to its home folder to 'deploy/install' it. [1,27] is where decwar was deployed for compuserve. for utexas it was logical device name 'gam:', assigned to [5,30].

0 comments on commit 1ee850f

Please sign in to comment.