multrix/src/main.nim
array-in-a-matrix 71a2b4a057 dot product proc
2022-11-22 20:09:25 -05:00

52 lines
1.2 KiB
Nim

import strutils, sequtils, os, procedures, strformat
var operation: string
case paramStr(0):
of "dot":
operation = "dot"
echo "Parameter is dot"
of "cross":
operation = "cross"
echo "Parameter is cross"
else:
# TODO: ask user to preform dot or cross product
echo "multrix"
echo "Enter number of rows in the first matrix:"
let r1: int = parseInt(readLine(stdin))
echo "Enter number of columns in the first matrix:"
let c1: int = parseInt(readLine(stdin))
var m1 = newSeqWith(r1, newSeq[float](c1))
procedures.fillMatrix(m1, r1, c1)
echo ""
echo "Enter number of rows in the second matrix:"
let r2: int = parseInt(readLine(stdin))
echo "Enter number of columns in the second matrix:"
let c2: int = parseInt(readLine(stdin))
var m2 = newSeqWith(r2, newSeq[float](c2))
procedures.fillMatrix(m2, r2, c2)
# calculate dot product (in procedures)
var m = newSeqWith(0, newSeq[float](0))
m = dot(m1, m2)
# TODO: calculate cross product (in procedures)
echo "\nFirst matrix is:"
procedures.printMatrix(m1)
echo "\nSecond matrix is:"
procedures.printMatrix(m2)
echo "\nResult matrix is:"
procedures.printMatrix(m)