generated from NLeSC/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from NLeSC/substepping
Substepping
- Loading branch information
Showing
14 changed files
with
229 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
// | ||
// Coarse data to compress the ammount of data for the qr dataset | ||
// | ||
export function coarseData(shape, data) { | ||
export function coarseData(data, shape) { | ||
// Coarse data to compress the ammount of data | ||
let dataCoarse = null; | ||
// console.log("Coarse graining..."); | ||
dataCoarse = new Uint8Array(shape[0] * shape[1] * shape[2] / (8 * 8 * 8)); | ||
for (let i = 0; i < shape[0] / 8; i++) { | ||
for (let j = 0; j < shape[1] / 8; j++) { | ||
for (let k = 0; k < shape[2] / 8; k++) { | ||
let x = 0; | ||
for (let l = 0; l < 8; l++) { | ||
for (let m = 0; m < 8; m++) { | ||
for (let n = 0; n < 8; n++) { | ||
const index = (k * 8 + n) + (j * 8 + m) * shape[2] + (l * 8 + i) * shape[2] * shape[1]; | ||
x = Math.max(x, data[index]) | ||
const blockSize = 8; | ||
const s0 = Math.ceil(shape[0] / blockSize); | ||
const s1 = Math.ceil(shape[1] / blockSize); | ||
const s2 = Math.ceil(shape[2] / blockSize); | ||
console.log("Coarse graining array of shape ",shape," to ",[s0, s1, s2],"..."); | ||
dataCoarse = new Uint8ClampedArray(s0 * s1 * s2); | ||
let index2 = 0; | ||
let x = 0; | ||
for (let i = 0; i < shape[2]; i += blockSize) { | ||
for (let j = 0; j < shape[0]; j += blockSize) { | ||
for (let k = 0; k < shape[1]; k += blockSize) { | ||
x = 0; | ||
for (let l = i; l < (i + blockSize) && l < shape[2]; l++) { | ||
for (let m = j; m < (j + blockSize) && m < shape[0]; m++) { | ||
for (let n = k; n < (k + blockSize) && n < shape[1]; n++) { | ||
const value = data[n + m * shape[1] + l * shape[0] * shape[1]]; | ||
if (value > x){ | ||
x = value; | ||
} | ||
} | ||
} | ||
} | ||
const index2 = k + j * shape[2] / 8 + i * (shape[2] / 8) * (shape[1] / 8); | ||
dataCoarse[index2] = x | ||
dataCoarse[index2] = x; | ||
index2++; | ||
} | ||
} | ||
} | ||
// console.log("...Done"); | ||
console.log("...Done"); | ||
|
||
return dataCoarse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.