os << m << endl;
for( int i = 0; i < m; i++ )
os << Coeff[2*i] << ' ' << Coeff[2*i+1] << endl;
return errOk;
}
//-----------------------------------------------------char* ErrorMessage( int err )
{
switch( err )
{
case errNoMemAllocated : return "Memory not allocated.";
case errTooFewPoints : return "Too few points.";
case errCannotSolveSLAE : return "Cannot solve SLAE.";
case errRegFailed : return "Regularization failed.";
case errTooFewSplineNodes : return "Too few spline nodes.";
case errNoLogScale : return "Cannot convert to log scale.";
case errNoImpuls : return "No Impuls.";
case errNoEMFCurve : return "No EMF curve.";
case errUserBreak : return "User break.";
default : return "Unknown error.";
}
}
Файл eh_lin.cpp
#include <fstream.h>
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "hvs.h"
#pragma hdrstop
#include "cmdkeys.h"
const char DefProgr[] = "% completed";
const char RegularProgr[] = "% of curve has been normalized";
int OnProgress( int action, int percent )
{
static char* ProgressMessage;
switch( action )
{
case paDecompose :
ProgressMessage = (char *)DefProgr;
cout << endl << "Decomposing impuls..." << endl;
break;
case paMakeMatrix :
ProgressMessage = (char *)DefProgr;
cout << endl << "Making matrix..." << endl;
break;
case paRegular :
ProgressMessage = (char *)RegularProgr;
cout << endl << "Regularization..." << endl;
default :
cout << percent << ProgressMessage << " \r";
}
return 1;
}
void main( int argc, char **argv )
{
if( argc <= 2 )
{
cout << "Format: eh <source eds> <coefficients> [<dst file>]" << endl;
cout << "Press any key..." << endl;
getch();
return;
}
char keys[100];
if( !ExtractKeys( argc, argv, keys, sizeof(keys) ) )
{
cout << "Command line too long." << endl;
cout << "Press any key." << endl;
getch();
return;
}
ifstream edsifs( argv[1] );
ifstream abifs( argv[2] );
int n = 0, m = 0;
int i;
int LoadImpuls;
double t,eds;
double epsi, cthick;
double *ET, *Eds;
double *HT, *HEds;
double *IT = NULL, *II = NULL;
char *IntMem;
char Line1[40], Line2[40], MediaInfo[512] = "\0";
// count items in Eds file
edsifs.getline( Line1, sizeof(Line1) );
edsifs.getline( Line2, sizeof(Line2) );
while( !edsifs.eof() && !edsifs.fail() )
{
edsifs >> t;
edsifs >> eds;
n++;
}
n--;
if( !edsifs.eof() )
{
edsifs.clear();
edsifs.getline( MediaInfo, sizeof(MediaInfo), EOF );
}
// Allocate memory
ET = new double[n+1];
Eds = new double[n+1];
// Reading source eds and times
edsifs.clear();
edsifs.seekg( 0, ios::beg );
edsifs.ignore( 40, '\n' );
edsifs.ignore( 40, '\n' );
for( i = 0; i < n; i++ )
edsifs >> ET[i] >> Eds[i];
edsifs.close();
LoadImpuls = CheckKey( keys, "IMP" ) != NULL;
if( LoadImpuls )
{
abifs >> m;
abifs >> epsi;
abifs >> cthick;
IT = new double[m];
II = new double[m];
for( i = 0; i < m; i++ )
abifs >> IT[i] >> II[i];
abifs.close();
}
CEMFTransform EMFTrans( IT, II, m, ET, Eds, n );
if( !LoadImpuls )
{
// Reading coeficients
abifs >> m;
IntMem = new char[EMFTrans.CountInternalMem( m )];
EMFTrans.SetIntMem( IntMem );
EMFTrans.LoadCoeff( abifs, m );
abifs.close();
}else
{
EMFTrans.SetDecomposeParams( epsi, cthick );
IntMem = new char[EMFTrans.CountInternalMem()];
EMFTrans.SetIntMem( IntMem );
}
int RegMode = GetKeyInt( keys, "R", 0 );
int Smoothed = CheckKey( keys, "S" ) != NULL;
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.