#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Engine.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TLabel *Score[n];
const int n=3;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double *b,a[9]={1,4,7,2,5,8,3,6,9};
mxArray *Ani,*About,*Sv;
Engine *ep;
Ani=mxCreateDoubleMatrix(3,3,mxREAL);
mxSetClassName(Ani,"z");
memcpy((char*)mxGetPr(Ani),(char*)a,9*sizeof(double);
if(ep=engOpen(NULL))
{
engEvalString(ep,"[x,y]=eig(z);eigenvalue=diag(y);sv=x(:,1)/sum(x(:,1));");
SV=engGetVariable(ep,"sv");
  b=mxGetPr(SV);
  memcpy((char*)mxGetPr(About),(char*)b,3*sizeof(double));
  engClose(ep);
  mxDestroyArray(SV);
  }
  else ShowMessage("Can't Open The Engine!");
for(int i=0;i<3;i++)
  {
  Score[i]=new TLable(this);
  Score[i]->Caption=FloatToStr(About[i]);
  Score[i]->Height=13;
  Score[i]->Left=96;
  Score[i]->Top=56+20*i;
  Score[i]->Visible=true;
  }



}
//-------------------------------------------