aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_redistribute_energy_double.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-30 22:58:00 +0100
committerMattias Andrée <maandree@kth.se>2023-01-30 22:58:00 +0100
commita4b5b706053b4796a3418345a49f0e6ff0623572 (patch)
treead9dafed98b05d0349ec5f171783f8ddce7841a9 /libglitter_redistribute_energy_double.c
parentFix warnings, add restrict, and add function attributes (diff)
downloadlibglitter-a4b5b706053b4796a3418345a49f0e6ff0623572.tar.gz
libglitter-a4b5b706053b4796a3418345a49f0e6ff0623572.tar.bz2
libglitter-a4b5b706053b4796a3418345a49f0e6ff0623572.tar.xz
Add libglitter_redistribute_energy_double stub
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libglitter_redistribute_energy_double.c')
-rw-r--r--libglitter_redistribute_energy_double.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/libglitter_redistribute_energy_double.c b/libglitter_redistribute_energy_double.c
new file mode 100644
index 0000000..3eb39e0
--- /dev/null
+++ b/libglitter_redistribute_energy_double.c
@@ -0,0 +1,80 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+static void
+hselfconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height, size_t kernelsize, const double *hkernel)
+{
+ /* TODO */
+}
+
+
+static void
+hconvolute(double *restrict output, const double *restrict input, size_t output_rowsize, size_t input_rowsize,
+ size_t width, size_t height, size_t kernelsize, const double *kernel)
+{
+ /* TODO */
+}
+
+
+static void
+vconvolute(double *restrict output, const double *restrict input, size_t output_rowsize, size_t input_rowsize,
+ size_t width, size_t height, size_t kernelsize, const double *kernel)
+{
+ /* TODO */
+}
+
+
+static void
+copyraster(double *restrict output, const double *restrict input, size_t output_rowsize,
+ size_t input_rowsize, size_t width, size_t height)
+{
+ size_t y;
+ for (y = 0; y < height; y++) {
+ memcpy(output, input, width * sizeof(double));
+ output = &output[output_rowsize];
+ input = &input[input_rowsize];
+ }
+}
+
+
+void
+libglitter_redistribute_energy_double(double *restrict output, const double *restrict input, /* TODO add man page */
+ size_t output_rowsize, size_t input_rowsize, size_t width,
+ size_t height, size_t hkernelsize, size_t vkernelsize,
+ const double *hkernel, const double *vkernel)
+{
+ /* TODO Can we allow output==input ? */
+ if (vkernelsize > 1) {
+ vconvolute(output, input, output_rowsize, input_rowsize, width, height, vkernelsize, vkernel);
+ if (hkernelsize > 1)
+ hselfconvolute(output, output_rowsize, width, height, hkernelsize, hkernel);
+ } else if (hkernelsize > 1) {
+ vconvolute(output, input, output_rowsize, input_rowsize, width, height, hkernelsize, hkernel);
+ } else {
+ copyraster(output, input, output_rowsize, input_rowsize, width, height);
+ }
+}
+
+
+#else
+
+
+#define TOLERANCE 0.0001
+
+static int
+eq(double a, double b)
+{
+ double r = a - b;
+ return (r < 0 ? -r : r) < TOLERANCE;
+}
+
+int
+main(void)
+{
+ return 0; /* TODO add test */
+}
+
+
+#endif