//---------------------------------------------------------------------------

#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
#include <math.h>
#include <complex.h>
#include <ExtCtrls.hpp>
#include <Chart.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <Series.hpp>
#include <TeeFunci.hpp>


using namespace std;
#define TINY 1.0e-20          // pomocne pro LU a SOLVE
//---------------------------------------------------------------------------
//typedef struct FCOMPLEX {float r,i;} fcomplex;
typedef struct FCOMPLEX {double r,i;} fcomplex;

fcomplex Cadd(fcomplex a, fcomplex b)
//secte komplexni cisla a a b
{
	fcomplex c;
	c.r=a.r+b.r;
	c.i=a.i+b.i;
	return c;
}

fcomplex Csub(fcomplex a, fcomplex b)
//odecte komplexni cislo b od a
{
	fcomplex c;
	c.r=a.r-b.r;
	c.i=a.i-b.i;
	return c;
}


fcomplex Cmul(fcomplex a, fcomplex b)
//vynasobi komplexni cisla a a b
{
       	/*fcomplex c;
	c.r=a.r*b.r-a.i*b.i;
	c.i=a.i*b.r+a.r*b.i;
	return c;*/
        fcomplex c;
        complex<double> d(a.r,a.i);
        complex<double> e(b.r,b.i);
        complex<double> f;
        f = d*e;
        c.r = f.real();
        c.i = f.imag();
	return c;
}

fcomplex Complex(double re, double im)
//vytvoří komplexni cislo c z realne a imaginarni slozky
{
	fcomplex c;
	c.r=re;
	c.i=im;
	return c;
}

fcomplex Conjg(fcomplex z)

{
	fcomplex c;
	c.r = z.r;
	c.i = -z.i;
	return c;
}

fcomplex Cdiv(fcomplex a, fcomplex b)
{
	/*fcomplex c;
	double r,den;
	if (fabs(b.r) >= fabs(b.i)) {
		r=b.i/b.r;
		den=b.r+r*b.i;
		c.r=(a.r+a.i*r)/den;
		c.i=(a.i-a.r*r)/den;
	} else {
		r=b.r/b.i;
		den=b.i+r*b.r;
		c.r=(a.r*r+a.i)/den;
		c.i=(a.i*r-a.r)/den;
	}
	return c;*/

        fcomplex c;
        complex<double> d(a.r,a.i);
        complex<double> e(b.r,b.i);
        complex<double> f;
        f = d/e;
        c.r = f.real();
        c.i = f.imag();
	return c;
}

double Cabs(fcomplex z)
{
	/*double x,y,ans,temp;
        x=z.r;
   	y=z.i;
   	if (x == 0.0)
		ans=(double) fabs(y);
	else if (y == 0.0)
		ans=(double) fabs(x);
	else if ((double) fabs(x)>=(double) fabs(y)) {
		temp=y/x;
		ans=((double)fabs(x))*sqrt(1.0+temp*temp);
	} else {
		temp=x/y;
		ans=((double)fabs(y))*sqrt(1.0+temp*temp);
	}
	return ans; */

        complex<double> a(z.r,z.i);
        return abs(a);
}

fcomplex Csqrt(fcomplex z)
{
	/*fcomplex c;
	float x,y,w,r;
	if ((z.r == 0.0) && (z.i == 0.0)) {
		c.r=0.0;
		c.i=0.0;
		return c;
	} else {
		x=fabs(z.r);
		y=fabs(z.i);
		if (x >= y) {
			r=y/x;
			w=sqrt(x)*sqrt(0.5*(1.0+sqrt(1.0+r*r)));
		} else {
			r=x/y;
			w=sqrt(y)*sqrt(0.5*(r+sqrt(1.0+r*r)));
		}
		if (z.r >= 0.0) {
			c.r=w;
			c.i=z.i/(2.0*w);
		} else {
			c.i=(z.i >= 0) ? w : -w;
			c.r=z.i/(2.0*c.i);
		}
		return c;
	} */
        fcomplex c;
        complex<double> d(z.r,z.i);
        complex<double> f;
        f = sqrt(d);
        c.r = f.real();
        c.i = f.imag();
	return c;
}

fcomplex RCadd(float x, fcomplex a)
//secte x s komplexnim cislem a

{
	fcomplex c;
	c.r=(double) x+a.r;
	c.i=a.i;
	return c;
}

fcomplex RCmul(float x, fcomplex a)
{
	fcomplex c;
	c.r=x*a.r;
	c.i=x*a.i;
	return c;
}

fcomplex RCDiv(float a, fcomplex b)
//vydeli realne cislo a komplexnim cislem b a vysledek uklada do c
{
        double pom;
        fcomplex c;
        pom = b.r*b.r+b.i*b.i;
        c.r = a*b.r/pom;
        c.i = -a*b.i/pom;
        return c;
}

fcomplex onedivC(fcomplex a)
//pocita hodnotu 1/cislo a uklada a vysledek uklada do c
{
        double pom;
        fcomplex c;
        pom = a.r*a.r+a.i*a.i;
        c.r = a.r/pom;
        c.i = -a.i/pom;
        return c;
}

//---------------------------------------------------------------------------
class TComplexArray {
  private:
    TList* FList;
    int FRowCount;
    int FColCount;
  public:
    TComplexArray(int AColCount, int ARowCount);
    TComplexArray(TComplexArray* MatAA, TComplexArray* MatBA, TComplexArray* MatAB, TComplexArray* MatBB);
    ~TComplexArray();
    int GetRowCount();
    int GetColCount();
    TList* GetColumn(int AColIndex);
    fcomplex GetItem(int AColIndex, int ARowIndex);
    void SetItem(int AColIndex, int ARowIndex, fcomplex NewItem);
    void SetItemReIm(int AColIndex, int ARowIndex, double compRe, double compIm);

    void SetItemSum(int AColIndex, int ARowIndex, fcomplex NewItem);
    void SetItemSumReIm(int AColIndex, int ARowIndex, double compRe, double compIm);

    void NullAll();
    void NullCol(int AColIndex);
    void NullRow(int ARowIndex);
    void OnesAll();
    void OnesDiag();

    void MulNum(fcomplex AValue);
    void DivNum(fcomplex AValue);

    int isNull();

    fcomplex Trace();

    int PlusMat(TComplexArray* AMatrix);

    TComplexArray* MulMat(TComplexArray* AMatrix);
    int MulMatMat(TComplexArray* AMatrixA, TComplexArray* AMatrixB);
    void Luc(TComplexArray* AMatrix,TComplexArray* indx, int &d);
    void Solvec(TComplexArray* AMatrix,TComplexArray* indx,TComplexArray* b);

    void Switch();

    TComplexArray* SmallMatrix();

    void SetNullRowAndValueReIm(int AColIndex, int ARowIndex, fcomplex AValue);
    void SetNullRowAndValueReIm(int AColIndex, int ARowIndex, double AValueRe, double AValueIm);

};

TComplexArray::TComplexArray(int AColCount, int ARowCount){
  FRowCount = ARowCount;
  FColCount = AColCount;
  FList = new TList();

  for(int i = 0; i < FColCount; i++) {
    TList* pItem = new TList();
    FList->Add(pItem);
    for(int j = 0; j < FRowCount; j++) {
      fcomplex* pItemComplex = new fcomplex;
      pItemComplex->r = 0.0;
      pItemComplex->i = 0.0;
      pItem->Add(pItemComplex);
    }
  }
};

int GetMaxTwo(int ANumA,  int ANumB) {
  int Result = ANumA;
  if (Result < ANumB)
    Result = ANumB;
  return Result;
}

//Y1 C12
//C21 Y2

//ctverec Y1 a Y2
//3x3 , 2x3
//3x2 , 2x2

//MatAA, MatBA
//MatAB, MatBB

