]> hackdaworld.org Git - my-code/api.git/commitdiff
init fourier.* (will be changed)
authorhackbard <hackbard>
Sat, 18 Sep 2004 11:45:33 +0000 (11:45 +0000)
committerhackbard <hackbard>
Sat, 18 Sep 2004 11:45:33 +0000 (11:45 +0000)
fourier/fourier.c [new file with mode: 0644]
fourier/fourier.h [new file with mode: 0644]

diff --git a/fourier/fourier.c b/fourier/fourier.c
new file mode 100644 (file)
index 0000000..14878e2
--- /dev/null
@@ -0,0 +1,57 @@
+/* fourier.c -- fourier transformation api
+ *
+ * author: hackbard@hackdaworld.dyndns.org
+ *
+ */
+
+#include "fourier.h"
+
+int fourier_init(t_fourier *fourier,int outfd) {
+
+ fprintf(outfd,"[fourier] initializing fourier api ...\n");
+
+ fourier->outfd=outfd;
+ fourier->type=0;
+ fourier->dim=0;
+
+ return F_SUCCESS;
+}
+
+int fourier_set_datalen(t_fourier *fourier,int dim,int len) {
+
+  int i;
+
+  if(dim>MAX_DIM) {
+    fprintf(fourier->outfd,"[fourier] dimension %d not supported\n",dim);
+    return F_SET_DLEN_ERROR;
+  }
+
+  fourier->data_len[dim]=len;
+
+  return F_SUCCESS;
+}
+
+int fourier_malloc(t_fourier *fourier) {
+
+  int i;
+
+  if(fourier->dim==0) {
+    fprintf(fourier->outfd,"[fourier] dimension not specified\n");
+    return F_DIM_ERROR;
+  }
+  for(i=0;i<fourier->dim;i++) {
+    if(fourier->data_len[i]==0) {
+      fprintf(fourier->outfd,"[fourier] invalid data len for dim %d\n",i);
+      return F_DLEN_ERROR;
+    }
+  }
+
+  for(i=0;i<fourier->dim;i++) {
+    if((fourier->data[i]=(t_complex *)malloc(sizeof(t_complex)*fourier->data_len[i]))==NULL) {
+      fprintf(fourier->outfd,"[fourier] malloc for data dim %d failed\n",i);
+      return F_MALLOC_ERROR;
+    }
+  }
+
+  return F_SUCCESS;
+}
diff --git a/fourier/fourier.h b/fourier/fourier.h
new file mode 100644 (file)
index 0000000..5a8ddb3
--- /dev/null
@@ -0,0 +1,33 @@
+/* fourier.h -- fourier headers */
+
+#ifndef FOURIER_H
+#define FOURIER_H
+
+/* includes */
+#include <stdio.h>
+
+/* defines */
+#define F_SUCCESS 1
+#define F_ERROR -1
+#define F_DIM_ERROR -2
+#define F_DLEN_ERROR -3
+#define F_MALLOC_ERROR -4
+#define F_SET_DLEN_ERROR -5
+
+#define MAX_DIM 3
+
+/* fourier specific variables */
+typedef struct s_complex {
+  double r;
+  double i;
+} t_complex;
+
+typedef struct s_fourier {
+  int outfd;
+  unsigned char type;
+  int dim;
+  t_complex *data[MAX_DIM];
+  int data_len[MAX_DIM];
+} t_fourier;
+
+#endif