Mercurial > octave
changeset 28521:23a33db2bdb3
maint: merge stable to default.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Wed, 01 Jul 2020 16:04:22 +0900 |
parents | d4563c5d4060 (current diff) 627da618dcc4 (diff) |
children | a5541f5a78dd |
files | |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/special-matrix/hilb.m Mon Jun 29 23:45:19 2020 -0400 +++ b/scripts/special-matrix/hilb.m Wed Jul 01 16:04:22 2020 +0900 @@ -66,12 +66,10 @@ error ("hilb: N must be a scalar integer"); endif - retval = zeros (n); - tmp = 1:n; - for i = 1:n - retval(i, :) = 1.0 ./ tmp; - tmp += 1; - endfor + ## Very elegant solution by N. Higham + ## https://nhigham.com/2020/06/30/what-is-the-hilbert-matrix/ + j = 1:n; + retval = 1 ./ (j' + j - 1); endfunction