## Feature #15869

### Add abs to Matrix

**Description**

While I was studying Markov Chain I had to find the maximum absolute value of the Matrix to divide the matrix in numbers from 0 to 1 to be able to make further analysis. Like this:

q = Matrix[ ... ] max = q.to_a.flatten.map { |e| e.abs }.max q = q / max

So this is the first of two features that I would like to contribute.

- Matrix.abs
- Matrix.max

### History

#### Updated by bonafernando (Fernando Wolf Bona) 7 months ago

**Backport**deleted ()*2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN***Tracker**changed from*Bug*to*Feature*

#### Updated by bonafernando (Fernando Wolf Bona) 7 months ago

bonafernando (Fernando Wolf Bona) wrote:

While I was studying Markov Chain I had to find the maximum absolute value of the Matrix to divide the matrix in numbers from 0 to 1 to be able to make further analysis. Like this:

q = Matrix[ ... ] max = q.to_a.flatten.map { |e| e.abs }.max q = q / maxSo this is the first of two features that I would like to contribute.

- Matrix.abs
- Matrix.max

#### Updated by marcandre (Marc-Andre Lafortune) 7 months ago

**Assignee**set to*marcandre (Marc-Andre Lafortune)*

#### Updated by shevegen (Robert A. Heiler) 7 months ago

Interesting. Not sure if this has to do with Markov Chain per se, but for storing state

through automata (in bioinformatics), hidden markov models are also used. Perhaps

extending Matrix may be beneficial in general (for ruby as a larger ecosystem;

curiously enough, the third most often downloaded gem is diff-lcs, which is probably

useful in a variety of different applications; I came to it indirectly through Hamming

and Levensthein distances).

#### Updated by marcandre (Marc-Andre Lafortune) about 2 months ago

**Status**changed from*Open*to*Closed*