TComplexArray::TComplexArray(TComplexArray* MatAA, TComplexArray* MatBA, TComplexArray* MatAB, TComplexArray* MatBB) {
  int MaxColA = GetMaxTwo(MatAA->GetColCount(), MatAB->GetColCount());
  int MaxColB = GetMaxTwo(MatBA->GetColCount(), MatBB->GetColCount());
  int MaxRowA = GetMaxTwo(MatAA->GetRowCount(), MatBA->GetRowCount());
  int MaxRowB = GetMaxTwo(MatAB->GetRowCount(), MatBB->GetRowCount());

  //GetColCount(), GetRowCount
  FRowCount = MaxRowA + MaxRowB;
  FColCount = MaxColA + MaxColB;
  FList = new TList();

  for(int i = 0; i < FColCount; i++) {
    TList* pItem = new TList();
    FList->Add(pItem);
    for(int j = 0; j < FRowCount; j++) {
      fcomplex* pItemComplex = new fcomplex;
      pItemComplex->r = 0.0;
      pItemComplex->i = 0.0;
      pItem->Add(pItemComplex);
    }
  }

  for(int i = 0; i < MatAA->GetRowCount(); i++) {
    for(int j = 0; j < MatAA->GetColCount(); j++) {
      fcomplex fc = MatAA->GetItem(j,i);
      this->SetItem(j, i, fc);
    }
  }

  for(int i = 0; i < MatBA->GetRowCount(); i++) {
    for(int j = 0; j < MatBA->GetColCount(); j++) {
      fcomplex fc = MatBA->GetItem(j,i);
      this->SetItem(MaxColA + j, i, fc);
    }
  }

  for(int i = 0; i < MatAB->GetRowCount(); i++) {
    for(int j = 0; j < MatAB->GetColCount(); j++) {
      fcomplex fc = MatAB->GetItem(j,i);
      this->SetItem(j, MaxRowA + i, fc);
    }
  }

  for(int i = 0; i < MatBB->GetRowCount(); i++) {
    for(int j = 0; j < MatBB->GetColCount(); j++) {
      fcomplex fc = MatBB->GetItem(j,i);
      this->SetItem(MaxColA + j, MaxRowA + i, fc);
    }
  }

};

TComplexArray::~TComplexArray(){
  for(int i = 0; i < FList->Count; i++) {
    TList* tmpSL = (TList*) FList->operator [](i);
    for(int j = 0; j < FRowCount; j++) {
      fcomplex* pItemComplex = (fcomplex*) tmpSL->operator [](j);
      delete pItemComplex;
    }
    delete tmpSL;
  }
  delete FList;
};

void TComplexArray::Switch() {

  TList* NewList = new TList();

  for(int i = 0; i < FRowCount; i++) {
    TList* pItem = new TList();
    NewList->Add(pItem);
    for(int j = 0; j < FColCount; j++) {
      fcomplex* pItemComplex = new fcomplex;
      pItemComplex->r = 0.0;
      pItemComplex->i = 0.0;
      pItem->Add(pItemComplex);
    }
  }

  for(int i = 0; i < FColCount; i++) {
    TList* tmpSL = (TList*) FList->operator [](i);
    for(int j = 0; j < FRowCount; j++) {
      fcomplex* pItemComplex = (fcomplex*) tmpSL->operator [](j);

      TList* tmpSlaveList = (TList*) NewList->operator [](j);
      fcomplex* pNewItemComplex = (fcomplex*) tmpSlaveList->operator [](i);

      pNewItemComplex->r = pItemComplex->r;
      pNewItemComplex->i = pItemComplex->i;
    }
  }

  for(int i = 0; i < FList->Count; i++) {
    TList* tmpSL = (TList*) FList->operator [](i);
    for(int j = 0; j < FRowCount; j++) {
      fcomplex* pItemComplex = (fcomplex*) tmpSL->operator [](j);
      delete pItemComplex;
    }
    delete tmpSL;
  }
  delete FList;
  FList = NewList;

  int tmpCount = FRowCount;
  FRowCount = FColCount;
  FColCount = tmpCount;

};


int TComplexArray::GetRowCount() {
    return FRowCount;
};

int TComplexArray::GetColCount() {
    return FColCount;
};

TList* TComplexArray::GetColumn(int AColIndex){
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    return pItem;
  } else
    return 0;
};

fcomplex TComplexArray::GetItem(int AColIndex, int ARowIndex) {
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      return *((fcomplex*) pItem->operator [](ARowIndex));
    } else
      return Complex(0.0,0.0);
  } else
    return Complex(0.0,0.0);
};

void TComplexArray::SetItem(int AColIndex, int ARowIndex, fcomplex NewItem) {
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      fcomplex* pItemComplex = (fcomplex*) pItem->operator [](ARowIndex);
      pItemComplex->r = NewItem.r;
      pItemComplex->i = NewItem.i;
    }
  }
};

void TComplexArray::SetItemReIm(int AColIndex, int ARowIndex, double compRe, double compIm) {
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      fcomplex* pItemComplex = (fcomplex*) pItem->operator [](ARowIndex);
      pItemComplex->r = compRe;
      pItemComplex->i = compIm;
    }
  }
};

void TComplexArray::SetItemSum(int AColIndex, int ARowIndex, fcomplex NewItem) {
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      fcomplex* pItemComplex = (fcomplex*) pItem->operator [](ARowIndex);
      pItemComplex->r = pItemComplex->r + NewItem.r;
      pItemComplex->i = pItemComplex->i + NewItem.i;
    }
  }
};

void TComplexArray::SetItemSumReIm(int AColIndex, int ARowIndex, double compRe, double compIm) {
  if (AColIndex < FColCount) {
    TList* pItem = (TList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      fcomplex* pItemComplex = (fcomplex*) pItem->operator [](ARowIndex);
      pItemComplex->r = pItemComplex->r + compRe;
      pItemComplex->i = pItemComplex->i + compIm;
    }
  }
};

void TComplexArray::NullAll() {
  for(int i = 0; i < GetRowCount(); i++) {
    for(int j = 0; j < GetColCount(); j++) {
      this->SetItemReIm(j, i, 0.0, 0.0);
    }
  }
};

void TComplexArray::NullCol(int AColIndex) {
  for(int i = 0; i < GetRowCount(); i++) {
    this->SetItemReIm(AColIndex, i, 0.0, 0.0);
  }
};

void TComplexArray::NullRow(int ARowIndex) {
  for(int j = 0; j < GetColCount(); j++) {
    this->SetItemReIm(j, ARowIndex, 0.0, 0.0);
  }
};

void TComplexArray::OnesAll() {
  for(int i = 0; i < GetRowCount(); i++) {
    for(int j = 0; j < GetColCount(); j++) {
      this->SetItemReIm(j, i, 1.0, 0.0);
    }
  }
};

void TComplexArray::OnesDiag() {
  NullAll();
  int np = GetRowCount();
  if(GetColCount() < np)
    np = GetColCount();
  for(int i = 0; i < np; i++) {
      this->SetItemReIm(i, i, 1.0, 0.0);
  }
};

void TComplexArray::MulNum(fcomplex AValue) {
  for(int i = 0; i < GetRowCount(); i++) {
    for(int j = 0; j < GetColCount(); j++) {
      fcomplex fc = this->GetItem(j,i);
      fc = Cmul(fc, AValue);
      this->SetItem(j, i, fc);
    }
  }
};

void TComplexArray::DivNum(fcomplex AValue) {
  for(int i = 0; i < this->GetRowCount(); i++) {
    for(int j = 0; j < this->GetColCount(); j++) {
      fcomplex fc = this->GetItem(j,i);
      fc = Cdiv(fc, AValue);
      this->SetItem(j, i, fc);
    }
  }
};

int TComplexArray::isNull(){
  int Result = 1;
  for(int i = 0; i < this->GetRowCount(); i++) {
    for(int j = 0; j < this->GetColCount(); j++) {
      fcomplex fc = this->GetItem(j,i);
      if(fc.r != 0)
        Result =0;
      if(fc.i != 0)
        Result =0;
    }
  }
  return Result;
};


fcomplex TComplexArray::Trace() {
  fcomplex sum = Complex(0.0,0.0);
  int np = GetRowCount();
  if(GetColCount() < np)
    np = GetColCount();
  for(int i = 0; i < np; i++) {
      sum = Cadd(sum, this->GetItem(i,i));
  }
  return sum;
};

int TComplexArray::PlusMat(TComplexArray* AMatrix) {
  int Result = 0;
  if((this->GetColCount() == AMatrix->GetColCount()) && (this->GetRowCount() == AMatrix->GetRowCount())) {
    for(int k = 0; k < this->GetColCount(); k++) {
      for(int i = 0; i < this->GetRowCount(); i++) {
        this->SetItemSum(k,i,AMatrix->GetItem(k,i));
      }
    }
  } else {
    // error
    Result = 1;
    ShowMessage("Error: Spatny rozmer matic pri scitani (TComplexArray::PlusMat)");
  }
  return Result;
};




