diff --git a/src/App.svelte b/src/App.svelte index ae6c993..cc252b4 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -8,12 +8,19 @@ let kernelHeight = 3; let padding = 0; - $: matrix = Array(matrixHeight) - .fill(1) - .map(() => Array(matrixWidth).fill(1)); - $: kernel = Array(kernelHeight) - .fill(1) - .map(() => Array(kernelWidth).fill(1)); + $: matrix = + matrixHeight > 0 && matrixWidth > 0 + ? Array(matrixHeight) + .fill(1) + .map(() => Array(matrixWidth).fill(1)) + : [[]]; + + $: kernel = + kernelHeight > 0 && kernelWidth > 0 + ? Array(kernelHeight) + .fill(1) + .map(() => Array(kernelWidth).fill(1)) + : [[]]; $: result = conv_2d(kernel, matrix, padding); @@ -73,7 +80,9 @@
{result[0].length}x{result.length}
-
+
+ +
Padding
diff --git a/src/MatrixSizeInput.svelte b/src/MatrixSizeInput.svelte index 45ac55a..2f41cd3 100644 --- a/src/MatrixSizeInput.svelte +++ b/src/MatrixSizeInput.svelte @@ -4,9 +4,9 @@
- + x - +