#include <iostream>
#include <armadillo>
#include "matrix_utils.h"

using namespace arma;

void ind2sub(arma::uvec &indices, int m, int n, arma::uvec &subscripts1, arma::uvec &subscripts2)
{
  for(int k = 0; k < indices.n_rows; k++)
  {
    subscripts1(k) = (uword)((indices(k) + 1) - 1) % m;
    subscripts2(k) = (uword)floor(((indices(k) + 1) - 1) / m);
  }
}
  
void sub2ind(arma::uvec &subscripts1, arma::uvec &subscripts2, int m, int n, arma::uvec &indices)
{
  for(int k = 0; k < subscripts1.n_rows; k++)
  {
    indices(k) = ((subscripts2(k) + 1) - 1) * m + ((subscripts1(k) + 1) - 1);
  }
}

stdvec arma_to_std_vec(arma::vec &arma_vec)
{
  stdvec std_vec = conv_to<stdvec>::from(arma_vec);
}