TComplexArray* TComplexArray::MulMat(TComplexArray* AMatrix) {
  TComplexArray* ResultMatrix;
  if(this->GetColCount() == AMatrix->GetRowCount()) {
    ResultMatrix = new TComplexArray(AMatrix->GetColCount(), this->GetRowCount());
    for(int k = 0; k < AMatrix->GetColCount(); k++) {
      for(int i = 0; i < this->GetRowCount(); i++) {
        fcomplex sum = Complex(0.0,0.0);
        for(int j = 0; j < this->GetColCount(); j++) {
          fcomplex fcA = this->GetItem(j,i);
          fcomplex fcB = AMatrix->GetItem(k,j);
          sum = Cadd(sum, Cmul(fcA, fcB));
        }
        ResultMatrix->SetItem(k,i,sum);
      }
    }
  } else {
    // error
    ResultMatrix = new TComplexArray(1, 1);
    ResultMatrix->SetItemReIm(0,0,1.0,1.0);
    ShowMessage("Error: Spatny rozmer matic pri nasobeni (TComplexArray::MulMat)" + IntToStr(this->GetColCount()) + ", " + IntToStr(AMatrix->GetRowCount()));
  }
  return ResultMatrix;
};


int TComplexArray::MulMatMat(TComplexArray* AMatrixA, TComplexArray* AMatrixB) {
  int Result = 0;
  if(AMatrixA->GetColCount() == AMatrixB->GetRowCount()) {
    for(int k = 0; k < AMatrixB->GetColCount(); k++) {
      for(int i = 0; i < AMatrixA->GetRowCount(); i++) {
        fcomplex sum = Complex(0.0,0.0);
        for(int j = 0; j < AMatrixA->GetColCount(); j++) {
          fcomplex fcA = AMatrixA->GetItem(j,i);
          fcomplex fcB = AMatrixB->GetItem(k,j);
          sum = Cadd(sum, Cmul(fcA, fcB));
        }
        this->SetItem(k,i,sum);
      }
    }
  } else {
    // error
    Result = 1;
    ShowMessage("Error: Spatny rozmer matic pri nasobeni (TComplexArray::MulMatMat)");
  }
  return Result;
};



void TComplexArray::Luc(TComplexArray* AMatrix,TComplexArray* indx, int &d)
{
  int i, imax, j, k;
  fcomplex sum, sumtemp, dum;
  long double temp; // big
  long double big;

  int n = AMatrix->GetColCount();
  TComplexArray* vv = new TComplexArray(n, 1); //vek
  d=1;imax=0;

  for (i=0;i<n;i++)
  {
    big=0.0;
    for(j=0;j<n;j++)
    {
      temp=Cabs(AMatrix->GetItem(j,i));
      if ( temp > big )
        big = temp;
    }
    if (big==0.0) ShowMessage("pause in LU - singular matrix");
    vv->SetItemReIm(i,0,1.0/big,0.0);
  }

  for (j=0;j<n;j++)
  {
    for (i=0;i<j;i++)
    {
      sum = AMatrix->GetItem(j,i);
      for (k=0;k<i;k++)
      {
        sumtemp = Cmul(AMatrix->GetItem(k,i),AMatrix->GetItem(j,k));
        sum = Csub(sum,sumtemp);
      }
      AMatrix->SetItem(j,i,sum);
    }
    big = 0.0;
    for(i=j;i<n;i++)
    {
      sum = AMatrix->GetItem(j,i);
      for (k=0;k<j;k++)
      {
        sumtemp = Cmul(AMatrix->GetItem(k,i),AMatrix->GetItem(j,k));
        sum = Csub(sum,sumtemp);
      }
      AMatrix->SetItem(j,i,sum);
      dum.r = vv->GetItem(i,0).r * Cabs(sum);
      dum.i = 0.0;
      if (dum.r >= big)  // >= podle NR; > podle Biolka
      {
        big = Cabs(dum);
        imax = i;
      }
    }

    if (j!=imax)
    {
     for (k=0;k<n;k++)
      {
        dum = AMatrix->GetItem(k,imax);
        AMatrix->SetItem(k,imax,AMatrix->GetItem(k,j));
        AMatrix->SetItem(k,j,dum);
      }
      d=-d;
      vv->SetItem(imax,0,vv->GetItem(j,0));
    }

    indx->SetItemReIm(j,0,imax,0);
    if ((Cabs(AMatrix->GetItem(j,j))) ==0.0)
      AMatrix->SetItemReIm(j,j,TINY,AMatrix->GetItem(j,j).i);  //TINY představuje "nulovou" hodnotu v matici
    if (j!=(n-1))
    {
      dum = onedivC(AMatrix->GetItem(j,j));
      for (i=j+1;i<n;i++)
        AMatrix->SetItem(j,i, Cmul(AMatrix->GetItem(j,i), dum));
    }
  }

  /*for (i=0;i<n;i++)
    {
      ShowMessage(1/vv->GetItem(i,0).r);
    }*/

  delete vv;
};

void TComplexArray::Solvec(TComplexArray* AMatrix,TComplexArray* indx,TComplexArray* b)
{
  int i,ii=0,ip,j;
  fcomplex sum, sumtemp;
  int n = AMatrix->GetColCount();

  for (i=0;i<n;i++)
  {
    ip=indx->GetItem(i,0).r;
    sum=b->GetItem(ip,0);
    b->SetItem(ip,0,b->GetItem(i,0));
    if (ii != 0 )
    {
      for (j=(ii-1);j<=(i-1);j++)
      {
        sumtemp = Cmul(AMatrix->GetItem(j,i),b->GetItem(j,0));
        sum = Csub(sum,sumtemp);
      }
    }
    else if (Cabs(sum)!=0.0) ii=i+1;
    b->SetItem(i,0,sum);
  }
  for (i=(n-1);i>=0;i--)
  {
    sum=b->GetItem(i,0);
    //if (i<(n-1))       // podle Biolka
    for (j=i+1;j<n;j++)
    {
      sumtemp = Cmul(AMatrix->GetItem(j,i),b->GetItem(j,0));
      sum = Csub(sum,sumtemp);
    }
    b->SetItem(i,0,Cdiv(sum,AMatrix->GetItem(i,i)));
  }
}

TComplexArray* TComplexArray::SmallMatrix()
{
  // Odřízne index 0 tudiž prvni sloupec a řádek
  TComplexArray* Result = new TComplexArray(this->GetColCount()-1, this->GetRowCount()-1);
  for(int i = 0; i < Result->GetRowCount(); i++) {
    for(int j = 0; j < Result->GetColCount(); j++) {
      fcomplex fc = this->GetItem(j+1, i+1);
      Result->SetItemReIm(j, i, fc.r, fc.i);
    }
  }
  return Result;
}

void TComplexArray::SetNullRowAndValueReIm(int AColIndex, int ARowIndex, fcomplex AValue){
  for(int j = 0; j < this->GetColCount(); j++) {
    if(AColIndex == j)
      this->SetItem(j,ARowIndex, AValue);
    else
      this->SetItem(j,ARowIndex, Complex(0.0, 0.0));
  }
}

void TComplexArray::SetNullRowAndValueReIm(int AColIndex, int ARowIndex, double AValueRe, double AValueIm){
  SetNullRowAndValueReIm(AColIndex, ARowIndex, Complex(AValueRe, AValueIm));
}


//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class TVectorComArray {    // faddejev
  private:
    TList* FList;
    int FCount;
    int FRowCount;
    int FColCount;
  public:
    TVectorComArray(int ACount, int AColCount, int ARowCount);
    ~TVectorComArray();
    int GetCount();
    int GetRowCount();
    int GetColCount();

    TComplexArray* GetMatrix(int AIndex);

    TComplexArray* GetMatrixCopy(int AIndex);
    void SetMatrixCopy(int AIndex, TComplexArray* ANewMatrix);

    TComplexArray* GetVectorFromAll(int AColIndex, int ARowIndex);

    fcomplex GetItem(int AIndex, int AColIndex, int ARowIndex);
    void SetItem(int AIndex, int AColIndex, int ARowIndex, fcomplex NewItem);
    void SetItemReIm(int AIndex, int AColIndex, int ARowIndex, double compRe, double compIm);
};

TVectorComArray::TVectorComArray(int ACount, int AColCount, int ARowCount){
  FCount = ACount;
  FRowCount = ARowCount;
  FColCount = AColCount;
  FList = new TList();
  for(int i = 0; i < FCount; i++) {
    //TList* pItem = new TList();
    TComplexArray* pItem = new TComplexArray(FColCount, FRowCount);
    FList->Add(pItem);
  }
};

TVectorComArray::~TVectorComArray(){
  for(int i = 0; i < FList->Count; i++) {
    TComplexArray* tmpItem = (TComplexArray*) FList->operator [](i);
    delete tmpItem;
  }
  delete FList;
};

int TVectorComArray::GetCount() {
  return FCount;
};

int TVectorComArray::GetRowCount() {
  return FRowCount;
};

int TVectorComArray::GetColCount() {
  return FColCount;
};

// koukat a nesahat
TComplexArray* TVectorComArray::GetMatrix(int AIndex) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AIndex);
    return pItem;
  } else
    return 0;
};

