Browse Source

updated README

master
lbeckman314 2 years ago
parent
commit
cf5351ab22
8 changed files with 223 additions and 56 deletions
  1. 204
    25
      README.md
  2. 1
    0
      example_matrices/m3
  3. 4
    5
      example_matrices/m4
  4. 4
    3
      example_matrices/m5
  5. 4
    3
      example_matrices/m6
  6. 4
    0
      example_matrices/m7
  7. 1
    0
      example_matrices/m8
  8. 1
    20
      example_matrices/m9

+ 204
- 25
README.md View File

@@ -1,6 +1,6 @@
![matrix](matrix.png)

This program adds, multiplies, transposes, and averages matrices! See it in action [here](https://asciinema.org/a/zjRyykwFxzX8SYoXAMemrWPk8).
This program adds, multiplies, transposes, and averages matrices! in action [here](https://asciinema.org/a/zjRyykwFxzX8SYoXAMemrWPk8).

<br />
<hr />
@@ -15,10 +15,11 @@ For an example of installation, see [here](https://asciinema.org/a/4R4KJhtmdGImK

[`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! : )
If you have a propensity against git, check out [the alternative installation](./#alternative-installation). In which case [`wget`](https://www.gnu.org/software/wget/) or [`curl`](https://curl.haxx.se/) can be helpful for downloading the necessary files. [`gpg`](https://gnupg.org/) and [`sha256sum`](https://linux.die.net/man/1/sha256sum) can be used to verify the integrity of the files.

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).
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 Subsystem 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>

@@ -37,7 +38,6 @@ chmod u+x matrix
```

<br />
<hr />

# Uninstallation

@@ -55,27 +55,90 @@ rm -rfI matrix

(Run `man -l matrix.man` while in the directory for a basic man page for `matrix`.)

`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.
`matrix` takes four arguments: **add**, **average**, **multiply**, and **transpose**. Matrix input (either with files or standard input) must be integers, either positive or negative, separated by white space. Non-numeric characters (including blank elements) will throw an error. Output will be tab-delimited elements.

<br />
<br />

**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.
takes two matrices of dimensions `row × col` and `row × col` and produces a sum matrix of dimesions `row × col`. To add two matrices, run `./matrix add m1 m2` where `m1` and `m2` are matrix files.


**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.
```sh
$ cat mI1
1 2 3 4
5 6 7 8

$ ./matrix add m1 m1
2 4 6 8
10 12 14 16
```

<br />
<br />

**mean**
takes one matrix of dimension `row × col` and averages each of it's columns. Produces an average matrix of dimensions `1 × col`. To add two matrices, run `./matrix transpose m1 ` where `m1` is a matrix file.

```sh
$ cat m1
1 2 3 4
5 6 7 8

$ ./matrix mean m1
3 4 5 6
```

<br />
<br />

**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.
takes two matrices of dimensions `row₁ × col₁` and `row₂ × col₂` and produces a sum matrix of dimesions `row₁ × col₂`. col₁ must be eqaul to row₂. To add two matrices, run `./matrix multiply m1 m2` where `m1` and `m2` are matrix files.

```sh
$ cat m1
1 2 3 4
5 6 7 8

$ cat m2
1 5
2 6
3 7
4 8

$ ./matrix multiply m1 m2
30 70
70 174
```

<br />
<br />

**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.
takes one matrix and moves element at position `row × col` to position `col × row`. To add two matrices, run `./matrix transpose m1` where `m1` is a matrix file.

```sh
$ cat m1
1 2 3 4
5 6 7 8

$ ./matrix transpose m1
1 5
2 6
3 7
4 8
```

<br />
<hr />
<br />

Examples of **valid** matrix input include:
# Examples of valid and invalid matrices:

m4 is a **valid** matrix
```
$ cat m4

1 2 3
4 5 6
7 8 9
@@ -83,37 +146,153 @@ Examples of **valid** matrix input include:
```
<br />

m5 is an **invalid** matrix: non-numeric character at position (1, 3).
```
1 2 3 4
5 6 7 8
$ cat m5

1 2 A
4 5 6
7 8 9
10 11 12
```

<br />
<hr />
<br />

m6 is a **valid** matrix
```
1 2 3
$ cat m6

1 2
2 3
3 4
4 5
```

<br />

Examples of **invalid** matrix input include:
m7 is an **invalid** matrix: blank character at position (2, 1)
```
$ cat m7

Non-numeric charcter at position (1, 3).
1 2
3
3 4
4 5
```
1 2 a
4 5 6
7 8 9
10 11 12

<br />
<hr />
<br />

m8 is a **valid** matrix
```
$ cat -A m8

1 2 3$
```

<br />

Blank character at position (1, 2)
m9 is an **invalid** matrix: trailing tab in first row
```
1 3 4
5 6 7 8
$ cat m9

1 2 3 $
```

<br />
<hr />
<br />

# Alternative Installation

<h2 class="code">0. Download</h2>

Trailing tab in first row
Click the tar.gz or zip buttons at the top of the page to download a tar.gz or .zip compressed directory.

Or copy and paste the following command into the terminal to have it download it for you!

```shell
wget http://www.liambeckman.com/pkgs/matrix/matrix.tar.gz

# or if you prefer curl:
# curl http://www.liambeckman.com/pkgs/matrix/matrix.tar.gz -o matrix.tar.gz
```
1t2\t3\t


<h2 class="code">Optional (but recommended): verify file integrity</h2>

```shell
#-------------------------------#
# RECIEVE GPG KEYS
#-------------------------------#

gpg --keyserver pgp.mit.edu --recv-keys AC1CC079

#-------------------------------#
# RECIEVE SHA256SUMS
#-------------------------------#

wget http://www.liambeckman.com/pkgs/matrix/sha256sums.txt{,.asc}
# or if you prefer curl:
# curl http://www.liambeckman.com/pkgs/matrix/sha256sums.txt{,.asc} -o sha256sums.txt -o sha256sums.txt.asc

#-------------------------------#
# VERIFY SHA256SUMS
#-------------------------------#

gpg --verify sha256sums.txt.asc

# 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]

#-------------------------------#
# VERIFY FILE INTEGRITY
#-------------------------------#

sha256sum -c sha256sums.txt

# matrix.tar.gz: OK
# matrix.zip: OK

#-------------------------------#
# OPTIONALLY REMOVE PUBLIC KEY
#-------------------------------#

# to remove my public key from your public key ring, simply
gpg --delete-key AC1CC079
```


<h2 class="code">1. Extract</h2>


```shell
tar -zxvf matrix.tar.gz
# or if you downloaded the zip file
# unzip matrix.zip
```


<h2 class="code">2. Compile and run</h2>


```shell
cd matrix

chmod u+x matrix
./matrix add m1 m1
```

<br />

# Uninstallation


<h2 class="code">0. Delete the directory/folder.</h2>

```shell
rm -rfI matrix
```

+ 1
- 0
example_matrices/m3 View File

@@ -0,0 +1 @@
1 2 3

+ 4
- 5
example_matrices/m4 View File

@@ -1,5 +1,4 @@
1 2
-3 4
3 6
8
9 10
1 2 3
4 5 6
7 8 9
10 11 12

+ 4
- 3
example_matrices/m5 View File

@@ -1,3 +1,4 @@
1 2 3
4 5 6
7 8 9
1 2 A
4 5 6
7 8 9
10 11 12

+ 4
- 3
example_matrices/m6 View File

@@ -1,3 +1,4 @@
1 2
2 3
3 4
1 2
2 3
3 4
4 5

+ 4
- 0
example_matrices/m7 View File

@@ -0,0 +1,4 @@
1 2
3
3 4
4 5

+ 1
- 0
example_matrices/m8 View File

@@ -0,0 +1 @@
1 2 3

+ 1
- 20
example_matrices/m9 View File

@@ -1,20 +1 @@
-93 -92 29 -45 -55 -87 -36 39 -88 71 7 -69 52 45 -22
50 -27 85 11 -76 -3 23 68 58 -5 34 7 -29 -49 41
-61 2 -44 -62 47 -77 33 6 -7 55 -45 99 2 20 89
52 -97 57 -39 -76 62 24 69 -74 89 -76 1 -46 -27 -9
55 77 42 10 -98 -22 15 -48 26 33 -7 29 -34 78 -19
23 25 -40 16 -63 -12 42 45 -22 20 44 -23 78 -50 17
-67 14 -9 -58 38 -78 2 99 -87 -92 -34 -29 -7 -31 11
65 -32 27 91 -46 -13 -71 37 24 -5 34 -92 6 15 -15
-49 23 -52 -9 59 -57 -78 -10 17 -27 44 -34 -62 22 -94
-45 -45 88 -12 -64 1 -60 -35 11 1 -10 52 5 52 -17
-91 61 90 22 82 -9 82 85 10 56 18 4 -18 -92 -46
31 98 47 -12 -60 20 54 -8 92 24 -71 -23 24 91 37
-12 98 -13 66 72 -14 88 51 75 5 40 -91 91 -94 26
0 60 -41 6 28 -54 97 56 40 -17 94 -92 -23 -3 -91
10 -26 78 -22 -55 73 -82 -49 -26 -63 -80 8 97 87 -27
80 17 90 22 6 45 23 91 16 -93 -38 -64 -75 35 61
21 -24 -38 92 -43 98 -14 35 39 -65 -20 65 65 19 -81
79 -32 62 -93 89 19 -83 -47 45 20 93 49 43 73 80
24 81 19 -15 48 -46 -23 -63 65 2 75 -16 1 -98 14
-40 -68 -89 -10 90 29 3 -15 58 86 -85 36 -55 31 -79
1 2 3

Loading…
Cancel
Save