Skip to content

Commit 5af38ea

Browse files
committed
- added a main behavior for all 6 configuration options that should allow people to run it smoothly from command line
1 parent 4635a04 commit 5af38ea

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

nimplex.nim

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,39 @@ proc simplex_internal_grid_fractional*(dim: int,
6666
result = result.map(x => x / float(ndiv))
6767
return result
6868

69-
echo "Simplex dimensions:"
70-
let dim = readLine(stdin).parseInt()
69+
when isMainModule:
70+
echo "Configuration (Full/Internal)(Fractional/Integer)(Full/Shape) - e.g. FFS:"
71+
let config = readLine(stdin)
7172

72-
echo "N divisions:"
73-
let ndiv = readLine(stdin).parseInt()
73+
echo "Simplex dimensions:"
74+
let dim = readLine(stdin).parseInt()
7475

75-
let temp = simplex_internal_grid_fractional(dim, ndiv)
76-
echo "Internal grid:", temp
77-
echo "Internal grid size:", temp.shape[0]
76+
echo "N divisions:"
77+
let ndiv = readLine(stdin).parseInt()
78+
79+
let mainConfig = config[0..1]
80+
81+
case mainConfig
82+
of "FF":
83+
let temp = simplex_grid_fractional(dim, ndiv)
84+
if config[2] == 'F':
85+
echo "Full grid:", temp
86+
echo "Full grid size:", temp.shape[0]
87+
of "FI":
88+
let temp = simplex_grid(dim, ndiv)
89+
if config[2] == 'F':
90+
echo "Full grid:", temp
91+
echo "Full grid size:", temp.shape[0]
92+
of "IF":
93+
let temp = simplex_internal_grid_fractional(dim, ndiv)
94+
if config[2] == 'F':
95+
echo "Full grid:", temp
96+
echo "Full grid size:", temp.shape[0]
97+
of "II":
98+
let temp = simplex_internal_grid(dim, ndiv)
99+
if config[2] == 'F':
100+
echo "Full grid:", temp
101+
echo "Full grid size:", temp.shape[0]
102+
else:
103+
echo "Invalid configuration"
104+
quit(1)

0 commit comments

Comments
 (0)