本文整理汇总了C++中Analysis::get_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Analysis::get_begin方法的具体用法?C++ Analysis::get_begin怎么用?C++ Analysis::get_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analysis
的用法示例。
在下文中一共展示了Analysis::get_begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char **argv )
{
Analysis *scmanal = new Analysis( 3, 2, 0, "", argc, argv );
char output_comment[ 256 ];
snprintf( output_comment, 256, "(%s) + (%s)", scmanal->get_comment( 0 ),
scmanal->get_comment( 1 ) );
scmanal->set_comment( 2, output_comment );
if ( scmanal->get_type( 0 ) != scmanal->get_type( 1 ) ) {
fprintf( stderr, "%s: Input file types differ.\n", argv[ 0 ] );
exit( 1 );
}
if ( scmanal->get_length( 0 ) != scmanal->get_length( 1 ) ) {
fprintf( stderr, "%s: Input file sizes differ.\n", argv[ 0 ] );
if ( scmanal->get_type( 0 ) != TIME_DOMAIN ) {
exit( 1 );
}
}
size_t length = MINVAL( scmanal->get_length( 0 ), scmanal->get_length( 1 ) );
if ( (scmanal->get_begin( 0 ) != scmanal->get_begin( 1 ))
|| (scmanal->get_compl_begin( 0 ) != scmanal->get_compl_begin( 1 ))
|| (scmanal->get_compl_end( 0 ) != scmanal->get_compl_end( 1 ))) {
fprintf( stderr, "%s: Input file spans differ.\n", argv[ 0 ] );
exit( 1 );
}
if ( ( scmanal->get_end( 0 ) != scmanal->get_end( 1 ) )
&& ( scmanal->get_type( 0 ) != TIME_DOMAIN ) ) {
fprintf( stderr, "%s: Input file ends differ.\n", argv[ 0 ] );
exit( 1 );
}
double min_end = MINVAL( scmanal->get_end( 0 ), scmanal->get_end( 1 ) );
scmanal->set_type( 2, scmanal->get_type( 0 ) );
scmanal->set_begin( 2, scmanal->get_begin( 0 ) );
scmanal->set_end( 2, min_end );
scmanal->set_compl_begin( 2, scmanal->get_compl_begin( 0 ) );
scmanal->set_compl_end( 2, scmanal->get_compl_end( 0 ) );
scmanal->make_outputs( length );
double
*input_1 = scmanal->get_file( 0 ),
*input_2 = scmanal->get_file( 1 ),
*output = scmanal->get_file( 2 );
for ( uint i = 0; i < length; i++ ) {
output[ i ] = input_1[ i ] + input_2[ i ];
}
delete scmanal;
}
示例2: main
int main( int argc, char **argv )
{
Analysis *scmanal = new Analysis( 2, 1, 3, "R C TAU", argc, argv );
double r_ohms = atof( argv[ 3 ] );
double c_farads = atof( argv[ 4 ] );
double tau_seconds = atof( argv[ 5 ] );
size_t length = scmanal->get_length( 0 );
if ( scmanal->get_type( 0 ) != FFT_DOMAIN ) {
fprintf( stderr, "%s: Input is not FFT domain.\n", argv[ 0 ] );
exit( 1 );
}
char output_comment[ 256 ];
snprintf( output_comment, 256, "RCDelay(%s, R=%f, C=%f, tau=%f)",
scmanal->get_comment( 0 ),
r_ohms, c_farads, tau_seconds );
scmanal->set_comment( 1, output_comment );
double begin_freq = scmanal->get_begin( 0 );
double end_freq = scmanal->get_end( 0 );
scmanal->set_type( 1, FFT_DOMAIN );
scmanal->set_begin( 1, begin_freq );
scmanal->set_end( 1, end_freq );
scmanal->set_compl_begin( 1, scmanal->get_compl_begin( 0 ) );
scmanal->set_compl_end( 1, scmanal->get_compl_end( 0 ) );
scmanal->make_outputs( length );
double *input = scmanal->get_file( 0 ), *output = scmanal->get_file( 1 );
/* DC is not delayed */
output[ 0 ] = input[ 0 ];
for ( uint i = 1; i < (length+1) / 2; i++ ) {
double a_real = input[ i ];
double a_imag = input[ length - i ];
double frequency = begin_freq + ((end_freq - begin_freq) * 2 * i / length);
double delay = tau_seconds + ((M_PI / 2) - atan(r_ohms * c_farads * 2 * M_PI * frequency)) / (2 * M_PI * frequency);
double argument = - 2 * M_PI * delay * frequency;
double b_real = cos( argument );
double b_imag = sin( argument );
output[ i ] = a_real * b_real - a_imag * b_imag;
output[ length - i ] = a_imag * b_real + a_real * b_imag;
}
if ( length % 2 == 0 ) {
output[ length / 2 ] = 0;
}
delete scmanal;
}