Mercurial > hg > may
changeset 471:8094afddd1c9
Add generate, constMatrix, zeroMatrix
author | Chris Cannam |
---|---|
date | Tue, 29 Oct 2013 11:33:33 +0000 |
parents | 25d309d90d50 |
children | de6e80e22885 |
files | src/may/matrix/complex.yeti |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/may/matrix/complex.yeti Tue Oct 29 11:33:10 2013 +0000 +++ b/src/may/matrix/complex.yeti Tue Oct 29 11:33:33 2013 +0000 @@ -61,6 +61,29 @@ pget = maybe' \(vec.zeros n) (mat.getDiagonal k); array (map2 cpx.complex (pget cm.real) (pget cm.imaginary))); +generate f size = + //!!! doc: inefficient if function is not fast as it's called + // twice for every cell (real & imag separately) + { + size, + real = Some (mat.generate do row col: cpx.real (f row col) done size), + imaginary = Some (mat.generate do row col: cpx.imaginary (f row col) done size), + }; + +constMatrix c size = + { + size, + real = Some (mat.constMatrix (cpx.real c) size), + imaginary = Some (mat.constMatrix (cpx.imaginary c) size), + }; + +zeroMatrix size = + { + size, + real = none, + imaginary = none + }; + rowSlice cm start end = (pget = maybe none (Some . do m: mat.rowSlice m start end done); { @@ -257,6 +280,9 @@ getColumn, getRow, getDiagonal, + generate, + constMatrix, + zeroMatrix, equal, conjugateTransposed, transposed, @@ -288,6 +314,9 @@ getColumn is number -> complexmatrix -> array<cplx>, getRow is number -> complexmatrix -> array<cplx>, getDiagonal is number -> complexmatrix -> array<cplx>, + generate is (number -> number -> cplx) -> { .rows is number, .columns is number } -> complexmatrix, + constMatrix is cplx -> { .rows is number, .columns is number } -> complexmatrix, + zeroMatrix is { .rows is number, .columns is number } -> complexmatrix, equal is complexmatrix -> complexmatrix -> boolean, conjugateTransposed is complexmatrix -> complexmatrix, transposed is complexmatrix -> complexmatrix,