|
|
@@ -1,84 +1,119 @@ |
|
|
|
 |
|
|
|
|
|
|
|
This program adds, multiplies, tranposes, and averages matrices! |
|
|
|
This program adds, multiplies, transposes, and averages matrices! See it in action [here](https://asciinema.org/a/zjRyykwFxzX8SYoXAMemrWPk8). |
|
|
|
|
|
|
|
<br /> |
|
|
|
<hr /> |
|
|
|
|
|
|
|
# Installation |
|
|
|
|
|
|
|
<h2 class="code">1. Download</h2> |
|
|
|
For an example of installation, see [here](https://asciinema.org/a/4R4KJhtmdGImK1UHn9x6hIULx). |
|
|
|
|
|
|
|
<h2 class="code">0. Prerequisites</h2> |
|
|
|
|
|
|
|
[`bash`](https://www.gnu.org/software/bash/) :: for running the script. |
|
|
|
|
|
|
|
[`git`](https://git-scm.com/) :: for a quick git clone. |
|
|
|
|
|
|
|
If you are running Windows, the above utilities will be packaged in any of the following: [babun](https://babun.github.io/), [cmder](http://cmder.net/), or [Linux Subsytem for Windows](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Take your pick! : ) |
|
|
|
|
|
|
|
The above utilities should be installed (or readily available) if you are running a Unix derivative (such as Linux, macOS, or any of the BSD's). |
|
|
|
|
|
|
|
|
|
|
|
<h2 class="code">1. Quickstart</h2> |
|
|
|
|
|
|
|
```shell |
|
|
|
wget http://www.liambeckman.com/code/matrix/matrix.tar.gz |
|
|
|
# or for a quick git clone... |
|
|
|
# git clone https://github.com/lbeckman314/matrix |
|
|
|
# clone the git repo |
|
|
|
git clone https://git.liambeckman.com/cgit/matrix |
|
|
|
|
|
|
|
# enter directory |
|
|
|
cd matrix |
|
|
|
|
|
|
|
# allow the script to execute |
|
|
|
chmod u+x matrix |
|
|
|
|
|
|
|
# run the script |
|
|
|
./matrix add m1 m1 |
|
|
|
``` |
|
|
|
|
|
|
|
<h2 class="code">Optional (but recommended): verify file integrity</h2> |
|
|
|
<br /> |
|
|
|
<hr /> |
|
|
|
|
|
|
|
```shell |
|
|
|
#-------------------------------# |
|
|
|
# RECIEVE GPG KEYS |
|
|
|
#-------------------------------# |
|
|
|
# Uninstallation |
|
|
|
|
|
|
|
gpg --keyserver pgp.mit.edu --recv-keys AC1CC079 |
|
|
|
|
|
|
|
#-------------------------------# |
|
|
|
# RECIEVE SHA256SUMS |
|
|
|
#-------------------------------# |
|
|
|
<h2 class="code">0. Delete the directory/folder.</h2> |
|
|
|
|
|
|
|
wget http://www.liambeckman.com/code/matrix/sha256sums.txt{,.sig} |
|
|
|
# or if you prefer curl: |
|
|
|
# curl http://www.liambeckman.com/code/matrix/sha256sums.txt{,.sig} -o sha256sums.txt -o sha256sums.txt.sig |
|
|
|
```shell |
|
|
|
rm -rfI matrix |
|
|
|
``` |
|
|
|
|
|
|
|
#-------------------------------# |
|
|
|
# VERIFY SHA256SUMS |
|
|
|
#-------------------------------# |
|
|
|
<br /> |
|
|
|
<hr /> |
|
|
|
|
|
|
|
gpg --verify sha256sums.txt.sig |
|
|
|
# Documentation |
|
|
|
|
|
|
|
# gpg: Signature made Tue Oct 31 11:11:11 2017 PDT using RSA key ID AC1CC079 |
|
|
|
# gpg: Good signature from "liam beckman ("I only want to live in peace, |
|
|
|
# plant potatoes, and dream!" -Tove Jansson) <lbeckman314@gmail.com>" [unknown] |
|
|
|
(Run `man -l matrix.man` while in the directory for a basic man page for `matrix`.) |
|
|
|
|
|
|
|
#-------------------------------# |
|
|
|
# VERIFY FILE INTEGRITY |
|
|
|
#-------------------------------# |
|
|
|
`matrix` takes four arguments: **add**, **average**, **multiply**, and **transpose**. Matrix input (either with files or standard input) must be integers, either positive or negative, seperated by white space. Non-numeric characters (including blank elements) will throw an error. |
|
|
|
|
|
|
|
sha256sum -c sha256sums.txt |
|
|
|
|
|
|
|
# matrix.tar.gz: OK |
|
|
|
# matrix.zip: OK |
|
|
|
**add** |
|
|
|
takes two matrices of dimensions (Y by Z) and (Y by Z) and produces a sum matrix of dimesions (Y by Z). To add two matrices, run `./matrix add m1 m2` where `m1` and `m2` are matrix files. |
|
|
|
|
|
|
|
#-------------------------------# |
|
|
|
# OPTIONALLY REMOVE PUBLIC KEY |
|
|
|
#-------------------------------# |
|
|
|
**average** |
|
|
|
takes one matrix of dimension (Y by X) and averages each of it's columns. Produces an average matrix of dimensions (1 by X). To add two matrices, run `./matrix transpose m1 ` where `m1` is a matrix file. |
|
|
|
|
|
|
|
# to remove my public key from your public key ring, simply |
|
|
|
gpg --delete-key AC1CC079 |
|
|
|
``` |
|
|
|
**multiply** |
|
|
|
takes two matrices of dimensions (Y1 by X1) and (Y2 by X2) and produces a sum matrix of dimesions (X1 by Y2). X1 must be eqaul to Y2. To add two matrices, run `./matrix multiply m1 m2` where `m1` and `m2` are matrix files. |
|
|
|
|
|
|
|
**transpose** |
|
|
|
takes one matrix and moves element at position (Y by X) to position (X by Y). To add two matrices, run `./matrix transpose m1` where `m1` is a matrix file. |
|
|
|
|
|
|
|
<h2 class="code">2. Extract</h2> |
|
|
|
<hr /> |
|
|
|
<br /> |
|
|
|
|
|
|
|
```shell |
|
|
|
tar -zxvf matrix.tar.gz |
|
|
|
# or if you downloaded the zip file |
|
|
|
# unzip matrix.zip |
|
|
|
``` |
|
|
|
Examples of **valid** matrix input include: |
|
|
|
|
|
|
|
``` |
|
|
|
1 2 3 |
|
|
|
4 5 6 |
|
|
|
7 8 9 |
|
|
|
10 11 12 |
|
|
|
``` |
|
|
|
<br /> |
|
|
|
|
|
|
|
<h2 class="code">3. Compile and run</h2> |
|
|
|
``` |
|
|
|
1 2 3 4 |
|
|
|
5 6 7 8 |
|
|
|
``` |
|
|
|
<br /> |
|
|
|
|
|
|
|
```shell |
|
|
|
g++ matrix/src/matrix.cpp -o matrix/src/matrix |
|
|
|
./matrix/src/matrix |
|
|
|
``` |
|
|
|
1 2 3 |
|
|
|
``` |
|
|
|
<br /> |
|
|
|
|
|
|
|
Examples of **invalid** matrix input include: |
|
|
|
|
|
|
|
# Uninstallation |
|
|
|
Non-numeric charcter at position (1, 3). |
|
|
|
``` |
|
|
|
1 2 a |
|
|
|
4 5 6 |
|
|
|
7 8 9 |
|
|
|
10 11 12 |
|
|
|
``` |
|
|
|
<br /> |
|
|
|
|
|
|
|
<h2 class="code">1. Delete the directory/folder.</h2> |
|
|
|
Blank character at position (1, 2) |
|
|
|
``` |
|
|
|
1 3 4 |
|
|
|
5 6 7 8 |
|
|
|
``` |
|
|
|
<br /> |
|
|
|
|
|
|
|
```shell |
|
|
|
rm -rfI matrix |
|
|
|
Trailing tab in first row |
|
|
|
``` |
|
|
|
1t2\t3\t |
|
|
|
``` |
|
|
|
|