/* -*- mode: c++; c-basic-offset: 3 -*-
 *
 * PANTHEON Project
 *
 * GREYC IMAGE
 * 6 Boulevard Maréchal Juin
 * F-14050 Caen Cedex France
 *
 * This file is free software. You can use it, distribute it
 * and/or modify it. However, the entire risk to the quality
 * and performance of this program is with you.
 *
 * Please email any bugs, comments, and/or additions to this file to:
 * pandore@greyc.ensicaen.fr
 * http://www.greyc.ensicaen.fr/EquipeImage/Pandore/
 */

/**
 * WAVEATOM transform
 * @authors
 *  Jalal Fadili
 * @date 2007-11-30
 *
 */

/*
 * @file fatom2sym_mex.cpp
 * @brief Forward transform of wave atom orthonormal basis
 */

#include <math.h>
#include <complex>
#include <iostream>
using namespace std;
#include "complexe.h"
using namespace pandore;
#include "mex.h"
#include "matrix.h"



#ifdef MAIN
#undef MAIN

#include "fatom1sym.cpp"

#endif



void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
{
  Img1dsf ims;
  Img1dsf imd;
  Float* input;
  Float* output;
  int m, n;
  char* pat;
  Short tp;
  
  if(nrhs!=3)
	 mexErrMsgTxt("3 inputs required");
  if(nlhs!=1)
	 mexErrMsgTxt("1 output required");
  input	= (Float*)mxGetData(prhs[0]);
  m 	= mxGetM(prhs[0]); 
  n 	= mxGetN(prhs[0]);
  pat	= mxArrayToString(prhs[1]);
  tp	= (Short)*(mxGetPr(prhs[2]));
  
  if(m > 1 && n > 1)
  	mexErrMsgTxt("Input data must be a vector");
	
  ims.New(m*n);
  memcpy(ims.Vector(),input,m*n*sizeof(Float));  
  Fatom1Sym(ims, imd, *pat, tp);
  plhs[0] = mxCreateNumericMatrix(m, n, mxSINGLE_CLASS, mxREAL);
  output = (Float*)mxGetData(plhs[0]);
  memcpy(output,imd.Vector(),m*n*sizeof(Float));
  
  return;
}
