README.md in matrix_extensions-0.0.3 vs README.md in matrix_extensions-0.0.4
- old
+ new
@@ -18,95 +18,95 @@
$ gem install matrix_extensions
## Usage
-*Element-wise multiplication:*
+**Element-wise multiplication:**
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix[ [1,2,3], [4,5,6] ].element_multiplication Matrix[ [2,3,4], [5,6,7] ]
=> Matrix[[2, 6, 12], [20, 30, 42]]
```
-*Element-wise division:*
+**Element-wise division:**
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix[ [2,4,6], [2.0,10,20] ].element_division Matrix[ [2,2,6], [4,5,10] ]
=> Matrix[[1, 2, 1], [0.5, 2, 2]]
```
-*Element-wise exponentiation:*
+**Element-wise exponentiation:**
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix[ [2,4], [1,4] ].element_exponentiation Matrix[ [2,4], [1,4]] ]
=> Matrix[[4, 256], [1, 256]]
```
-*Prefilled matrix with zeros or ones:*
+**Prefilled matrix with zeros or ones:**
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix.zeros(2,4)
=> Matrix[[0, 0, 0, 0], [0, 0, 0, 0]]
Matrix.ones(2,2)
=> Matrix[[1, 1], [1, 1]]
```
-*Concatenating matrices and vectors horizontally:*
+**Concatenating matrices and vectors horizontally:**
This iterates through a list of matrices and vectors and appends columns of each list one after another. The row number of all matrices and vectors must be equal. The number of arguments passed in can be freely chosen.
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
m1 = Matrix[ [1,2,3], [4,5,6] ]
m2 = Matrix[ [2,3,4], [5,6,7] ]
v = Vector[ 3,4 ]
Matrix.hconcat(m1, m2, v)
=> Matrix[[1, 2, 3, 2, 3, 4, 3], [4, 5, 6, 5, 6, 7, 4]]
```
-*Concatenating matrices and vectors vertically:*
+**Concatenating matrices and vectors vertically:**
This iterates through a list of matrices and vectors and appends rows of each list one after another. The column number of all matrices and vectors must be equal. The number of arguments passed in can be freely chosen.
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
m1 = Matrix[ [1,2,3], [4,5,6] ]
m2 = Matrix[ [2,3,4], [5,6,7] ]
v = Vector[ 3,4,5 ]
Matrix.vconcat(m1, m2, v)
=> Matrix[[1, 2, 3], [4, 5, 6], [2, 3, 4], [5, 6, 7], [3, 4, 5]]
```
-*Removing trailing columns:*
+**Removing trailing columns:**
-Removes a set number of trailing columns from a matrix. The argument defaults to 1.
+Removes a set number of trailing columns from a matrix (destructive) and returns the removed columns. The argument defaults to 1.
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix[ [1,2,3], [4,5,6] ].hpop(2)
-=> Matrix[[1], [4]]
+=> Matrix[[2, 3], [5, 6]]
```
-*Removing trailing rows:*
+**Removing trailing rows:**
-Removes a set number of trailing rows from a matrix. The argument defaults to 1.
+Removes a set number of trailing rows from a matrix (destructive) and returns the removed rows. The argument defaults to 1.
```ruby
-require 'matrix_extensions'
+require 'matrix_extensions' # if not loaded automatically
Matrix[ [1,2,3], [4,5,6], [7,8,9] ].vpop(2)
=> Matrix[[1, 2, 3]]
```