// sahat ale smazat po sobě - tvoje kopie !!!!!!!
TComplexArray* TVectorComArray::GetMatrixCopy(int AIndex) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AIndex);
    TComplexArray* newItem = new TComplexArray(pItem->GetColCount(), pItem->GetRowCount());
    for(int k = 0; k < pItem->GetColCount(); k++) {
      for(int i = 0; i < pItem->GetRowCount(); i++) {
        newItem->SetItem(k,i,pItem->GetItem(k,i));
      }
    }
    return newItem;
  } else
    return 0;
};

void TVectorComArray::SetMatrixCopy(int AIndex, TComplexArray* ANewMatrix) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AIndex);
    if ((ANewMatrix->GetColCount() == pItem->GetColCount()) && (ANewMatrix->GetRowCount() == pItem->GetRowCount())) {
      for(int k = 0; k < pItem->GetColCount(); k++) {
        for(int i = 0; i < pItem->GetRowCount(); i++) {
          pItem->SetItem(k,i,ANewMatrix->GetItem(k,i));
        }
      }
     } else
       ShowMessage("Error: TVectorComArray::SetMatrixCopy - kopirovana matice ma nevyhovujici rozmer");
  } else
    ShowMessage("Error: TVectorComArray::SetMatrixCopy - index mimo rozsah vektoru");
};

TComplexArray* TVectorComArray::GetVectorFromAll(int AColIndex, int ARowIndex)
{
  int count = this->GetCount();
  TComplexArray* ResultVector = new TComplexArray(count,1);
  for(int i = 0; i < count; i++)
  {
    ResultVector->SetItem(i, 1, this->GetItem(i,AColIndex, ARowIndex));
  }
  return ResultVector;
};

fcomplex TVectorComArray::GetItem(int AIndex, int AColIndex, int ARowIndex) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AIndex);
    return pItem->GetItem(AColIndex, ARowIndex);
  } else
    return Complex(0.0,0.0);
};

void TVectorComArray::SetItem(int AIndex, int AColIndex, int ARowIndex, fcomplex NewItem) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AIndex);
    pItem->SetItem(AColIndex, ARowIndex, NewItem);
  }
};

void TVectorComArray::SetItemReIm(int AIndex, int AColIndex, int ARowIndex, double compRe, double compIm) {
  if (AIndex < FCount) {
    TComplexArray* pItem = (TComplexArray*) FList->operator [](AColIndex);
    pItem->SetItemReIm(AColIndex, ARowIndex, compRe, compIm);
  }
};


//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------



class TStringArray {     /// semisymbolická analýza
  private:
    TList* FList;
    int FRowCount;
    int FColCount;
  public:
    TStringArray(int AColCount, int ARowCount);
    ~TStringArray();
    int GetRowCount();
    int GetColCount();
    TStringList* GetColumn(int AColIndex);
    AnsiString GetItem(int AColIndex, int ARowIndex);
    void SetItem(int AColIndex, int ARowIndex, AnsiString NewItem);
};

TStringArray::TStringArray(int AColCount, int ARowCount){
  FRowCount = ARowCount;
  FColCount = AColCount;
  FList = new TList();

  for(int i = 0; i < FColCount; i++) {
    TStringList* pItem = new TStringList();
    FList->Add(pItem);
    for(int j = 0; j < FRowCount; j++) {
      pItem->Add("");
    }
  }
};
TStringArray::~TStringArray(){
  for(int i = 0; i < FList->Count; i++) {
    TStringList* tmpSL = (TStringList*) FList->operator [](i);
    delete tmpSL;
  }
  delete FList;
};

int TStringArray::GetRowCount() {
  return FRowCount;
};

int TStringArray::GetColCount() {
  return FColCount;
};

TStringList* TStringArray::GetColumn(int AColIndex){
  if (AColIndex < FColCount) {
    TStringList* pItem = (TStringList*) FList->operator [](AColIndex);
    return pItem;
  } else
    return 0;
};

AnsiString TStringArray::GetItem(int AColIndex, int ARowIndex) {
  if (AColIndex < FColCount) {
    TStringList* pItem = (TStringList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      return pItem->operator [](ARowIndex);
    } else
      return "";
  } else
    return "";
};

void TStringArray::SetItem(int AColIndex, int ARowIndex, AnsiString NewItem) {
  if (AColIndex < FColCount) {
    TStringList* pItem = (TStringList*) FList->operator [](AColIndex);
    if (ARowIndex < FRowCount) {
      pItem->Strings[ARowIndex] = NewItem;
    }
  }
};

//---------------------------------------------------------------------------

typedef struct TEleNodeItem {   // datová struktura uchocvává info o uzlech
  int ID;
  ShortString Name;
  int ModAU;
  int ModAI;
  int ModBU;
  int ModBI;
} TFEleNodeItem;

class TEleNodes {
  private:
    TList* FList;
    int FMaxID;
  public:
    TEleNodes();
    ~TEleNodes();
    int Count(void);
    int Add(TEleNodeItem Item);
    int CompareAdd(ShortString Name);
    TEleNodeItem GetItem(int Index);
    void SetItem(int Index, TEleNodeItem);
    int IndexOfID(int Value);
    int IndexOfName(ShortString AName);
};

