// Exposes a single function for computing SVDs.
// For interfacing via cython.

#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

// #define PRINT_DEBUGGING_OUTPUT
#define USE_SCALAR_IMPLEMENTATION
// #define USE_SSE_IMPLEMENTATION
// #define USE_AVX_IMPLEMENTATION

#define COMPUTE_V_AS_MATRIX
//#define COMPUTE_V_AS_QUATERNION
#define COMPUTE_U_AS_MATRIX
//#define COMPUTE_U_AS_QUATERNION


#include "Singular_Value_Decomposition_Preamble.hpp"

int svd_c(double* A, double* U, double* S, double* V) {

#include "Singular_Value_Decomposition_Kernel_Declarations.hpp"

  Sa11.f = A[0];
  Sa12.f = A[1];
  Sa13.f = A[2];
  Sa21.f = A[3];
  Sa22.f = A[4];
  Sa23.f = A[5];
  Sa31.f = A[6];
  Sa32.f = A[7];
  Sa33.f = A[8];

#include "Singular_Value_Decomposition_Main_Kernel_Body.hpp"

  U[0] = Su11.f;
  U[1] = Su12.f;
  U[2] = Su13.f;
  U[3] = Su21.f;
  U[4] = Su22.f;
  U[5] = Su23.f;
  U[6] = Su31.f;
  U[7] = Su32.f;
  U[8] = Su33.f;

  S[0] = Sa11.f;
  S[1] = Sa22.f;
  S[2] = Sa33.f;

  V[0] = Sv11.f;
  V[1] = Sv12.f;
  V[2] = Sv13.f;
  V[3] = Sv21.f;
  V[4] = Sv22.f;
  V[5] = Sv23.f;
  V[6] = Sv31.f;
  V[7] = Sv32.f;
  V[8] = Sv33.f;

  return 0;

}

