MC: Faster User-RPL HILBERT
07-10-2018, 01:58 AM (This post was last modified: 07-10-2018 11:55 AM by Thomas Okken.)
Post: #10
 Thomas Okken Senior Member Posts: 1,120 Joined: Feb 2014
RE: MC: Faster User-RPL HILBERT
To elaborate a bit...

A naive Java implementation would be like this:

Code:
double[][] hilbert(int n) {     double[][] h = new double[n][n];     for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)             h[i][j] = 1.0 / (i + j + 1);     return h; }

while the division-minimizing approach could also be coded with nested loops, like this:

Code:
double[][] hilbert(int n) {     double[][] h = new double[n][n];     for (int j = 0; j < n; j++)         h[0][j] = 1.0 / (j + 1);     for (int i = 1; i < n; i++) {         for (int j = 0; j < n - 1; j++)             h[i][j] = h[i - 1][j + 1];         h[i][n - 1] = 1.0 / (i + n);     }     return h; }
 « Next Oldest | Next Newest »

 Messages In This Thread MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018, 01:28 PM RE: MC: Faster User-RPL HILBERT - Thomas Okken - 07-09-2018, 03:16 PM RE: MC: Faster User-RPL HILBERT - rprosperi - 07-09-2018, 04:32 PM RE: MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018, 05:25 PM RE: MC: Faster User-RPL HILBERT - Valentin Albillo - 07-09-2018, 09:46 PM RE: MC: Faster User-RPL HILBERT - Thomas Okken - 07-09-2018, 11:03 PM RE: MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018, 11:43 PM RE: MC: Faster User-RPL HILBERT - Thomas Okken - 07-10-2018, 01:25 AM RE: MC: Faster User-RPL HILBERT - Gerald H - 07-10-2018, 09:50 AM RE: MC: Faster User-RPL HILBERT - ttw - 07-09-2018, 05:10 PM RE: MC: Faster User-RPL HILBERT - Thomas Okken - 07-10-2018 01:58 AM RE: MC: Faster User-RPL HILBERT - Werner - 07-10-2018, 07:20 AM RE: MC: Faster User-RPL HILBERT - John Keith - 08-05-2018, 02:05 PM RE: MC: Faster User-RPL HILBERT - Juan14 - 08-05-2018, 06:31 PM RE: MC: Faster User-RPL HILBERT - John Keith - 08-05-2018, 07:40 PM

User(s) browsing this thread: 1 Guest(s)