fclose(in2);
return false;
}
if (sscanf(TextBuffer,"%d %d %d %d %d %ld %ld %ld %ld %ld %ld %ld %ld",
&tmp,&tmp,&tmp,&tmp,&tmp,
&FE[Current][0],&FE[Current][1],&FE[Current][2],&FE[Current][3],
&FE[Current][4],&FE[Current][5],&FE[Current][6],&FE[Current][7]) != 13) continue;
if (fgets(TextBuffer,1000,in2) == NULL)
{
printf("Unable read file %s",fn2);
fclose(in2);
return false;
}
if (sscanf(TextBuffer,"%ld %ld",&FE[Current][8],&FE[Current][9]) != 2)
{
printf("Unable read file %s",fn2);
fclose(in2);
return false;
}
{
if (fabs((tx = 0.5*(X[FE[Current][0] - 1] + X[FE[Current][1] - 1])) - X[FE[Current][4] - 1]) > Eps)
X[FE[Current][4] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][0] - 1] + Y[FE[Current][1] - 1])) - Y[FE[Current][4] - 1]) > Eps)
Y[FE[Current][4] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][0] - 1] + Z[FE[Current][1] - 1])) - Z[FE[Current][4] - 1]) > Eps)
Z[FE[Current][4] - 1] = tz;
if (fabs((tx = 0.5*(X[FE[Current][2] - 1] + X[FE[Current][1] - 1])) - X[FE[Current][5] - 1]) > Eps)
X[FE[Current][5] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][2] - 1] + Y[FE[Current][1] - 1])) - Y[FE[Current][5] - 1]) > Eps)
Y[FE[Current][5] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][2] - 1] + Z[FE[Current][1] - 1])) - Z[FE[Current][5] - 1]) > Eps)
Z[FE[Current][5] - 1] = tz;
if (fabs((tx = 0.5*(X[FE[Current][0] - 1] + X[FE[Current][2] - 1])) - X[FE[Current][6] - 1]) > Eps)
X[FE[Current][6] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][0] - 1] + Y[FE[Current][2] - 1])) - Y[FE[Current][6] - 1]) > Eps)
Y[FE[Current][6] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][0] - 1] + Z[FE[Current][2] - 1])) - Z[FE[Current][6] - 1]) > Eps)
Z[FE[Current][6] - 1] = tz;
if (fabs((tx = 0.5*(X[FE[Current][0] - 1] + X[FE[Current][3] - 1])) - X[FE[Current][7] - 1]) > Eps)
X[FE[Current][7] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][0] - 1] + Y[FE[Current][3] - 1])) - Y[FE[Current][7] - 1]) > Eps)
Y[FE[Current][7] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][0] - 1] + Z[FE[Current][3] - 1])) - Z[FE[Current][7] - 1]) > Eps)
Z[FE[Current][7] - 1] = tz;
if (fabs((tx = 0.5*(X[FE[Current][3] - 1] + X[FE[Current][1] - 1])) - X[FE[Current][8] - 1]) > Eps)
X[FE[Current][8] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][3] - 1] + Y[FE[Current][1] - 1])) - Y[FE[Current][8] - 1]) > Eps)
Y[FE[Current][8] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][3] - 1] + Z[FE[Current][1] - 1])) - Z[FE[Current][8] - 1]) > Eps)
Z[FE[Current][8] - 1] = tz;
if (fabs((tx = 0.5*(X[FE[Current][3] - 1] + X[FE[Current][2] - 1])) - X[FE[Current][9] - 1]) > Eps)
X[FE[Current][9] - 1] = tx;
if (fabs((ty = 0.5*(Y[FE[Current][3] - 1] + Y[FE[Current][2] - 1])) - Y[FE[Current][9] - 1]) > Eps)
Y[FE[Current][9] - 1] = ty;
if (fabs((tz = 0.5*(Z[FE[Current][3] - 1] + Z[FE[Current][2] - 1])) - Z[FE[Current][9] - 1]) > Eps)
Z[FE[Current][9] - 1] = tz;
}
if (++Current == 999)
{
Matrix<DWORD> t = FE;
FE.ReSize(2 * FE.Size1(),10);
for (DWORD i = 0; i < Current; i++)
for (DWORD j = 0; j < 10; j++)
FE[i][j] = t[i][j];
}
if (Current % 100 == 0)
printf("Line: %ld ",Current);
}
NumFE = Current;
for (DWORD i = 0; i < NumFE; i++)
for (DWORD j = 0; j < 10; j++)
FE[i][j]--;
printf(" ");
return true;
}
bool ReadCubeData(char* fn1,char*fn2,FILE* in1,FILE* in2,Vector<double>& X,Vector<double>& Y,Vector<double>& Z,
Matrix<DWORD>& FE,DWORD& NumPoints,DWORD& NumFE)
{
double tx,
ty,
tz;
char TextBuffer[1001];
DWORD Current = 0L,
tmp;
while (!feof(in1))
{
if (fgets(TextBuffer,1000,in1) == NULL)
{
if (feof(in1)) break;
printf("Unable read file %s",fn1);
fclose(in1);
fclose(in2);
return false;
}
if (sscanf(TextBuffer,"%ld %lf %lf %lf", &NumPoints,&tx,&ty,&tz) != 4) continue;
X[Current] = tx;
Y[Current] = ty;
Z[Current] = tz;
if (++Current == 999)
{
Vector<double> t1 = X,
t2 = Y,
t3 = Z;
X.ReSize(2 * X.Size());
Y.ReSize(2 * X.Size());
Z.ReSize(2 * X.Size());
for (DWORD i = 0; i < Current; i++)
{
X[i] = t1[i];
Y[i] = t2[i];
Z[i] = t3[i];
}
}
if (Current % 100 == 0)
printf("Line: %ld ",Current);
}
fclose(in1);
printf(" ");
NumPoints = Current;
Current = 0L;
while (!feof(in2))
{
if (fgets(TextBuffer,1000,in2) == NULL)
{
if (feof(in2)) break;
printf("Unable read file %s",fn2);
fclose(in2);
return false;
}
if (sscanf(TextBuffer,"%d %d %d %d %d %ld %ld %ld %ld %ld %ld %ld %ld",
&tmp,&tmp,&tmp,&tmp,&tmp,
&FE[Current][0],&FE[Current][1],&FE[Current][3],&FE[Current][2],
&FE[Current][4],&FE[Current][5],&FE[Current][7],&FE[Current][6]) != 13) continue;
if (++Current == 999)
{
Matrix<DWORD> t = FE;
FE.ReSize(2 * FE.Size1(),10);
for (DWORD i = 0; i < Current; i++)
for (DWORD j = 0; j < 10; j++)
FE[i][j] = t[i][j];
}
if (Current % 100 == 0)
printf("Line: %ld ",Current);}
NumFE = Current;
for (DWORD i = 0; i < NumFE; i++)
for (DWORD j = 0; j < 10; j++)
FE[i][j]--;
printf(" ");
return true;} ПРИЛОЖЕНИЕ 2.
Исходный текст программы, реализующей алгоритм компактного хранения и решения СЛАУ высокого порядка.
#include "matrix.h"
class RVector
{
private:
Vector<double> Buffer;
public:
RVector(void) {}
~RVector() {}
RVector(DWORD Size) { Buffer.ReSize(Size); }
RVector(RVector& right) { Buffer = right.Buffer; }
RVector(Vector<double>& right) { Buffer = right; }
DWORD Size(void) { return Buffer.Size(); }
void ReSize(DWORD Size) { Buffer.ReSize(Size); }
double& operator [] (DWORD i) { return Buffer[i]; }
RVector& operator = (RVector& right) { Buffer = right.Buffer; return *this; }
RVector& operator = (Vector<double>& right) { Buffer = right; return *this; }
void Sub(RVector&);
void Sub(RVector&,double);
void Mul(double);
void Add(RVector&);
friend double Norm(RVector&,RVector&);
};
class TSMatrix
{
private:
Vector<double> Right;
Vector<double>* Array;
Vector<DWORD>* Links;
uint Dim;
DWORD Size;
public:
TSMatrix(void) { Size = 0; Dim = 0; Array = NULL; Links = NULL; }
TSMatrix(Vector<DWORD>*,DWORD,uint);
~TSMatrix(void) { if (Array) delete [] Array; }
Vector<double>& GetRight(void) { return Right; }
DWORD GetSize(void) { return Size; }
uint GetDim(void) { return Dim; }
Vector<double>& GetVector(DWORD i) { return Array[i]; }
Vector<DWORD>* GetLinks(void) { return Links; }
void SetLinks(Vector<DWORD>* l) { Links = l; }
void Add(Matrix<double>&,Vector<DWORD>&);
void Add(DWORD I, DWORD L, DWORD J, DWORD K, double v)
{
DWORD Row = I,
Col = L * Links[I].Size() * Dim + Find(I,J) * Dim + K;
Array[Row][Col] += v;
}
void Add(DWORD I, double v)
{
Right[I] += v;
}
DWORD Find(DWORD,DWORD);
void Restore(Matrix<double>&); )