TEleNodes::TEleNodes()
{
  FList = new TList();
  FMaxID = 0;
};
TEleNodes::~TEleNodes()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TEleNodes::Count(void)
{
  return FList->Count;
};
int TEleNodes::Add(TEleNodeItem Item)
{
   TEleNodeItem* pItem = (TEleNodeItem*) malloc(sizeof(TEleNodeItem));
   *pItem = Item;
   if (Item.ID > FMaxID)
     FMaxID = Item.ID;
   return FList->Add(pItem);
};
int TEleNodes::CompareAdd(ShortString Name)
{
  int i = 0;
  int run = 1;
  int ID = 0;
  while ((i < Count())&&(run)){
    TEleNodeItem Item = GetItem(i);
    if (CompareStr(Item.Name, Name) == 0) {
      run = 0;
      ID = Item.ID;
    }
    i++;
  }

  if (run) {
    TEleNodeItem Item;
    Item.ID = FMaxID + 1;
    Item.Name = Name;
    Item.ModAU = Item.ID;
    Item.ModAI = Item.ID;
    Item.ModBU = Item.ID;
    Item.ModBI = Item.ID;
    Add(Item);
    return Item.ID;
  } else {
    return ID;
  }
};
TEleNodeItem TEleNodes::GetItem(int Index)
{
  return *((TEleNodeItem*) FList->operator [](Index));
};
void TEleNodes::SetItem(int Index, TEleNodeItem Item)
{
  *((TEleNodeItem*) FList->operator [](Index)) = Item;
};
int TEleNodes::IndexOfID(int Value)
{
  int i = 0;
  int run = 1;
  int Index = -1;
  while ((i < Count())&&(run)) {
    TEleNodeItem Item = GetItem(i);
    if (Item.ID == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return -1;
  else
    return Index;
};
int TEleNodes::IndexOfName(ShortString AName)
{
  int i = 0;
  int run = 1;
  int Index = -1;
  while ((i < Count())&&(run)) {
    TEleNodeItem Item = GetItem(i);
    if (CompareStr(Item.Name, AName) == 0) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return -1;
  else
    return Index;
};

//---------------------------------------------------------------------------

typedef struct TElePartItem {   // Odpory a kondenzátory
  ShortString Name;
  ShortString Value;
  int Input;
  int Output;
} TFElePartItem;

class TElePart {
  private:
    TList* FList;
  public:
    TElePart();
    ~TElePart();
    int Count(void);
    int Add(TElePartItem Item);
    TElePartItem GetItem(int Index);
    void SetItem(int Index, TElePartItem Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TElePart::TElePart()
{
  FList = new TList();
};
TElePart::~TElePart()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TElePart::Count(void)
{
  return FList->Count;
};
int TElePart::Add(TElePartItem Item)
{
   TElePartItem* pItem = (TElePartItem*) malloc(sizeof(TElePartItem));
   *pItem = Item;
   return FList->Add(pItem);
   //FIntList = (int*) malloc(sizeof(int)*FCount);
   //free(FIntList);
   //#include <alloc.h>
};
TElePartItem TElePart::GetItem(int Index)
{
  return *((TElePartItem*) FList->operator [](Index));
};
void TElePart::SetItem(int Index, TElePartItem Item)
{
  *((TElePartItem*) FList->operator [](Index)) = Item;
};
int TElePart::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TElePartItem Item = GetItem(i);
    if (Item.Input == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TElePart::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TElePartItem Item = GetItem(i);
    if (Item.Input == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------

typedef struct TElePartItemL {  // Cívky
  ShortString Name;
  ShortString ValueLs;
  ShortString ValueRs;
  int Input;
  int Output;
} TElePartItemL;

class TElePartL {
  private:
    TList* FList;
  public:
    TElePartL();
    ~TElePartL();
    int Count(void);
    int Add(TElePartItemL Item);
    TElePartItemL GetItem(int Index);
    void SetItem(int Index, TElePartItemL Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TElePartL::TElePartL()
{
  FList = new TList();
};
TElePartL::~TElePartL()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TElePartL::Count(void)
{
  return FList->Count;
};
int TElePartL::Add(TElePartItemL Item)
{
   TElePartItemL* pItem = (TElePartItemL*) malloc(sizeof(TElePartItemL));
   *pItem = Item;
   return FList->Add(pItem);
};
TElePartItemL TElePartL::GetItem(int Index)
{
  return *((TElePartItemL*) FList->operator [](Index));
};
void TElePartL::SetItem(int Index, TElePartItemL Item)
{
  *((TElePartItemL*) FList->operator [](Index)) = Item;
};
int TElePartL::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TElePartItemL Item = GetItem(i);
    if (Item.Input == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TElePartL::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TElePartItemL Item = GetItem(i);
    if (Item.Input == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};
//---------------------------------------------------------------------------

typedef struct TElePartItemB {  // Buffer
  ShortString Name;
  ShortString ValueF;
  ShortString ValueRout;
  int Input;
  int Output;
} TElePartItemB;

class TElePartB {
  private:
    TList* FList;
  public:
    TElePartB();
    ~TElePartB();
    int Count(void);
    int Add(TElePartItemB Item);
    TElePartItemB GetItem(int Index);
    void SetItem(int Index, TElePartItemB Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TElePartB::TElePartB()
{
  FList = new TList();
};
TElePartB::~TElePartB()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TElePartB::Count(void)
{
  return FList->Count;
};
int TElePartB::Add(TElePartItemB Item)
{
   TElePartItemB* pItem = (TElePartItemB*) malloc(sizeof(TElePartItemB));
   *pItem = Item;
   return FList->Add(pItem);
};
TElePartItemB TElePartB::GetItem(int Index)
{
  return *((TElePartItemB*) FList->operator [](Index));
};
void TElePartB::SetItem(int Index, TElePartItemB Item)
{
  *((TElePartItemB*) FList->operator [](Index)) = Item;
};
int TElePartB::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TElePartItemB Item = GetItem(i);
    if (Item.Input == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TElePartB::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TElePartItemB Item = GetItem(i);
    if (Item.Input == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------

typedef struct TElePartItemS {  // Spínače
  ShortString Name;
  ShortString Value;
  ShortString ValueR;
  int Input;
  int Output;
} TElePartItemS;

class TElePartS {
  private:
    TList* FList;
  public:
    TElePartS();
    ~TElePartS();
    int Count(void);
    int Add(TElePartItemS Item);
    TElePartItemS GetItem(int Index);
    void SetItem(int Index, TElePartItemS Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TElePartS::TElePartS()
{
  FList = new TList();
};
TElePartS::~TElePartS()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TElePartS::Count(void)
{
  return FList->Count;
};
int TElePartS::Add(TElePartItemS Item)
{
   TElePartItemS* pItem = (TElePartItemS*) malloc(sizeof(TElePartItemS));
   *pItem = Item;
   return FList->Add(pItem);
};
TElePartItemS TElePartS::GetItem(int Index)
{
  return *((TElePartItemS*) FList->operator [](Index));
};
void TElePartS::SetItem(int Index, TElePartItemS Item)
{
  *((TElePartItemS*) FList->operator [](Index)) = Item;
};
int TElePartS::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TElePartItemS Item = GetItem(i);
    if (Item.Input == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TElePartS::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TElePartItemS Item = GetItem(i);
    if (Item.Input == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------

typedef struct TElePartItemM {   // Vzájemná indukčnost M
  ShortString Name;
  ShortString ValueL1;
  ShortString ValueL2;
  ShortString ValueR1;
  ShortString ValueR2;
  ShortString ValueK;
  int InputA;
  int OutputB;
  int InputC;
  int OutputD;
} TElePartItemM;

class TElePartM {
  private:
    TList* FList;
  public:
    TElePartM();
    ~TElePartM();
    int Count(void);
    int Add(TElePartItemM Item);
    TElePartItemM GetItem(int Index);
    void SetItem(int Index, TElePartItemM Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TElePartM::TElePartM()
{
  FList = new TList();
};
TElePartM::~TElePartM()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TElePartM::Count(void)
{
  return FList->Count;
};
int TElePartM::Add(TElePartItemM Item)
{
   TElePartItemM* pItem = (TElePartItemM*) malloc(sizeof(TElePartItemM));
   *pItem = Item;
   return FList->Add(pItem);
};
TElePartItemM TElePartM::GetItem(int Index)
{
  return *((TElePartItemM*) FList->operator [](Index));
};
void TElePartM::SetItem(int Index, TElePartItemM Item)
{
  *((TElePartItemM*) FList->operator [](Index)) = Item;
};
int TElePartM::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TElePartItemM Item = GetItem(i);
    if (Item.InputA == Value) {
      Index = i;
      run = 0;
    }
    if (Item.OutputB == Value) {
      Index = i;
      run = 0;
    }
    if (Item.InputC == Value) {
      Index = i;
      run = 0;
    }
    if (Item.OutputD == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TElePartM::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TElePartItemM Item = GetItem(i);
    if (Item.InputA == Value)
      PutCount++;
    if (Item.OutputB == Value)
      PutCount++;
    if (Item.InputC == Value)
      PutCount++;
    if (Item.OutputD == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------

typedef struct TEleAOItem {   // Operační zesilovače OA1p
  ShortString Name;
  ShortString ValueA;
  ShortString ValueFt;
  ShortString ValueRout;
  int InputA;
  int InputB;
  int Output;
} TFEleAOItem;

class TEleAO {
  private:
    TList* FList;
  public:
    TEleAO();
    ~TEleAO();
    int Count(void);
    int Add(TEleAOItem Item);
    TEleAOItem GetItem(int Index);
    void SetItem(int Index, TEleAOItem Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TEleAO::TEleAO()
{
  FList = new TList();
};
TEleAO::~TEleAO()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TEleAO::Count(void)
{
  return FList->Count;
};
int TEleAO::Add(TEleAOItem Item)
{
   TEleAOItem* pItem = (TEleAOItem*) malloc(sizeof(TEleAOItem));
   *pItem = Item;
   return FList->Add(pItem);
};
TEleAOItem TEleAO::GetItem(int Index)
{
  return *((TEleAOItem*) FList->operator [](Index));
};
void TEleAO::SetItem(int Index, TEleAOItem Item)
{
  *((TEleAOItem*) FList->operator [](Index)) = Item;
};
int TEleAO::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TEleAOItem Item = GetItem(i);
    if (Item.InputA == Value) {
      Index = i;
      run = 0;
    }
    if (Item.InputB == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TEleAO::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TEleAOItem Item = GetItem(i);
    if (Item.InputA == Value)
      PutCount++;
    if (Item.InputB == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------
typedef struct TEleIDOZItem {   // ideální operační zesilovač IDOZ
  ShortString Name;
  ShortString ValueF;
  ShortString ValueRout;
  int InputA;
  int InputB;
  int Output;
} TEleIDOZItem;

class TEleIDOZ {
  private:
    TList* FList;
  public:
    TEleIDOZ();
    ~TEleIDOZ();
    int Count(void);
    int Add(TEleIDOZItem Item);
    TEleIDOZItem GetItem(int Index);
    void SetItem(int Index, TEleIDOZItem Item);
    int PutIDExists(int Value);
    int PutIDCount(int Value);
};

TEleIDOZ::TEleIDOZ()
{
  FList = new TList();
};
TEleIDOZ::~TEleIDOZ()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TEleIDOZ::Count(void)
{
  return FList->Count;
};
int TEleIDOZ::Add(TEleIDOZItem Item)
{
   TEleIDOZItem* pItem = (TEleIDOZItem*) malloc(sizeof(TEleIDOZItem));
   *pItem = Item;
   return FList->Add(pItem);
};
TEleIDOZItem TEleIDOZ::GetItem(int Index)
{
  return *((TEleIDOZItem*) FList->operator [](Index));
};
void TEleIDOZ::SetItem(int Index, TEleIDOZItem Item)
{
  *((TEleIDOZItem*) FList->operator [](Index)) = Item;
};
int TEleIDOZ::PutIDExists(int Value)
{
  int i = 0;
  int run = 1;
  int Index = 0;
  while ((i < Count())&&(run)) {
    TEleIDOZItem Item = GetItem(i);
    if (Item.InputA == Value) {
      Index = i;
      run = 0;
    }
    if (Item.InputB == Value) {
      Index = i;
      run = 0;
    }
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return 0;
  else
    return Index + 1;
};
int TEleIDOZ::PutIDCount(int Value)
{
  int PutCount = 0;
  for (int i = 0; i < Count(); i++) {
    TEleIDOZItem Item = GetItem(i);
    if (Item.InputA == Value)
      PutCount++;
    if (Item.InputB == Value)
      PutCount++;
    if (Item.Output == Value)
      PutCount++;
  }
  return PutCount;
};

//---------------------------------------------------------------------------

typedef struct TIOListItem {
  int Input;
  int Output;
} TFIOListItem;

class TIOList {
  private:
    TList* FList;
  public:
    TIOList();
    ~TIOList();
    int Count();
    int Add(TIOListItem Item);
    TIOListItem GetItem(int Index);
    void SetItem(int Index, TIOListItem Item);
    int IndexOfInput(int Value);
    int IndexOfOutput(int Value);
};

TIOList::TIOList()
{
  FList = new TList();
};
TIOList::~TIOList()
{
  for(int i = 0; i < Count(); i++){
    free(FList->operator [](i));
  }
  delete FList;
};
int TIOList::Count()
{
  return FList->Count;
};
int TIOList::Add(TIOListItem Item)
{
  TIOListItem* pItem = (TIOListItem*) malloc(sizeof(TIOListItem));
  *pItem = Item;
  return FList->Add(pItem);
};
TIOListItem TIOList::GetItem(int Index)
{
  return *((TIOListItem*) FList->operator [](Index));
};
void TIOList::SetItem(int Index, TIOListItem Item)
{
  *((TIOListItem*) FList->operator [](Index)) = Item;
};
int TIOList::IndexOfInput(int Value)
{
  int i = 0;
  int run = 1;
  int Index = -1;
  while ((i < Count())&&(run)) {
    TIOListItem Item = GetItem(i);
    if (Item.Input == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return -1;
  else
    return Index;
};
int TIOList::IndexOfOutput(int Value)
{
  int i = 0;
  int run = 1;
  int Index = -1;
  while ((i < Count())&&(run)) {
    TIOListItem Item = GetItem(i);
    if (Item.Output == Value) {
      Index = i;
      run = 0;
    }
    i++;
  }
  if (run)
    return -1;
  else
    return Index;
};

//-----------------------------------------------------------------------------
TComplexArray* InvMat(TComplexArray* y, int t, int deleni)
//vypocita inverzni matici k "y" v casove oblasti pro cas t a vysledek ulozi do matice "ze"

/* Prepisovana funkcni procedura pro vypocet v Pascalu:
     procedure INVLAP2_4(y:matc;vstup:byte;var x:vek;np:integer;t:extended;deleni:word);
         label skok,skok1;
         var i,j,k,index:byte;
             kr:integer;
             x0:vek;
             z,kp:array[1..2] of complex;
             vekpom1,vekpom2:vekc;
             matpom1,matpom2:matcd;
             indx1,indx2:vekint;
             d1,d2:shortint;
             krok:real;
         begin
        {-------definice Padeho koeficientu---------}

        z[1].re:=3.779019967010193;z[1].im:=1.380176524272843;
        z[2].re:=2.220980032989807;z[2].im:=4.160391445506932;

        kp[1].re:=2.256958744418140;kp[1].im:=-39.63308700050173;
        kp[2].re:=-2.256958744418140;kp[2].im:=11.10883163787590;
        {--------konec definice--------------------}
           NEW(matpom1);NEW(matpom2);
           krok:=t/deleni;
                 for j:=1 to np do
                   begin
                      for k:=1 to np do
                         begin
                           matpom1^[j,k].re:=y[j,k].re+y[j,k].im*z[1].re/krok;
                           matpom1^[j,k].im:=y[j,k].im*z[1].im/krok;
                           matpom2^[j,k].re:=y[j,k].re+y[j,k].im*z[2].re/krok;
                           matpom2^[j,k].im:=y[j,k].im*z[2].im/krok;
                         end;
                    end;
                 LUC(matpom1^,np,indx1,d1);
                 LUC(matpom2^,np,indx2,d2);
                 VEKTORZEROC(vekpom1);
                 vekpom1[vstup].re:=1;
                 vekpom2:=vekpom1;
                   kr:=1;
                   goto SKOK;
        SKOK1:VEKTORZERO(x0);
                 for j:=1 to np do
                             begin
                               for k:=1 to np do x0[j]:=x0[j]+y[j,k].im*x[k];
                             end;
                VEKTORZEROC(vekpom1);
                 for j:=1 to np do vekpom1[j].re:=x0[j];
                 vekpom2:=vekpom1;
        SKOK:SOLVEC(matpom1^,np,indx1,vekpom1);
             SOLVEC(matpom2^,np,indx2,vekpom2);
             VEKTORZERO(x);
             for j:=1 to np do
                begin
                    x[j]:=x[j]+kp[1].im*vekpom1[j].im-kp[1].re*vekpom1[j].re;
                    x[j]:=x[j]+kp[2].im*vekpom2[j].im-kp[2].re*vekpom2[j].re;
                    x[j]:=x[j]/krok;
                end;
             kr:=kr+1;
             if kr<=deleni then goto skok1;
             DISPOSE(matpom1);DISPOSE(matpom2);
        end;
*/
/* přepsana funkce
{
  int d1, d2;
  TComplexArray* z = new TComplexArray(2,1);
  TComplexArray* kp = new TComplexArray(2,1);
  // Definice padeho koeficientu
  z->SetItemReIm(0,0,3.779019967010193,1.380176524272843);
  z->SetItemReIm(1,0,2.220980032989807,4.160391445506932);
  kp->SetItemReIm(0,0,2.256958744418140,-39.63308700050173);
  kp->SetItemReIm(1,0,-2.256958744418140,11.10883163787590);


  int n = y->GetColCount();
  TComplexArray* ze = new TComplexArray(n,n);      //výsledná matice reálných čísel
  TComplexArray* matpom1 = new TComplexArray(n,n);
  TComplexArray* matpom2 = new TComplexArray(n,n);
  TComplexArray* vekpom1 = new TComplexArray(n,1);
  TComplexArray* vekpom2 = new TComplexArray(n,1);
  TComplexArray* indx1 = new TComplexArray(n,1);
  TComplexArray* indx2 = new TComplexArray(n,1);
  TComplexArray* x0 = new TComplexArray(n,1);
  fcomplex pom1, pom2;
  boolean skok;
  int i,j,k, kr;

  double krok = ((double) t) / ((double) deleni);

 for (j=0;j<n;j++)
 {
   for(k=0;k<n;k++)
   {
     matpom1->SetItemReIm(k,j, y->GetItem(k,j).r+y->GetItem(k,j).i*z->GetItem(0,0).r/krok, y->GetItem(k,j).i*z->GetItem(0,0).i/krok);
     matpom2->SetItemReIm(k,j, y->GetItem(k,j).r+y->GetItem(k,j).i*z->GetItem(1,0).r/krok, y->GetItem(k,j).i*z->GetItem(1,0).i/krok);
   }
 }

 matpom1->Luc(matpom1,indx1,d1);
 matpom2->Luc(matpom2,indx2,d2);

 for (i=0;i<n;i++)
 {
   vekpom1->NullAll();
   pom1 = Complex(1,vekpom1->GetItem(i,0).i);   //melo by byt 0
   vekpom1->SetItem(i,0,pom1);
   vekpom2->NullAll();
   pom2 = Complex(i,vekpom2->GetItem(i,0).i);   //melo by byt 0
   vekpom2->SetItem(i,0,pom2);
   skok = False;

   for(kr=1;kr<=deleni;kr++)
   {
     if (skok)
     {
       x0->NullAll();
       for(j=0;j<n;j++)
       {
         for(k=0;k<n;k++)
         {
           x0->SetItemReIm(j,0,x0->GetItem(j,0).r+y->GetItem(k,j).i*ze->GetItem(i,k).r,0);
         }
       }
       vekpom1->NullAll();
       for(j=0;j<n;j++)
       {
         vekpom1->SetItemReIm(j,0,x0->GetItem(j,0).r,vekpom1->GetItem(j,0).i);
         vekpom2->SetItemReIm(j,0,x0->GetItem(j,0).r,vekpom2->GetItem(j,0).i);
       }
       // vekpom2 = vekpom1;
     }

     matpom1->Solvec(matpom1,indx1,vekpom1);
     matpom2->Solvec(matpom2,indx2,vekpom2);
     for(k=0;k<n;k++)
     {
      ze->SetItemReIm(i,k,0.0,0.0);
     }
     for(j=0;j<n;j++)
     {
       ze->SetItemReIm(i,j,ze->GetItem(i,j).r+kp->GetItem(0,0).i*vekpom1->GetItem(j,0).i-kp->GetItem(0,0).r*vekpom1->GetItem(j,0).r,0);
       ze->SetItemReIm(i,j,ze->GetItem(i,j).r+kp->GetItem(1,0).i*vekpom2->GetItem(j,0).i-kp->GetItem(1,0).r*vekpom2->GetItem(j,0).r,0);
       ze->SetItemReIm(i,j,ze->GetItem(i,j).r/((double) krok),0);
     }
     skok = True;
   }
 }


 delete z;
 delete kp;
 delete matpom1;
 delete matpom2;
 delete indx1;
 delete indx2;
 delete vekpom1;
 delete vekpom2;
 delete x0;

 return ze;
*/
{

int n=y->GetColCount();

 TComplexArray* indx = new TComplexArray(n,1);
 int d = 1;
 TComplexArray* col = new TComplexArray(n,1);
 TComplexArray* invmat = new TComplexArray(n,n);
 TComplexArray* matpom = new TComplexArray(n,n);

 for (int j=0;j<n;j++)
 {
   for(int k=0;k<n;k++)
   {
     matpom->SetItemReIm(k,j, y->GetItem(k,j).r, y->GetItem(k,j).i);
    }
 }

 matpom->Luc(matpom,indx,d);

 for (int j=0;j<n;j++)
 {
   col->NullAll();
   col->SetItemReIm(j,0,1.0,0.0);
   matpom->Solvec(matpom,indx,col);
   for (int i=0;i<n;i++)
      invmat->SetItem(j,i,col->GetItem(i,0));
 }

 delete matpom;
 delete indx;
 delete col;
 return invmat;

}

//---------------------------------------------------------------------------

TComplexArray* InvLapInt(TComplexArray* y, int t, int deleni, int vstup)
//vypocet integralu x(t)

/* Prepisovana funkcni procedura pro vypocet v Pascalu:
     procedure INVLAPINT2_4(y:matc;vstup:byte;var x:vek;np:integer;t:extended;deleni:word);
         label skok,skok1;
         var i,j,k,index:byte;
             kr:integer;
             x0:vek;
             z,kp:array[1..2] of complex;
             vekpom1,vekpom2,a,b:vekc;
             matpom1,matpom2:matcd;
             indx1,indx2:vekint;
             d1,d2:shortint;
             krok:real;
         begin
        {-------definice Padeho koeficientu---------}

        z[1].re:=3.779019967010193;z[1].im:=1.380176524272843;
        z[2].re:=2.220980032989807;z[2].im:=4.160391445506932;

        kp[1].re:=2.256958744418140;kp[1].im:=-39.63308700050173;
        kp[2].re:=-2.256958744418140;kp[2].im:=11.10883163787590;
        {--------konec definice--------------------}
           NEW(matpom1);NEW(matpom2);
           krok:=t/deleni;
                 for j:=1 to np do
                   begin
                      for k:=1 to np do
                         begin
                           matpom1^[j,k].re:=y[j,k].re+y[j,k].im*z[1].re/krok;
                           matpom1^[j,k].im:=y[j,k].im*z[1].im/krok;
                           matpom2^[j,k].re:=y[j,k].re+y[j,k].im*z[2].re/krok;
                           matpom2^[j,k].im:=y[j,k].im*z[2].im/krok;
                         end;
                    end;
                 LUC(matpom1^,np,indx1,d1);
                 LUC(matpom2^,np,indx2,d2);
                 VEKTORZEROC(vekpom1);vekpom2:=vekpom1;
                 VYDELRC(krok,z[1],vekpom1[vstup]);
                 VYDELRC(krok,z[2],vekpom2[vstup]);
                 a:=vekpom1;b:=vekpom2;
                 kr:=1;
                 goto SKOK;
        SKOK1:VEKTORZERO(x0);
                 for j:=1 to np do
                             begin
                               for k:=1 to np do x0[j]:=x0[j]+y[j,k].im*x[k];
                             end;
                 for j:=1 to np do
                   begin
                      SECTIRC(x0[j],a[j],vekpom1[j]);
                      SECTIRC(x0[j],b[j],vekpom2[j]);
                   end;
        SKOK:SOLVEC(matpom1^,np,indx1,vekpom1);
             SOLVEC(matpom2^,np,indx2,vekpom2);
             VEKTORZERO(x);
             for j:=1 to np do
               begin
                    x[j]:=x[j]+kp[1].im*vekpom1[j].im-kp[1].re*vekpom1[j].re;
                    x[j]:=x[j]+kp[2].im*vekpom2[j].im-kp[2].re*vekpom2[j].re;
                    x[j]:=x[j]/krok;
                end;
             kr:=kr+1;
             if kr<=deleni then goto skok1;
             DISPOSE(matpom1);DISPOSE(matpom2);
        end;
*/
{
 int d1, d2;
 TComplexArray* z = new TComplexArray(2,1);
 TComplexArray* kp = new TComplexArray(2,1);
 // Definice padeho koeficientu
 z->SetItemReIm(0,0,3.779019967010193,1.380176524272843);
 z->SetItemReIm(1,0,2.220980032989807,4.160391445506932);
 kp->SetItemReIm(0,0,2.256958744418140,-39.63308700050173);
 kp->SetItemReIm(1,0,-2.256958744418140,11.10883163787590);

 int n = y->GetColCount();
 TComplexArray* x = new TComplexArray(n,1);      //výsledná matice reálných čísel
 TComplexArray* matpom1 = new TComplexArray(n,n);
 TComplexArray* matpom2 = new TComplexArray(n,n);
 TComplexArray* vekpom1 = new TComplexArray(n,1);
 TComplexArray* vekpom2 = new TComplexArray(n,1);
 TComplexArray* a = new TComplexArray(n,1);
 TComplexArray* b = new TComplexArray(n,1);
 TComplexArray* indx1 = new TComplexArray(n,1);
 TComplexArray* indx2 = new TComplexArray(n,1);
 TComplexArray* x0 = new TComplexArray(n,1);
 fcomplex pom1, pom2;
 boolean skok;
 int i,j,k, kr;

 double krok = ((double) t) / ((double) deleni);

 for (j=0;j<n;j++)
 {
   for(k=0;k<n;k++)
   {
     matpom1->SetItemReIm(k,j, y->GetItem(k,j).r+y->GetItem(k,j).i*z->GetItem(0,0).r/krok, y->GetItem(k,j).i*z->GetItem(0,0).i/krok);
     matpom2->SetItemReIm(k,j, y->GetItem(k,j).r+y->GetItem(k,j).i*z->GetItem(1,0).r/krok, y->GetItem(k,j).i*z->GetItem(1,0).i/krok);
   }
 }
 matpom1->Luc(matpom1,indx1,d1);
 matpom2->Luc(matpom2,indx2,d2);

 vekpom1->NullAll();
 vekpom2->NullAll();
 vekpom1->SetItem(vstup,0,RCDiv(krok,z->GetItem(0,0)));
 vekpom2->SetItem(vstup,0,RCDiv(krok,z->GetItem(1,0)));
 a->SetItem(vstup,0,RCDiv(krok,z->GetItem(0,0)));
 b->SetItem(vstup,0,RCDiv(krok,z->GetItem(1,0)));

 skok = False;
 for(kr=0;kr<deleni;kr++)
 {
   if (skok)
   {
     x0->NullAll();
     for(j=0;j<n;j++)
     {
       for(k=0;k<n;k++)
       {
         x0->SetItemReIm(j,0,x0->GetItem(j,0).r+y->GetItem(k,j).i*x->GetItem(k,0).r,0);
       }
     }
     vekpom1->NullAll();
     for(j=0;j<n;j++)
     {
       pom1 = RCadd(x0->GetItem(j,0).r,a->GetItem(j,0));
       vekpom1->SetItem(j,0,pom1);
       pom2 = RCadd(x0->GetItem(j,0).r,a->GetItem(j,0));
       vekpom2->SetItem(j,0,pom2);
     }
     // vekpom2 = vekpom1;
   }
   matpom1->Solvec(matpom1,indx1,vekpom1);
   matpom2->Solvec(matpom2,indx2,vekpom2);
   x->NullAll();
   for(j=0;j<n;j++)
   {
     x->SetItemReIm(j,0,x->GetItem(j,0).r+kp->GetItem(0,0).i*vekpom1->GetItem(j,0).i-kp->GetItem(0,0).r*vekpom1->GetItem(j,0).r,0);
     x->SetItemReIm(j,0,x->GetItem(j,0).r+kp->GetItem(1,0).i*vekpom2->GetItem(j,0).i-kp->GetItem(1,0).r*vekpom2->GetItem(j,0).r,0);
     x->SetItemReIm(j,0,x->GetItem(j,0).r/krok,0);
   }
   skok = True;
 }



 delete kp;
 delete matpom1;
 delete matpom2;
 delete indx1;
 delete indx2;
 delete vekpom1;
 delete vekpom2;
 delete a;
 delete b;
 delete x0;

 return x;
}

//---------------------------------------------------------------------------

void Faddejev(TComplexArray* f, TVectorComArray* acit, TComplexArray* ajmen)
{
 int n = f->GetColCount();
 // TVectorComArray* acit = new TVectorComArray(n+1,n,n); //vektor matic citatele
 TComplexArray* acitpom = new TComplexArray(n,n);   //pomocná matice pro zapisováí do acit
 TComplexArray* jednotkova = new TComplexArray(n,n);   //jednotková matice
 //TComplexArray* ajmen = new TComplexArray(n+1,1);      //vektor reálných koeficientů jmenovatele

 jednotkova->OnesDiag();

 acitpom->OnesDiag();
 acit->SetMatrixCopy(0,acitpom);
 ajmen->SetItemReIm(0,0,1,0);

 for(int i=1;i<=n;i++)
 {
   // sahani pres nesahat !!!!! - bude se menit uvnitr
   TComplexArray* pomMat = acit->GetMatrix(i);
   pomMat->MulMatMat(f, acit->GetMatrix(i-1));
   //ShowMessage(pomMat->Trace().r);
   //ShowMessage(-1.0/(double)i);
   //ShowMessage(RCmul(-1.0/(double)i, pomMat->Trace()).r);
   ajmen->SetItem(i,0,RCmul(-1.0/(double)i, pomMat->Trace()));
   jednotkova->OnesDiag();
   jednotkova->MulNum(ajmen->GetItem(i,0));
   pomMat->PlusMat(jednotkova);
 }

 if (acit->GetMatrix(n)->isNull())
   ShowMessage("Posledni je nulova - OK");
 else
   ShowMessage("Faddejev - ERROR !!!!");

 //delete acit;
 delete acitpom;
 delete jednotkova;
 //delete ajmen;
}



//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TPageControl *PageControl1;
        TTabSheet *TabSheet1;
        TTabSheet *TabSheet2;
        TLabel *LPrvniRadek;
        TLabel *Label1;
        TLabel *Label2;
        TLabel *Label3;
        TLabel *Label4;
        TLabel *Label5;
        TLabel *Label6;
        TLabel *Label7;
        TLabel *Label8;
        TLabel *Label9;
        TLabel *Label10;
        TLabel *Label11;
        TLabel *Label12;
        TLabel *Label13;
        TLabel *Label14;
        TLabel *Label15;
        TLabel *Label16;
        TLabel *Label17;
        TLabel *Label18;
        TLabel *Label19;
        TLabel *Label20;
        TLabel *Label21;
        TLabel *Label22;
        TLabel *Label23;
        TLabel *Label24;
        TMemo *Memo1;
        TListView *LV1;
        TButton *Button1;
        TMemo *Memo2;
        TListView *LV2;
        TListView *LV3;
        TMemo *Memo3;
        TListView *LV4;
        TListView *LV5;
        TListView *LV6;
        TListView *LV7;
        TListView *LV8;
        TListView *LV9;
        TListView *LV10;
        TMainMenu *MainMenu1;
        TMenuItem *Soubor;
        TMenuItem *Otevrit;
        TMenuItem *Ulozit;
        TMenuItem *Konec;
        TOpenDialog *OpenDialog1;
        TSaveDialog *SaveDialog1;
        TListView *ListView1;
        TListView *ListView2;
        TListView *ListView3;
        TListView *ListView4;
        TListView *ListView5;
        TListView *ListView6;
        TListView *ListView7;
        TListView *ListView8;
        TTabSheet *TabSheet3;
        TListView *ListView10;
        TButton *Button2;
        TListView *ListView9;
        TListView *ListView11;
        TListView *ListView12;
        TListView *LV11;
        TLabel *Label25;
        TLabel *Label26;
        TListView *LV12;
        TLabel *Label27;
        TLabel *Label28;
        TTabSheet *TabSheet4;
        TListView *ListView13;
        TListView *ListView14;
        TListView *ListView15;
        TListView *ListView16;
        TListView *LV13;
        TLabel *Label29;
        TLabel *Label30;
        TButton *Button3;
        TLabel *Label31;
        TLabel *Label32;
        TLabel *Label33;
        TLabel *Label34;
        TLabel *Label35;
        TLabel *Label36;
        TButton *Button8;
        TTabSheet *TabSheet5;
        TListView *ListView17;
        TTabSheet *TabSheet6;
        TImage *Image;
        TLabel *XLabel;
        TLabel *YLabel;
        TPanel *Panel1;
        TLabel *Label39;
        TEdit *EditFS;
        TLabel *Label40;
        TTabSheet *TabSheet7;
        TPanel *Panelin;
        TPanel *Panelout;
        TLabel *Label37;
        TEdit *EditIN;
        TEdit *EditD;
        TLabel *Label38;
        TEdit *EditOUT;
        TComboBox *CBXmin;
        TComboBox *CBXmax;
        TLabel *Label43;
        TComboBox *CBHodDek;
        TChart *Chart1;
        TAverageTeeFunction *TeeFunction1;
        TLineSeries *Series2;
        TLineSeries *Series1;
        TLabel *Label41;
        TLabel *Label42;
        TCheckBox *ChBinfaze1;
        TCheckBox *ChBinfaze2;
        TCheckBox *ChBoutfaze1;
        TCheckBox *ChBoutfaze2;
        TAverageTeeFunction *TeeFunction2;
        TMenuItem *Ulozit2;
        TSaveDialog *SaveDialog2;
        TMenuItem *secret1;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall OtevritClick(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall UlozitClick(TObject *Sender);
        void __fastcall KonecClick(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall Button8Click(TObject *Sender);
        void __fastcall ImageMouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
        void __fastcall Chart1MouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
        void __fastcall Memo1Exit(TObject *Sender);
        void __fastcall ChBoutfaze1Click(TObject *Sender);
        void __fastcall ChBoutfaze2Click(TObject *Sender);
        void __fastcall Memo1Change(TObject *Sender);
        void __fastcall Ulozit2Click(TObject *Sender);
        void __fastcall secret1Click(TObject *Sender);
private:	// User declarations
        int Fx;
        TElePart* CompR;
        TElePart* CompRS1;
        TElePart* CompRS2;
        TElePartL* CompL;
        TElePart* CompC;
        TElePartS* Switch;
        TEleAO* AOIdoz;
        TElePartB* CompBuf;
        TElePartM* CompM;
        TEleNodes* Nodes;
        TEleIDOZ* CompIdoz;
        // matice pro obecné řešení
        TStringArray* FCircuitArrayY1;
        TStringArray* FCircuitArrayC12;
        TStringArray* FCircuitArrayC21;
        TStringArray* FCircuitArrayY2;
        TStringArray* FCircuitArrayY1s;
        TStringArray* FCircuitArrayC12s;
        TStringArray* FCircuitArrayC21s;
        TStringArray* FCircuitArrayY2s;
        // matice pro numerické řešení
        TComplexArray* FComplexCircuitArrayY1;
        TComplexArray* FComplexCircuitArrayC12;
        TComplexArray* FComplexCircuitArrayC21;
        TComplexArray* FComplexCircuitArrayY2;
        TComplexArray* FComplexCircuitArrayY1f;
        TComplexArray* FComplexCircuitArrayC12f;
        TComplexArray* FComplexCircuitArrayC21f;
        TComplexArray* FComplexCircuitArrayY2f;
        TComplexArray* FComplexCircuitArrayY1short;
        TComplexArray* FComplexCircuitArrayC12short;
        TComplexArray* FComplexCircuitArrayC21short;
        TComplexArray* FComplexCircuitArrayY2short;
        // pomocné proměnné pro funkce Luc a Solvec
        TComplexArray* indx;
        TComplexArray* b;
        TComplexArray* f;
        // proměnné pro grafy a mfile
        TComplexArray* matfreq;
        TComplexArray* matexp;
        TComplexArray* matdb;
        TComplexArray* matfaze;

public:		// User declarations
        AnsiString VstupSoub;

        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
