📄 fc_test.cpp
字号:
/*
===============================================================================
FILE: fc_test.cpp
CONTENTS:
A small program that tests the floating point compressor.
PROGRAMMERS:
martin isenburg@cs.unc.edu
COPYRIGHT:
copyright (C) 2003 martin isenburg@cs.unc.edu
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
CHANGE HISTORY:
23 June 2004 -- created after finishing the paper with Ajith
===============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "floatcompressorold.h"
#include "floatcompressornew.h"
#include "rangemodel.h"
#include "rangeencoder.h"
int main(int argc, char *argv[])
{
unsigned y, size_y = 5000;
unsigned x, size_x = 1025;
FloatCompressorOld *fc_old = new FloatCompressorOld();
FloatCompressorNew *fc_new = new FloatCompressorNew();
// old coder
printf("starting old compression ...\n");
fc_old->SetupCompressor(0);
// zero instead of rangeencoder pointer will then use internally separate rangencoder for sign, exponent, and mantissa
fc_old->CompressAcross(-0.89f, -1.01f);
for (y = 0; y != size_y; y++)
for (x = 0; x != size_x; x++)
{
fc_old->CompressAcross(0.0f, 0.0f);
}
fc_old->FinishCompressor();
printf("done.\n");
fprintf(stderr, "SIGN %8.6f EXPO %8.6f MANT %5.3f TOTAL %5.3f\n",
8.0f*fc_old->GetSignBytes()/(size_y*size_x),8.0f*fc_old->GetExponentBytes()/(size_y*size_x),
8.0f*fc_old->GetMantissaBytes()/(size_y*size_x),8.0f*fc_old->GetTotalBytes()/(size_y*size_x));
printf("starting old decompression ...\n");
fc_old->SetupDecompressor(0); // zero instead of rangeencoder pointer will then use internally separate rangencoder for sign, exponent, and mantissa
if (fc_old->DecompressAcross(-0.89f) != -1.01f) {printf("error1\n"); exit(1);}
for (y = 0; y != size_y; y++)
for (x = 0; x != size_x; x++)
{
if (fc_old->DecompressAcross(0.0f) != 0.0f) {printf("error2\n"); exit(1);}
}
fc_old->FinishDecompressor();
printf("done.\n");
// new coder
printf("starting new compression ...\n");
fc_new->SetupCompressor(0); // zero instead of rangeencoder pointer will then use internally separate rangencoder for signexponent, and mantissa
fc_new->CompressAcross(-0.89f, -1.01f);
for (y = 0; y != size_y; y++)
for (x = 0; x != size_x; x++)
{
fc_new->CompressAcross(0.0f, 0.0f);
}
fc_new->FinishCompressor();
printf("done.\n");
fprintf(stderr, "SIGNEXPO %8.6f MANT %5.3f TOTAL %5.3f MANT(%5.3f,%5.3f,%5.3f)\n",
8.0f*fc_new->GetSignExponentBytes()/(size_y*size_x),8.0f*fc_new->GetMantissaBytes()/(size_y*size_x),
8.0f*fc_new->GetTotalBytes()/(size_y*size_x),8.0f*fc_new->GetMantissaBytes(0)/(size_y*size_x),
8.0f*fc_new->GetMantissaBytes(1)/(size_y*size_x),8.0f*fc_new->GetMantissaBytes(2)/(size_y*size_x));
printf("starting new decompression ...\n");
fc_new->SetupDecompressor(0); // zero instead of rangeencoder pointer will then use internally separate rangencoder for signexponent, and mantissa
if (fc_new->DecompressAcross(-0.89f) != -1.01f) {printf("error1\n"); exit(1);}
for (y = 0; y != size_y; y++)
for (x = 0; x != size_x; x++)
{
if (fc_new->DecompressAcross(0.0f) != 0.0f) {printf("error2\n"); exit(1);}
}
fc_new->FinishDecompressor();
printf("done.\n");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -