update options for pip installation in README.md
[liba.git] / src / tf.c
blob1a396aa92094f2aa317d0f5dc505c43d1511a19c
1 #include "a/tf.h"
3 void a_tf_set_num(a_tf *ctx, unsigned int num_n, a_float const *num_p, a_float *input)
5 ctx->num_p = num_p;
6 ctx->num_n = num_n;
7 ctx->input = input;
8 a_zero(ctx->input, sizeof(a_float) * ctx->num_n);
11 void a_tf_set_den(a_tf *ctx, unsigned int den_n, a_float const *den_p, a_float *output)
13 ctx->den_p = den_p;
14 ctx->den_n = den_n;
15 ctx->output = output;
16 a_zero(ctx->output, sizeof(a_float) * ctx->den_n);
19 void a_tf_init(a_tf *ctx,
20 unsigned int num_n, a_float const *num_p, a_float *input,
21 unsigned int den_n, a_float const *den_p, a_float *output)
23 a_tf_set_num(ctx, num_n, num_p, input);
24 a_tf_set_den(ctx, den_n, den_p, output);
27 a_float a_tf_iter(a_tf const *ctx, a_float x)
29 a_float y = 0;
30 a_float_push(ctx->input, ctx->num_n, &x, 1);
31 for (unsigned int i = 0; i != ctx->num_n; ++i)
33 y += ctx->num_p[i] * ctx->input[i];
35 for (unsigned int i = 0; i != ctx->den_n; ++i)
37 y -= ctx->den_p[i] * ctx->output[i];
39 a_float_push(ctx->output, ctx->den_n, &y, 1);
40 return y;
43 void a_tf_zero(a_tf const *ctx)
45 a_zero(ctx->input, sizeof(a_float) * ctx->num_n);
46 a_zero(ctx->output, sizeof(a_float) * ctx->den_n);