# HG changeset patch # User Chris Cannam # Date 1383046413 0 # Node ID 8094afddd1c95700cb30b627829e0195240eb61f # Parent 25d309d90d50beebb3ea18a47837906f41d12789 Add generate, constMatrix, zeroMatrix diff -r 25d309d90d50 -r 8094afddd1c9 src/may/matrix/complex.yeti --- 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, getRow is number -> complexmatrix -> array, getDiagonal is number -> complexmatrix -> array, + 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,