EMS-TU-Ilmenau / fastmat

A library to build up lazily evaluated expressions of linear transforms for efficient scientific computing.
https://fastmat.readthedocs.io
Apache License 2.0
24 stars 8 forks source link

Column and Row Normalization #8

Closed SebastianSemper closed 5 years ago

SebastianSemper commented 6 years ago

Problem

Currently we offer a Matrix.normalized() function, which returns Matrix * Diag such that this matrices columns are normalized. This yields certain drawbacks:

  1. There is no obvious way to tell, that the columns of the matrix are normalized. So the name is a little bit to abiguous.

  2. We need to differentiate between column and row normalization, since both features are needed in various contexts.

Solution

Implement Matrix.colNormalized, which returns Matrix * Diag and Matrix.rowNormalized, which returns Diag * Matrix.

Profit

  1. The Product class allows nifty normalization

  2. ...

SebastianSemper commented 6 years ago

A little bit more insight:

If one is able to apply A^2 and A^2^H, where A^2 is elementwise squaring, one can apply these to a vector containing all ones and then draw a square root element wise of the result, to get the row or colum norms respectively.

Moreover if the classes could provide not only their norms, but squared norms, one could use this in cases like the blockdiag or diag blocks or blocks to calculate the norm of nested matrizes.

since this is something, we might be using a lot, it might be worth to spend some effort in providing these methods.

ChristophWWagner commented 5 years ago

so if I understood correctly, you are suggesting to add the following properties to the base class?:

.colNorm
.rowNorm
.colSuaredNorm
.rowSquaredNorm
.colNormalized
.rowNormalized

Each one of these gets the full shadowing and overloading interface, of course. (e.g. .colNorm also gets ._colNorm, .colSquaredNorm, .colNormalized)

In the process .normalized would be removed.

SebastianSemper commented 5 years ago

No

Am Fr., 9. Nov. 2018, 19:38 hat Christoph Wagner notifications@github.com geschrieben:

so if I understood correctly, you are suggesting to add the following properties to the base class?:

.colNorm .rowNorm .colSuaredNorm .rowSquaredNorm .colNormalized .rowNormalized

Each one of these gets the full shadowing and overloading interface, of course. (e.g. .colNorm also gets ._colNorm, .colSquaredNorm, .colNormalized)

In the process .normalized would be removed.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EMS-TU-Ilmenau/fastmat/issues/8#issuecomment-437454442, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDZRiP1k5NpYC5jrVFyM7T29RKVCMuGks5utcujgaJpZM4P6cNb .

ChristophWWagner commented 5 years ago

Update:

.columnNorms
.rowNorms
.columnNormalized
.rowNormalized