26   for (I a = 1; a < 15; a++) {  
    27     I b = (I)(
Rand() % 10);
    28     I c = (I)(
Rand() % 10);
    29     if (std::numeric_limits<I>::is_signed) {
    30       if (
Rand() % 2 == 0) b = -b;
    31       if (
Rand() % 2 == 0) c = -c;
    33     if (b == 0 && c == 0) 
continue;  
    40     if (b <= 0 || c <= 0) 
continue;  
    67         std::floor(static_cast<double>(a) / static_cast<double>(b)));
    72   UnitTestGcdLcmTpl<int>();
    73   UnitTestGcdLcmTpl<size_t>();
    74   UnitTestGcdLcmTpl<int16>();
    79   std::cout << 
"Testing random-number generation.  "    80             << 
"If there is an error this may not terminate.\n";
    81   std::cout << 
"If this does not terminate, look more closely.  "    82             << 
"There might be a problem [but might not be]\n";
    83   for (
int i = 1; 
i < 10; 
i++) {
    85       std::cout << 
"Test RandUniform\n";
    88       for (
int j = 0; ; 
j++) {
    90         if (std::abs(sum) < 0.5*sqrt(static_cast<double>(
j))) 
break;
    95       for (
int j = 0; ; 
j++) {
    97         if (std::abs(sum) < 0.5*sqrt(static_cast<double>(
j))) 
break;
   102       for (
int j = 0; ; 
j++) {
   105         if (
i % 2 == 0) sum += a;
   108         if (std::abs(sum) < 0.5*sqrt(static_cast<double>(
j))) 
break;
   114       std::cout << 
"Test RandPoisson\n";
   117       for (
int j = 0; ; 
j++) {
   119         if (std::abs(sum) < 0.5*sqrt(static_cast<double>(
j))) 
break;
   132         KALDI_ASSERT(tot > (n * p * 0.8) && tot < (n * p * 1.2));
   139         KALDI_ASSERT(tot > (n * p * 0.8) && tot < (n * p * 1.2));
   145       std::cout << 
"Test RandInt\n";
   146       int minint = 
Rand() % 200;
   147       int maxint = minint + 1 + 
Rand()  % 20;
   149       float sum = 
RandInt(minint, maxint) +  0.5*(minint+maxint);
   150       for (
int j = 0; ; 
j++) {
   151         sum += 
RandInt(minint, maxint) - 0.5*(minint+maxint);
   152         if (std::abs(static_cast<float>(sum)) <
   153             0.5*sqrt(static_cast<double>(
j))*(maxint-minint)) 
break;
   172   for (
int i = 0; 
i < 100; 
i++) {
   173     double f1 = 
Rand() % 10000, f2 = 
Rand() % 20;
   176     double add = f1 + f2, thresh = add*0.00001;
   177     KALDI_ASSERT(std::abs(add-add1) < thresh && std::abs(add-add2) < thresh);
   182              thresh = (f2*0.01)+0.001;
   207                && 
"If this test fails, you can probably just comment it out-- "   208                "may mean your CPU exceeds expected floating point precision");
   210                && 
"If this test fails, you can probably just comment it out-- "   211                "may mean your CPU exceeds expected floating point precision");
   213                && std::abs(cos(
M_PI)+1.0) < 1.0e-05);
   215                && std::abs(cos(
M_2PI)-1.0) < 1.0e-05);
   221   for (
int i = 1; 
i < 100; 
i++) {
   222     float f1 = 
Rand() % 10000 + 1, f2 = 
Rand() % 20 + 1;
   223     float tmp1 = f1 * f2;
   224     float tmp2 = (1/f1 + 1/f2);
   226     float addeql = tmp1 * tmp2;
   227     float thresh = 0.00001;
   233   for (
int p= 0; p < 100; p++) {
   234     I m = 
Rand() % 100000;
   236       std::vector<I> factors;
   239       for (
size_t i = 0; 
i < factors.size(); 
i++) {
   241         if (
i+1 < factors.size())
   250   UnitTestFactorizeTpl<int>();
   251   UnitTestFactorizeTpl<size_t>();
   252   UnitTestFactorizeTpl<int16>();
   264                             -std::numeric_limits<float>::infinity()));
   266                            std::numeric_limits<float>::infinity()));
   268                            -std::numeric_limits<float>::infinity()));
   283     for (
int i = 0; 
i < block_size; 
i++) {
   286     num_ops += block_size;
   290   Real flops = 1.0e-06 * num_ops / tim.
Elapsed();
   292             << (
sizeof(Real) == 4 ? 
"float" : 
"double") << 
") is " << flops;
   304     for (
int i = 0; 
i < block_size; 
i++) {
   305       sum += 
Log(static_cast<float>(
i + 1));
   307     num_ops += block_size;
   311   Real flops = 1.0e-06 * num_ops / tim.
Elapsed();
   313             << (
sizeof(Real) == 4 ? 
"float" : 
"double") << 
") is " << flops;
   319   using namespace kaldi;
   329   UnitTestExpSpeed<float>();
   330   UnitTestExpSpeed<double>();
   331   UnitTestLogSpeed<float>();
   332   UnitTestLogSpeed<double>();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
static int32 DivideRoundingDown(int32 a, int32 b)
Returns a / b, rounding towards negative infinity in all cases. 
 
void UnitTestDivideRoundingDown()
 
float RandUniform(struct RandomState *state=NULL)
Returns a random number strictly between 0 and 1. 
 
bool WithProb(BaseFloat prob, struct RandomState *state)
 
Float RandPrune(Float post, BaseFloat prune_thresh, struct RandomState *state=NULL)
 
#define KALDI_ISFINITE(x)
 
float RandGauss(struct RandomState *state=NULL)
 
int32 RoundUpToNearestPowerOfTwo(int32 n)
 
void UnitTestRoundUpToNearestPowerOfTwo()
 
I Lcm(I m, I n)
Returns the least common multiple of two integers. 
 
int32 RandPoisson(float lambda, struct RandomState *state)
 
double LogSub(double x, double y)
 
void RandGauss2(float *a, float *b, RandomState *state)
 
void UnitTestAssertFunc()
 
int Rand(struct RandomState *state)
 
double LogAdd(double x, double y)
 
#define KALDI_ASSERT(cond)
 
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b)) 
 
const float kLogZeroFloat
 
const double kLogZeroDouble
 
double Elapsed() const
Returns time in seconds. 
 
void UnitTestFactorizeTpl()
 
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)). 
 
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)
 
void Factorize(I m, std::vector< I > *factors)
 
void UnitTestApproxEqual()